babylon.module.d.ts 5.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  466. * @param convertedColor defines the Color3 object where to store the linear space version
  467. * @returns the unmodified Color3
  468. */
  469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  470. /**
  471. * Computes a new Color3 converted from the current one to gamma space
  472. * @returns a new Color3 object
  473. */
  474. toGammaSpace(): Color3;
  475. /**
  476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  477. * @param convertedColor defines the Color3 object where to store the gamma space version
  478. * @returns the unmodified Color3
  479. */
  480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  481. private static _BlackReadOnly;
  482. /**
  483. * Creates a new Color3 from the string containing valid hexadecimal values
  484. * @param hex defines a string containing valid hexadecimal values
  485. * @returns a new Color3 object
  486. */
  487. static FromHexString(hex: string): Color3;
  488. /**
  489. * Creates a new Color3 from the starting index of the given array
  490. * @param array defines the source array
  491. * @param offset defines an offset in the source array
  492. * @returns a new Color3 object
  493. */
  494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  495. /**
  496. * Creates a new Color3 from integer values (< 256)
  497. * @param r defines the red component to read from (value between 0 and 255)
  498. * @param g defines the green component to read from (value between 0 and 255)
  499. * @param b defines the blue component to read from (value between 0 and 255)
  500. * @returns a new Color3 object
  501. */
  502. static FromInts(r: number, g: number, b: number): Color3;
  503. /**
  504. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  505. * @param start defines the start Color3 value
  506. * @param end defines the end Color3 value
  507. * @param amount defines the gradient value between start and end
  508. * @returns a new Color3 object
  509. */
  510. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  511. /**
  512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  513. * @param left defines the start value
  514. * @param right defines the end value
  515. * @param amount defines the gradient factor
  516. * @param result defines the Color3 object where to store the result
  517. */
  518. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  519. /**
  520. * Returns a Color3 value containing a red color
  521. * @returns a new Color3 object
  522. */
  523. static Red(): Color3;
  524. /**
  525. * Returns a Color3 value containing a green color
  526. * @returns a new Color3 object
  527. */
  528. static Green(): Color3;
  529. /**
  530. * Returns a Color3 value containing a blue color
  531. * @returns a new Color3 object
  532. */
  533. static Blue(): Color3;
  534. /**
  535. * Returns a Color3 value containing a black color
  536. * @returns a new Color3 object
  537. */
  538. static Black(): Color3;
  539. /**
  540. * Gets a Color3 value containing a black color that must not be updated
  541. */
  542. static readonly BlackReadOnly: DeepImmutable<Color3>;
  543. /**
  544. * Returns a Color3 value containing a white color
  545. * @returns a new Color3 object
  546. */
  547. static White(): Color3;
  548. /**
  549. * Returns a Color3 value containing a purple color
  550. * @returns a new Color3 object
  551. */
  552. static Purple(): Color3;
  553. /**
  554. * Returns a Color3 value containing a magenta color
  555. * @returns a new Color3 object
  556. */
  557. static Magenta(): Color3;
  558. /**
  559. * Returns a Color3 value containing a yellow color
  560. * @returns a new Color3 object
  561. */
  562. static Yellow(): Color3;
  563. /**
  564. * Returns a Color3 value containing a gray color
  565. * @returns a new Color3 object
  566. */
  567. static Gray(): Color3;
  568. /**
  569. * Returns a Color3 value containing a teal color
  570. * @returns a new Color3 object
  571. */
  572. static Teal(): Color3;
  573. /**
  574. * Returns a Color3 value containing a random color
  575. * @returns a new Color3 object
  576. */
  577. static Random(): Color3;
  578. }
  579. /**
  580. * Class used to hold a RBGA color
  581. */
  582. export class Color4 {
  583. /**
  584. * Defines the red component (between 0 and 1, default is 0)
  585. */
  586. r: number;
  587. /**
  588. * Defines the green component (between 0 and 1, default is 0)
  589. */
  590. g: number;
  591. /**
  592. * Defines the blue component (between 0 and 1, default is 0)
  593. */
  594. b: number;
  595. /**
  596. * Defines the alpha component (between 0 and 1, default is 1)
  597. */
  598. a: number;
  599. /**
  600. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  601. * @param r defines the red component (between 0 and 1, default is 0)
  602. * @param g defines the green component (between 0 and 1, default is 0)
  603. * @param b defines the blue component (between 0 and 1, default is 0)
  604. * @param a defines the alpha component (between 0 and 1, default is 1)
  605. */
  606. constructor(
  607. /**
  608. * Defines the red component (between 0 and 1, default is 0)
  609. */
  610. r?: number,
  611. /**
  612. * Defines the green component (between 0 and 1, default is 0)
  613. */
  614. g?: number,
  615. /**
  616. * Defines the blue component (between 0 and 1, default is 0)
  617. */
  618. b?: number,
  619. /**
  620. * Defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. a?: number);
  623. /**
  624. * Adds in place the given Color4 values to the current Color4 object
  625. * @param right defines the second operand
  626. * @returns the current updated Color4 object
  627. */
  628. addInPlace(right: DeepImmutable<Color4>): Color4;
  629. /**
  630. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  631. * @returns the new array
  632. */
  633. asArray(): number[];
  634. /**
  635. * Stores from the starting index in the given array the Color4 successive values
  636. * @param array defines the array where to store the r,g,b components
  637. * @param index defines an optional index in the target array to define where to start storing values
  638. * @returns the current Color4 object
  639. */
  640. toArray(array: number[], index?: number): Color4;
  641. /**
  642. * Determines equality between Color4 objects
  643. * @param otherColor defines the second operand
  644. * @returns true if the rgba values are equal to the given ones
  645. */
  646. equals(otherColor: DeepImmutable<Color4>): boolean;
  647. /**
  648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. add(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  655. * @param right defines the second operand
  656. * @returns a new Color4 object
  657. */
  658. subtract(right: DeepImmutable<Color4>): Color4;
  659. /**
  660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  661. * @param right defines the second operand
  662. * @param result defines the Color4 object where to store the result
  663. * @returns the current Color4 object
  664. */
  665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  666. /**
  667. * Creates a new Color4 with the current Color4 values multiplied by scale
  668. * @param scale defines the scaling factor to apply
  669. * @returns a new Color4 object
  670. */
  671. scale(scale: number): Color4;
  672. /**
  673. * Multiplies the current Color4 values by scale and stores the result in "result"
  674. * @param scale defines the scaling factor to apply
  675. * @param result defines the Color4 object where to store the result
  676. * @returns the current unmodified Color4
  677. */
  678. scaleToRef(scale: number, result: Color4): Color4;
  679. /**
  680. * Scale the current Color4 values by a factor and add the result to a given Color4
  681. * @param scale defines the scale factor
  682. * @param result defines the Color4 object where to store the result
  683. * @returns the unmodified current Color4
  684. */
  685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  686. /**
  687. * Clamps the rgb values by the min and max values and stores the result into "result"
  688. * @param min defines minimum clamping value (default is 0)
  689. * @param max defines maximum clamping value (default is 1)
  690. * @param result defines color to store the result into.
  691. * @returns the cuurent Color4
  692. */
  693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  694. /**
  695. * Multipy an Color4 value by another and return a new Color4 object
  696. * @param color defines the Color4 value to multiply by
  697. * @returns a new Color4 object
  698. */
  699. multiply(color: Color4): Color4;
  700. /**
  701. * Multipy a Color4 value by another and push the result in a reference value
  702. * @param color defines the Color4 value to multiply by
  703. * @param result defines the Color4 to fill the result in
  704. * @returns the result Color4
  705. */
  706. multiplyToRef(color: Color4, result: Color4): Color4;
  707. /**
  708. * Creates a string with the Color4 current values
  709. * @returns the string representation of the Color4 object
  710. */
  711. toString(): string;
  712. /**
  713. * Returns the string "Color4"
  714. * @returns "Color4"
  715. */
  716. getClassName(): string;
  717. /**
  718. * Compute the Color4 hash code
  719. * @returns an unique number that can be used to hash Color4 objects
  720. */
  721. getHashCode(): number;
  722. /**
  723. * Creates a new Color4 copied from the current one
  724. * @returns a new Color4 object
  725. */
  726. clone(): Color4;
  727. /**
  728. * Copies the given Color4 values into the current one
  729. * @param source defines the source Color4 object
  730. * @returns the current updated Color4 object
  731. */
  732. copyFrom(source: Color4): Color4;
  733. /**
  734. * Copies the given float values into the current one
  735. * @param r defines the red component to read from
  736. * @param g defines the green component to read from
  737. * @param b defines the blue component to read from
  738. * @param a defines the alpha component to read from
  739. * @returns the current updated Color4 object
  740. */
  741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  742. /**
  743. * Copies the given float values into the current one
  744. * @param r defines the red component to read from
  745. * @param g defines the green component to read from
  746. * @param b defines the blue component to read from
  747. * @param a defines the alpha component to read from
  748. * @returns the current updated Color4 object
  749. */
  750. set(r: number, g: number, b: number, a: number): Color4;
  751. /**
  752. * Compute the Color4 hexadecimal code as a string
  753. * @returns a string containing the hexadecimal representation of the Color4 object
  754. */
  755. toHexString(): string;
  756. /**
  757. * Computes a new Color4 converted from the current one to linear space
  758. * @returns a new Color4 object
  759. */
  760. toLinearSpace(): Color4;
  761. /**
  762. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  763. * @param convertedColor defines the Color4 object where to store the linear space version
  764. * @returns the unmodified Color4
  765. */
  766. toLinearSpaceToRef(convertedColor: Color4): Color4;
  767. /**
  768. * Computes a new Color4 converted from the current one to gamma space
  769. * @returns a new Color4 object
  770. */
  771. toGammaSpace(): Color4;
  772. /**
  773. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  774. * @param convertedColor defines the Color4 object where to store the gamma space version
  775. * @returns the unmodified Color4
  776. */
  777. toGammaSpaceToRef(convertedColor: Color4): Color4;
  778. /**
  779. * Creates a new Color4 from the string containing valid hexadecimal values
  780. * @param hex defines a string containing valid hexadecimal values
  781. * @returns a new Color4 object
  782. */
  783. static FromHexString(hex: string): Color4;
  784. /**
  785. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  786. * @param left defines the start value
  787. * @param right defines the end value
  788. * @param amount defines the gradient factor
  789. * @returns a new Color4 object
  790. */
  791. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  792. /**
  793. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  794. * @param left defines the start value
  795. * @param right defines the end value
  796. * @param amount defines the gradient factor
  797. * @param result defines the Color4 object where to store data
  798. */
  799. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  800. /**
  801. * Creates a new Color4 from a Color3 and an alpha value
  802. * @param color3 defines the source Color3 to read from
  803. * @param alpha defines the alpha component (1.0 by default)
  804. * @returns a new Color4 object
  805. */
  806. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  807. /**
  808. * Creates a new Color4 from the starting index element of the given array
  809. * @param array defines the source array to read from
  810. * @param offset defines the offset in the source array
  811. * @returns a new Color4 object
  812. */
  813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  814. /**
  815. * Creates a new Color3 from integer values (< 256)
  816. * @param r defines the red component to read from (value between 0 and 255)
  817. * @param g defines the green component to read from (value between 0 and 255)
  818. * @param b defines the blue component to read from (value between 0 and 255)
  819. * @param a defines the alpha component to read from (value between 0 and 255)
  820. * @returns a new Color3 object
  821. */
  822. static FromInts(r: number, g: number, b: number, a: number): Color4;
  823. /**
  824. * Check the content of a given array and convert it to an array containing RGBA data
  825. * If the original array was already containing count * 4 values then it is returned directly
  826. * @param colors defines the array to check
  827. * @param count defines the number of RGBA data to expect
  828. * @returns an array containing count * 4 values (RGBA)
  829. */
  830. static CheckColors4(colors: number[], count: number): number[];
  831. }
  832. /**
  833. * Class representing a vector containing 2 coordinates
  834. */
  835. export class Vector2 {
  836. /** defines the first coordinate */
  837. x: number;
  838. /** defines the second coordinate */
  839. y: number;
  840. /**
  841. * Creates a new Vector2 from the given x and y coordinates
  842. * @param x defines the first coordinate
  843. * @param y defines the second coordinate
  844. */
  845. constructor(
  846. /** defines the first coordinate */
  847. x?: number,
  848. /** defines the second coordinate */
  849. y?: number);
  850. /**
  851. * Gets a string with the Vector2 coordinates
  852. * @returns a string with the Vector2 coordinates
  853. */
  854. toString(): string;
  855. /**
  856. * Gets class name
  857. * @returns the string "Vector2"
  858. */
  859. getClassName(): string;
  860. /**
  861. * Gets current vector hash code
  862. * @returns the Vector2 hash code as a number
  863. */
  864. getHashCode(): number;
  865. /**
  866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  867. * @param array defines the source array
  868. * @param index defines the offset in source array
  869. * @returns the current Vector2
  870. */
  871. toArray(array: FloatArray, index?: number): Vector2;
  872. /**
  873. * Copy the current vector to an array
  874. * @returns a new array with 2 elements: the Vector2 coordinates.
  875. */
  876. asArray(): number[];
  877. /**
  878. * Sets the Vector2 coordinates with the given Vector2 coordinates
  879. * @param source defines the source Vector2
  880. * @returns the current updated Vector2
  881. */
  882. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  883. /**
  884. * Sets the Vector2 coordinates with the given floats
  885. * @param x defines the first coordinate
  886. * @param y defines the second coordinate
  887. * @returns the current updated Vector2
  888. */
  889. copyFromFloats(x: number, y: number): Vector2;
  890. /**
  891. * Sets the Vector2 coordinates with the given floats
  892. * @param x defines the first coordinate
  893. * @param y defines the second coordinate
  894. * @returns the current updated Vector2
  895. */
  896. set(x: number, y: number): Vector2;
  897. /**
  898. * Add another vector with the current one
  899. * @param otherVector defines the other vector
  900. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  901. */
  902. add(otherVector: DeepImmutable<Vector2>): Vector2;
  903. /**
  904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  905. * @param otherVector defines the other vector
  906. * @param result defines the target vector
  907. * @returns the unmodified current Vector2
  908. */
  909. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  910. /**
  911. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  912. * @param otherVector defines the other vector
  913. * @returns the current updated Vector2
  914. */
  915. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  916. /**
  917. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. addVector3(otherVector: Vector3): Vector2;
  922. /**
  923. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  924. * @param otherVector defines the other vector
  925. * @returns a new Vector2
  926. */
  927. subtract(otherVector: Vector2): Vector2;
  928. /**
  929. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  930. * @param otherVector defines the other vector
  931. * @param result defines the target vector
  932. * @returns the unmodified current Vector2
  933. */
  934. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  935. /**
  936. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Multiplies in place the current Vector2 coordinates by the given ones
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  953. /**
  954. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @param result defines the target vector
  957. * @returns the unmodified current Vector2
  958. */
  959. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  960. /**
  961. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  962. * @param x defines the first coordinate
  963. * @param y defines the second coordinate
  964. * @returns a new Vector2
  965. */
  966. multiplyByFloats(x: number, y: number): Vector2;
  967. /**
  968. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @returns a new Vector2
  971. */
  972. divide(otherVector: Vector2): Vector2;
  973. /**
  974. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  975. * @param otherVector defines the other vector
  976. * @param result defines the target vector
  977. * @returns the unmodified current Vector2
  978. */
  979. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  980. /**
  981. * Divides the current Vector2 coordinates by the given ones
  982. * @param otherVector defines the other vector
  983. * @returns the current updated Vector2
  984. */
  985. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  986. /**
  987. * Gets a new Vector2 with current Vector2 negated coordinates
  988. * @returns a new Vector2
  989. */
  990. negate(): Vector2;
  991. /**
  992. * Multiply the Vector2 coordinates by scale
  993. * @param scale defines the scaling factor
  994. * @returns the current updated Vector2
  995. */
  996. scaleInPlace(scale: number): Vector2;
  997. /**
  998. * Returns a new Vector2 scaled by "scale" from the current Vector2
  999. * @param scale defines the scaling factor
  1000. * @returns a new Vector2
  1001. */
  1002. scale(scale: number): Vector2;
  1003. /**
  1004. * Scale the current Vector2 values by a factor to a given Vector2
  1005. * @param scale defines the scale factor
  1006. * @param result defines the Vector2 object where to store the result
  1007. * @returns the unmodified current Vector2
  1008. */
  1009. scaleToRef(scale: number, result: Vector2): Vector2;
  1010. /**
  1011. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1012. * @param scale defines the scale factor
  1013. * @param result defines the Vector2 object where to store the result
  1014. * @returns the unmodified current Vector2
  1015. */
  1016. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1017. /**
  1018. * Gets a boolean if two vectors are equals
  1019. * @param otherVector defines the other vector
  1020. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1021. */
  1022. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1023. /**
  1024. * Gets a boolean if two vectors are equals (using an epsilon value)
  1025. * @param otherVector defines the other vector
  1026. * @param epsilon defines the minimal distance to consider equality
  1027. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1028. */
  1029. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1030. /**
  1031. * Gets a new Vector2 from current Vector2 floored values
  1032. * @returns a new Vector2
  1033. */
  1034. floor(): Vector2;
  1035. /**
  1036. * Gets a new Vector2 from current Vector2 floored values
  1037. * @returns a new Vector2
  1038. */
  1039. fract(): Vector2;
  1040. /**
  1041. * Gets the length of the vector
  1042. * @returns the vector length (float)
  1043. */
  1044. length(): number;
  1045. /**
  1046. * Gets the vector squared length
  1047. * @returns the vector squared length (float)
  1048. */
  1049. lengthSquared(): number;
  1050. /**
  1051. * Normalize the vector
  1052. * @returns the current updated Vector2
  1053. */
  1054. normalize(): Vector2;
  1055. /**
  1056. * Gets a new Vector2 copied from the Vector2
  1057. * @returns a new Vector2
  1058. */
  1059. clone(): Vector2;
  1060. /**
  1061. * Gets a new Vector2(0, 0)
  1062. * @returns a new Vector2
  1063. */
  1064. static Zero(): Vector2;
  1065. /**
  1066. * Gets a new Vector2(1, 1)
  1067. * @returns a new Vector2
  1068. */
  1069. static One(): Vector2;
  1070. /**
  1071. * Gets a new Vector2 set from the given index element of the given array
  1072. * @param array defines the data source
  1073. * @param offset defines the offset in the data source
  1074. * @returns a new Vector2
  1075. */
  1076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1077. /**
  1078. * Sets "result" from the given index element of the given array
  1079. * @param array defines the data source
  1080. * @param offset defines the offset in the data source
  1081. * @param result defines the target vector
  1082. */
  1083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1084. /**
  1085. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1086. * @param value1 defines 1st point of control
  1087. * @param value2 defines 2nd point of control
  1088. * @param value3 defines 3rd point of control
  1089. * @param value4 defines 4th point of control
  1090. * @param amount defines the interpolation factor
  1091. * @returns a new Vector2
  1092. */
  1093. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1094. /**
  1095. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1096. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1097. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1098. * @param value defines the value to clamp
  1099. * @param min defines the lower limit
  1100. * @param max defines the upper limit
  1101. * @returns a new Vector2
  1102. */
  1103. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1104. /**
  1105. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1106. * @param value1 defines the 1st control point
  1107. * @param tangent1 defines the outgoing tangent
  1108. * @param value2 defines the 2nd control point
  1109. * @param tangent2 defines the incoming tangent
  1110. * @param amount defines the interpolation factor
  1111. * @returns a new Vector2
  1112. */
  1113. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1116. * @param start defines the start vector
  1117. * @param end defines the end vector
  1118. * @param amount defines the interpolation factor
  1119. * @returns a new Vector2
  1120. */
  1121. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1122. /**
  1123. * Gets the dot product of the vector "left" and the vector "right"
  1124. * @param left defines first vector
  1125. * @param right defines second vector
  1126. * @returns the dot product (float)
  1127. */
  1128. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1129. /**
  1130. * Returns a new Vector2 equal to the normalized given vector
  1131. * @param vector defines the vector to normalize
  1132. * @returns a new Vector2
  1133. */
  1134. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1137. * @param left defines 1st vector
  1138. * @param right defines 2nd vector
  1139. * @returns a new Vector2
  1140. */
  1141. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1142. /**
  1143. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1144. * @param left defines 1st vector
  1145. * @param right defines 2nd vector
  1146. * @returns a new Vector2
  1147. */
  1148. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1149. /**
  1150. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1151. * @param vector defines the vector to transform
  1152. * @param transformation defines the matrix to apply
  1153. * @returns a new Vector2
  1154. */
  1155. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1156. /**
  1157. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1158. * @param vector defines the vector to transform
  1159. * @param transformation defines the matrix to apply
  1160. * @param result defines the target vector
  1161. */
  1162. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1163. /**
  1164. * Determines if a given vector is included in a triangle
  1165. * @param p defines the vector to test
  1166. * @param p0 defines 1st triangle point
  1167. * @param p1 defines 2nd triangle point
  1168. * @param p2 defines 3rd triangle point
  1169. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1170. */
  1171. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1172. /**
  1173. * Gets the distance between the vectors "value1" and "value2"
  1174. * @param value1 defines first vector
  1175. * @param value2 defines second vector
  1176. * @returns the distance between vectors
  1177. */
  1178. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1179. /**
  1180. * Returns the squared distance between the vectors "value1" and "value2"
  1181. * @param value1 defines first vector
  1182. * @param value2 defines second vector
  1183. * @returns the squared distance between vectors
  1184. */
  1185. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1186. /**
  1187. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1188. * @param value1 defines first vector
  1189. * @param value2 defines second vector
  1190. * @returns a new Vector2
  1191. */
  1192. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1193. /**
  1194. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1195. * @param p defines the middle point
  1196. * @param segA defines one point of the segment
  1197. * @param segB defines the other point of the segment
  1198. * @returns the shortest distance
  1199. */
  1200. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1201. }
  1202. /**
  1203. * Classed used to store (x,y,z) vector representation
  1204. * A Vector3 is the main object used in 3D geometry
  1205. * It can represent etiher the coordinates of a point the space, either a direction
  1206. * Reminder: js uses a left handed forward facing system
  1207. */
  1208. export class Vector3 {
  1209. /**
  1210. * Defines the first coordinates (on X axis)
  1211. */
  1212. x: number;
  1213. /**
  1214. * Defines the second coordinates (on Y axis)
  1215. */
  1216. y: number;
  1217. /**
  1218. * Defines the third coordinates (on Z axis)
  1219. */
  1220. z: number;
  1221. private static _UpReadOnly;
  1222. /**
  1223. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1224. * @param x defines the first coordinates (on X axis)
  1225. * @param y defines the second coordinates (on Y axis)
  1226. * @param z defines the third coordinates (on Z axis)
  1227. */
  1228. constructor(
  1229. /**
  1230. * Defines the first coordinates (on X axis)
  1231. */
  1232. x?: number,
  1233. /**
  1234. * Defines the second coordinates (on Y axis)
  1235. */
  1236. y?: number,
  1237. /**
  1238. * Defines the third coordinates (on Z axis)
  1239. */
  1240. z?: number);
  1241. /**
  1242. * Creates a string representation of the Vector3
  1243. * @returns a string with the Vector3 coordinates.
  1244. */
  1245. toString(): string;
  1246. /**
  1247. * Gets the class name
  1248. * @returns the string "Vector3"
  1249. */
  1250. getClassName(): string;
  1251. /**
  1252. * Creates the Vector3 hash code
  1253. * @returns a number which tends to be unique between Vector3 instances
  1254. */
  1255. getHashCode(): number;
  1256. /**
  1257. * Creates an array containing three elements : the coordinates of the Vector3
  1258. * @returns a new array of numbers
  1259. */
  1260. asArray(): number[];
  1261. /**
  1262. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1263. * @param array defines the destination array
  1264. * @param index defines the offset in the destination array
  1265. * @returns the current Vector3
  1266. */
  1267. toArray(array: FloatArray, index?: number): Vector3;
  1268. /**
  1269. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1270. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1271. */
  1272. toQuaternion(): Quaternion;
  1273. /**
  1274. * Adds the given vector to the current Vector3
  1275. * @param otherVector defines the second operand
  1276. * @returns the current updated Vector3
  1277. */
  1278. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1279. /**
  1280. * Adds the given coordinates to the current Vector3
  1281. * @param x defines the x coordinate of the operand
  1282. * @param y defines the y coordinate of the operand
  1283. * @param z defines the z coordinate of the operand
  1284. * @returns the current updated Vector3
  1285. */
  1286. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1287. /**
  1288. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1289. * @param otherVector defines the second operand
  1290. * @returns the resulting Vector3
  1291. */
  1292. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1293. /**
  1294. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1295. * @param otherVector defines the second operand
  1296. * @param result defines the Vector3 object where to store the result
  1297. * @returns the current Vector3
  1298. */
  1299. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1300. /**
  1301. * Subtract the given vector from the current Vector3
  1302. * @param otherVector defines the second operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1306. /**
  1307. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1321. * @param x defines the x coordinate of the operand
  1322. * @param y defines the y coordinate of the operand
  1323. * @param z defines the z coordinate of the operand
  1324. * @returns the resulting Vector3
  1325. */
  1326. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1327. /**
  1328. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1329. * @param x defines the x coordinate of the operand
  1330. * @param y defines the y coordinate of the operand
  1331. * @param z defines the z coordinate of the operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1336. /**
  1337. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1338. * @returns a new Vector3
  1339. */
  1340. negate(): Vector3;
  1341. /**
  1342. * Multiplies the Vector3 coordinates by the float "scale"
  1343. * @param scale defines the multiplier factor
  1344. * @returns the current updated Vector3
  1345. */
  1346. scaleInPlace(scale: number): Vector3;
  1347. /**
  1348. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1349. * @param scale defines the multiplier factor
  1350. * @returns a new Vector3
  1351. */
  1352. scale(scale: number): Vector3;
  1353. /**
  1354. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1355. * @param scale defines the multiplier factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. scaleToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1362. * @param scale defines the scale factor
  1363. * @param result defines the Vector3 object where to store the result
  1364. * @returns the unmodified current Vector3
  1365. */
  1366. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1367. /**
  1368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1369. * @param otherVector defines the second operand
  1370. * @returns true if both vectors are equals
  1371. */
  1372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1375. * @param otherVector defines the second operand
  1376. * @param epsilon defines the minimal distance to define values as equals
  1377. * @returns true if both vectors are distant less than epsilon
  1378. */
  1379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1380. /**
  1381. * Returns true if the current Vector3 coordinates equals the given floats
  1382. * @param x defines the x coordinate of the operand
  1383. * @param y defines the y coordinate of the operand
  1384. * @param z defines the z coordinate of the operand
  1385. * @returns true if both vectors are equals
  1386. */
  1387. equalsToFloats(x: number, y: number, z: number): boolean;
  1388. /**
  1389. * Multiplies the current Vector3 coordinates by the given ones
  1390. * @param otherVector defines the second operand
  1391. * @returns the current updated Vector3
  1392. */
  1393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1394. /**
  1395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1396. * @param otherVector defines the second operand
  1397. * @returns the new Vector3
  1398. */
  1399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1400. /**
  1401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1402. * @param otherVector defines the second operand
  1403. * @param result defines the Vector3 object where to store the result
  1404. * @returns the current Vector3
  1405. */
  1406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1407. /**
  1408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1409. * @param x defines the x coordinate of the operand
  1410. * @param y defines the y coordinate of the operand
  1411. * @param z defines the z coordinate of the operand
  1412. * @returns the new Vector3
  1413. */
  1414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1415. /**
  1416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1417. * @param otherVector defines the second operand
  1418. * @returns the new Vector3
  1419. */
  1420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1423. * @param otherVector defines the second operand
  1424. * @param result defines the Vector3 object where to store the result
  1425. * @returns the current Vector3
  1426. */
  1427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1428. /**
  1429. * Divides the current Vector3 coordinates by the given ones.
  1430. * @param otherVector defines the second operand
  1431. * @returns the current updated Vector3
  1432. */
  1433. divideInPlace(otherVector: Vector3): Vector3;
  1434. /**
  1435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1436. * @param other defines the second operand
  1437. * @returns the current updated Vector3
  1438. */
  1439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1442. * @param other defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1448. * @param x defines the x coordinate of the operand
  1449. * @param y defines the y coordinate of the operand
  1450. * @param z defines the z coordinate of the operand
  1451. * @returns the current updated Vector3
  1452. */
  1453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1454. /**
  1455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1456. * @param x defines the x coordinate of the operand
  1457. * @param y defines the y coordinate of the operand
  1458. * @param z defines the z coordinate of the operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1462. /**
  1463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1464. * Check if is non uniform within a certain amount of decimal places to account for this
  1465. * @param epsilon the amount the values can differ
  1466. * @returns if the the vector is non uniform to a certain number of decimal places
  1467. */
  1468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1469. /**
  1470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1471. */
  1472. readonly isNonUniform: boolean;
  1473. /**
  1474. * Gets a new Vector3 from current Vector3 floored values
  1475. * @returns a new Vector3
  1476. */
  1477. floor(): Vector3;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. fract(): Vector3;
  1483. /**
  1484. * Gets the length of the Vector3
  1485. * @returns the length of the Vecto3
  1486. */
  1487. length(): number;
  1488. /**
  1489. * Gets the squared length of the Vector3
  1490. * @returns squared length of the Vector3
  1491. */
  1492. lengthSquared(): number;
  1493. /**
  1494. * Normalize the current Vector3.
  1495. * Please note that this is an in place operation.
  1496. * @returns the current updated Vector3
  1497. */
  1498. normalize(): Vector3;
  1499. /**
  1500. * Reorders the x y z properties of the vector in place
  1501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1502. * @returns the current updated vector
  1503. */
  1504. reorderInPlace(order: string): this;
  1505. /**
  1506. * Rotates the vector around 0,0,0 by a quaternion
  1507. * @param quaternion the rotation quaternion
  1508. * @param result vector to store the result
  1509. * @returns the resulting vector
  1510. */
  1511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1512. /**
  1513. * Rotates a vector around a given point
  1514. * @param quaternion the rotation quaternion
  1515. * @param point the point to rotate around
  1516. * @param result vector to store the result
  1517. * @returns the resulting vector
  1518. */
  1519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1520. /**
  1521. * Normalize the current Vector3 with the given input length.
  1522. * Please note that this is an in place operation.
  1523. * @param len the length of the vector
  1524. * @returns the current updated Vector3
  1525. */
  1526. normalizeFromLength(len: number): Vector3;
  1527. /**
  1528. * Normalize the current Vector3 to a new vector
  1529. * @returns the new Vector3
  1530. */
  1531. normalizeToNew(): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 to the reference
  1534. * @param reference define the Vector3 to update
  1535. * @returns the updated Vector3
  1536. */
  1537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1538. /**
  1539. * Creates a new Vector3 copied from the current Vector3
  1540. * @returns the new Vector3
  1541. */
  1542. clone(): Vector3;
  1543. /**
  1544. * Copies the given vector coordinates to the current Vector3 ones
  1545. * @param source defines the source Vector3
  1546. * @returns the current updated Vector3
  1547. */
  1548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Copies the given floats to the current Vector3 coordinates
  1551. * @param x defines the x coordinate of the operand
  1552. * @param y defines the y coordinate of the operand
  1553. * @param z defines the z coordinate of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. copyFromFloats(x: number, y: number, z: number): Vector3;
  1557. /**
  1558. * Copies the given floats to the current Vector3 coordinates
  1559. * @param x defines the x coordinate of the operand
  1560. * @param y defines the y coordinate of the operand
  1561. * @param z defines the z coordinate of the operand
  1562. * @returns the current updated Vector3
  1563. */
  1564. set(x: number, y: number, z: number): Vector3;
  1565. /**
  1566. * Copies the given float to the current Vector3 coordinates
  1567. * @param v defines the x, y and z coordinates of the operand
  1568. * @returns the current updated Vector3
  1569. */
  1570. setAll(v: number): Vector3;
  1571. /**
  1572. * Get the clip factor between two vectors
  1573. * @param vector0 defines the first operand
  1574. * @param vector1 defines the second operand
  1575. * @param axis defines the axis to use
  1576. * @param size defines the size along the axis
  1577. * @returns the clip factor
  1578. */
  1579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1580. /**
  1581. * Get angle between two vectors
  1582. * @param vector0 angle between vector0 and vector1
  1583. * @param vector1 angle between vector0 and vector1
  1584. * @param normal direction of the normal
  1585. * @return the angle between vector0 and vector1
  1586. */
  1587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1588. /**
  1589. * Returns a new Vector3 set from the index "offset" of the given array
  1590. * @param array defines the source array
  1591. * @param offset defines the offset in the source array
  1592. * @returns the new Vector3
  1593. */
  1594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1595. /**
  1596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1597. * This function is deprecated. Use FromArray instead
  1598. * @param array defines the source array
  1599. * @param offset defines the offset in the source array
  1600. * @returns the new Vector3
  1601. */
  1602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1603. /**
  1604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1605. * @param array defines the source array
  1606. * @param offset defines the offset in the source array
  1607. * @param result defines the Vector3 where to store the result
  1608. */
  1609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1610. /**
  1611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1612. * This function is deprecated. Use FromArrayToRef instead.
  1613. * @param array defines the source array
  1614. * @param offset defines the offset in the source array
  1615. * @param result defines the Vector3 where to store the result
  1616. */
  1617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1618. /**
  1619. * Sets the given vector "result" with the given floats.
  1620. * @param x defines the x coordinate of the source
  1621. * @param y defines the y coordinate of the source
  1622. * @param z defines the z coordinate of the source
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1626. /**
  1627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1628. * @returns a new empty Vector3
  1629. */
  1630. static Zero(): Vector3;
  1631. /**
  1632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1633. * @returns a new unit Vector3
  1634. */
  1635. static One(): Vector3;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1638. * @returns a new up Vector3
  1639. */
  1640. static Up(): Vector3;
  1641. /**
  1642. * Gets a up Vector3 that must not be updated
  1643. */
  1644. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1647. * @returns a new down Vector3
  1648. */
  1649. static Down(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1652. * @returns a new forward Vector3
  1653. */
  1654. static Forward(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1657. * @returns a new forward Vector3
  1658. */
  1659. static Backward(): Vector3;
  1660. /**
  1661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1662. * @returns a new right Vector3
  1663. */
  1664. static Right(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1667. * @returns a new left Vector3
  1668. */
  1669. static Left(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1673. * @param vector defines the Vector3 to transform
  1674. * @param transformation defines the transformation matrix
  1675. * @returns the transformed Vector3
  1676. */
  1677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1678. /**
  1679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @param result defines the Vector3 where to store the result
  1684. */
  1685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1686. /**
  1687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1688. * This method computes tranformed coordinates only, not transformed direction vectors
  1689. * @param x define the x coordinate of the source vector
  1690. * @param y define the y coordinate of the source vector
  1691. * @param z define the z coordinate of the source vector
  1692. * @param transformation defines the transformation matrix
  1693. * @param result defines the Vector3 where to store the result
  1694. */
  1695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1696. /**
  1697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1699. * @param vector defines the Vector3 to transform
  1700. * @param transformation defines the transformation matrix
  1701. * @returns the new Vector3
  1702. */
  1703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1704. /**
  1705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param x define the x coordinate of the source vector
  1716. * @param y define the y coordinate of the source vector
  1717. * @param z define the z coordinate of the source vector
  1718. * @param transformation defines the transformation matrix
  1719. * @param result defines the Vector3 where to store the result
  1720. */
  1721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1722. /**
  1723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1724. * @param value1 defines the first control point
  1725. * @param value2 defines the second control point
  1726. * @param value3 defines the third control point
  1727. * @param value4 defines the fourth control point
  1728. * @param amount defines the amount on the spline to use
  1729. * @returns the new Vector3
  1730. */
  1731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1732. /**
  1733. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1736. * @param value defines the current value
  1737. * @param min defines the lower range value
  1738. * @param max defines the upper range value
  1739. * @returns the new Vector3
  1740. */
  1741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1742. /**
  1743. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1746. * @param value defines the current value
  1747. * @param min defines the lower range value
  1748. * @param max defines the upper range value
  1749. * @param result defines the Vector3 where to store the result
  1750. */
  1751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1752. /**
  1753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1754. * @param value1 defines the first control point
  1755. * @param tangent1 defines the first tangent vector
  1756. * @param value2 defines the second control point
  1757. * @param tangent2 defines the second tangent vector
  1758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1759. * @returns the new Vector3
  1760. */
  1761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1762. /**
  1763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1764. * @param start defines the start value
  1765. * @param end defines the end value
  1766. * @param amount max defines amount between both (between 0 and 1)
  1767. * @returns the new Vector3
  1768. */
  1769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1770. /**
  1771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1772. * @param start defines the start value
  1773. * @param end defines the end value
  1774. * @param amount max defines amount between both (between 0 and 1)
  1775. * @param result defines the Vector3 where to store the result
  1776. */
  1777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1778. /**
  1779. * Returns the dot product (float) between the vectors "left" and "right"
  1780. * @param left defines the left operand
  1781. * @param right defines the right operand
  1782. * @returns the dot product
  1783. */
  1784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1785. /**
  1786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1787. * The cross product is then orthogonal to both "left" and "right"
  1788. * @param left defines the left operand
  1789. * @param right defines the right operand
  1790. * @returns the cross product
  1791. */
  1792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the cross product of "left" and "right"
  1795. * The cross product is then orthogonal to both "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1801. /**
  1802. * Returns a new Vector3 as the normalization of the given vector
  1803. * @param vector defines the Vector3 to normalize
  1804. * @returns the new Vector3
  1805. */
  1806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1807. /**
  1808. * Sets the given vector "result" with the normalization of the given first vector
  1809. * @param vector defines the Vector3 to normalize
  1810. * @param result defines the Vector3 where to store the result
  1811. */
  1812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1813. /**
  1814. * Project a Vector3 onto screen space
  1815. * @param vector defines the Vector3 to project
  1816. * @param world defines the world matrix to use
  1817. * @param transform defines the transform (view x projection) matrix to use
  1818. * @param viewport defines the screen viewport to use
  1819. * @returns the new Vector3
  1820. */
  1821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1822. /** @hidden */
  1823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1824. /**
  1825. * Unproject from screen space to object space
  1826. * @param source defines the screen space Vector3 to use
  1827. * @param viewportWidth defines the current width of the viewport
  1828. * @param viewportHeight defines the current height of the viewport
  1829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1830. * @param transform defines the transform (view x projection) matrix to use
  1831. * @returns the new Vector3
  1832. */
  1833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1834. /**
  1835. * Unproject from screen space to object space
  1836. * @param source defines the screen space Vector3 to use
  1837. * @param viewportWidth defines the current width of the viewport
  1838. * @param viewportHeight defines the current height of the viewport
  1839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1840. * @param view defines the view matrix to use
  1841. * @param projection defines the projection matrix to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param view defines the view matrix to use
  1852. * @param projection defines the projection matrix to use
  1853. * @param result defines the Vector3 where to store the result
  1854. */
  1855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param sourceX defines the screen space x coordinate to use
  1859. * @param sourceY defines the screen space y coordinate to use
  1860. * @param sourceZ defines the screen space z coordinate to use
  1861. * @param viewportWidth defines the current width of the viewport
  1862. * @param viewportHeight defines the current height of the viewport
  1863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1864. * @param view defines the view matrix to use
  1865. * @param projection defines the projection matrix to use
  1866. * @param result defines the Vector3 where to store the result
  1867. */
  1868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1869. /**
  1870. * Gets the minimal coordinate values between two Vector3
  1871. * @param left defines the first operand
  1872. * @param right defines the second operand
  1873. * @returns the new Vector3
  1874. */
  1875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1876. /**
  1877. * Gets the maximal coordinate values between two Vector3
  1878. * @param left defines the first operand
  1879. * @param right defines the second operand
  1880. * @returns the new Vector3
  1881. */
  1882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1883. /**
  1884. * Returns the distance between the vectors "value1" and "value2"
  1885. * @param value1 defines the first operand
  1886. * @param value2 defines the second operand
  1887. * @returns the distance
  1888. */
  1889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1890. /**
  1891. * Returns the squared distance between the vectors "value1" and "value2"
  1892. * @param value1 defines the first operand
  1893. * @param value2 defines the second operand
  1894. * @returns the squared distance
  1895. */
  1896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1897. /**
  1898. * Returns a new Vector3 located at the center between "value1" and "value2"
  1899. * @param value1 defines the first operand
  1900. * @param value2 defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1907. * to something in order to rotate it from its local system to the given target system
  1908. * Note: axis1, axis2 and axis3 are normalized during this operation
  1909. * @param axis1 defines the first axis
  1910. * @param axis2 defines the second axis
  1911. * @param axis3 defines the third axis
  1912. * @returns a new Vector3
  1913. */
  1914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1915. /**
  1916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1917. * @param axis1 defines the first axis
  1918. * @param axis2 defines the second axis
  1919. * @param axis3 defines the third axis
  1920. * @param ref defines the Vector3 where to store the result
  1921. */
  1922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1923. }
  1924. /**
  1925. * Vector4 class created for EulerAngle class conversion to Quaternion
  1926. */
  1927. export class Vector4 {
  1928. /** x value of the vector */
  1929. x: number;
  1930. /** y value of the vector */
  1931. y: number;
  1932. /** z value of the vector */
  1933. z: number;
  1934. /** w value of the vector */
  1935. w: number;
  1936. /**
  1937. * Creates a Vector4 object from the given floats.
  1938. * @param x x value of the vector
  1939. * @param y y value of the vector
  1940. * @param z z value of the vector
  1941. * @param w w value of the vector
  1942. */
  1943. constructor(
  1944. /** x value of the vector */
  1945. x: number,
  1946. /** y value of the vector */
  1947. y: number,
  1948. /** z value of the vector */
  1949. z: number,
  1950. /** w value of the vector */
  1951. w: number);
  1952. /**
  1953. * Returns the string with the Vector4 coordinates.
  1954. * @returns a string containing all the vector values
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Returns the string "Vector4".
  1959. * @returns "Vector4"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Returns the Vector4 hash code.
  1964. * @returns a unique hash code
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1969. * @returns the resulting array
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Populates the given array from the given index with the Vector4 coordinates.
  1974. * @param array array to populate
  1975. * @param index index of the array to start at (default: 0)
  1976. * @returns the Vector4.
  1977. */
  1978. toArray(array: FloatArray, index?: number): Vector4;
  1979. /**
  1980. * Adds the given vector to the current Vector4.
  1981. * @param otherVector the vector to add
  1982. * @returns the updated Vector4.
  1983. */
  1984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1985. /**
  1986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1987. * @param otherVector the vector to add
  1988. * @returns the resulting vector
  1989. */
  1990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1991. /**
  1992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1993. * @param otherVector the vector to add
  1994. * @param result the vector to store the result
  1995. * @returns the current Vector4.
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1998. /**
  1999. * Subtract in place the given vector from the current Vector4.
  2000. * @param otherVector the vector to subtract
  2001. * @returns the updated Vector4.
  2002. */
  2003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2004. /**
  2005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2006. * @param otherVector the vector to add
  2007. * @returns the new vector with the result
  2008. */
  2009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2010. /**
  2011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2012. * @param otherVector the vector to subtract
  2013. * @param result the vector to store the result
  2014. * @returns the current Vector4.
  2015. */
  2016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. */
  2020. /**
  2021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2022. * @param x value to subtract
  2023. * @param y value to subtract
  2024. * @param z value to subtract
  2025. * @param w value to subtract
  2026. * @returns new vector containing the result
  2027. */
  2028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2029. /**
  2030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2031. * @param x value to subtract
  2032. * @param y value to subtract
  2033. * @param z value to subtract
  2034. * @param w value to subtract
  2035. * @param result the vector to store the result in
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2041. * @returns a new vector with the negated values
  2042. */
  2043. negate(): Vector4;
  2044. /**
  2045. * Multiplies the current Vector4 coordinates by scale (float).
  2046. * @param scale the number to scale with
  2047. * @returns the updated Vector4.
  2048. */
  2049. scaleInPlace(scale: number): Vector4;
  2050. /**
  2051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2052. * @param scale the number to scale with
  2053. * @returns a new vector with the result
  2054. */
  2055. scale(scale: number): Vector4;
  2056. /**
  2057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2058. * @param scale the number to scale with
  2059. * @param result a vector to store the result in
  2060. * @returns the current Vector4.
  2061. */
  2062. scaleToRef(scale: number, result: Vector4): Vector4;
  2063. /**
  2064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector4 object where to store the result
  2067. * @returns the unmodified current Vector4
  2068. */
  2069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2070. /**
  2071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2072. * @param otherVector the vector to compare against
  2073. * @returns true if they are equal
  2074. */
  2075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2076. /**
  2077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2078. * @param otherVector vector to compare against
  2079. * @param epsilon (Default: very small number)
  2080. * @returns true if they are equal
  2081. */
  2082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2083. /**
  2084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2085. * @param x x value to compare against
  2086. * @param y y value to compare against
  2087. * @param z z value to compare against
  2088. * @param w w value to compare against
  2089. * @returns true if equal
  2090. */
  2091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2092. /**
  2093. * Multiplies in place the current Vector4 by the given one.
  2094. * @param otherVector vector to multiple with
  2095. * @returns the updated Vector4.
  2096. */
  2097. multiplyInPlace(otherVector: Vector4): Vector4;
  2098. /**
  2099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2100. * @param otherVector vector to multiple with
  2101. * @returns resulting new vector
  2102. */
  2103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2104. /**
  2105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2106. * @param otherVector vector to multiple with
  2107. * @param result vector to store the result
  2108. * @returns the current Vector4.
  2109. */
  2110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2111. /**
  2112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2113. * @param x x value multiply with
  2114. * @param y y value multiply with
  2115. * @param z z value multiply with
  2116. * @param w w value multiply with
  2117. * @returns resulting new vector
  2118. */
  2119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2122. * @param otherVector vector to devide with
  2123. * @returns resulting new vector
  2124. */
  2125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2128. * @param otherVector vector to devide with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Divides the current Vector3 coordinates by the given ones.
  2135. * @param otherVector vector to devide with
  2136. * @returns the updated Vector3.
  2137. */
  2138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2139. /**
  2140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2141. * @param other defines the second operand
  2142. * @returns the current updated Vector4
  2143. */
  2144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2145. /**
  2146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2147. * @param other defines the second operand
  2148. * @returns the current updated Vector4
  2149. */
  2150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2151. /**
  2152. * Gets a new Vector4 from current Vector4 floored values
  2153. * @returns a new Vector4
  2154. */
  2155. floor(): Vector4;
  2156. /**
  2157. * Gets a new Vector4 from current Vector3 floored values
  2158. * @returns a new Vector4
  2159. */
  2160. fract(): Vector4;
  2161. /**
  2162. * Returns the Vector4 length (float).
  2163. * @returns the length
  2164. */
  2165. length(): number;
  2166. /**
  2167. * Returns the Vector4 squared length (float).
  2168. * @returns the length squared
  2169. */
  2170. lengthSquared(): number;
  2171. /**
  2172. * Normalizes in place the Vector4.
  2173. * @returns the updated Vector4.
  2174. */
  2175. normalize(): Vector4;
  2176. /**
  2177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2178. * @returns this converted to a new vector3
  2179. */
  2180. toVector3(): Vector3;
  2181. /**
  2182. * Returns a new Vector4 copied from the current one.
  2183. * @returns the new cloned vector
  2184. */
  2185. clone(): Vector4;
  2186. /**
  2187. * Updates the current Vector4 with the given one coordinates.
  2188. * @param source the source vector to copy from
  2189. * @returns the updated Vector4.
  2190. */
  2191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2192. /**
  2193. * Updates the current Vector4 coordinates with the given floats.
  2194. * @param x float to copy from
  2195. * @param y float to copy from
  2196. * @param z float to copy from
  2197. * @param w float to copy from
  2198. * @returns the updated Vector4.
  2199. */
  2200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2201. /**
  2202. * Updates the current Vector4 coordinates with the given floats.
  2203. * @param x float to set from
  2204. * @param y float to set from
  2205. * @param z float to set from
  2206. * @param w float to set from
  2207. * @returns the updated Vector4.
  2208. */
  2209. set(x: number, y: number, z: number, w: number): Vector4;
  2210. /**
  2211. * Copies the given float to the current Vector3 coordinates
  2212. * @param v defines the x, y, z and w coordinates of the operand
  2213. * @returns the current updated Vector3
  2214. */
  2215. setAll(v: number): Vector4;
  2216. /**
  2217. * Returns a new Vector4 set from the starting index of the given array.
  2218. * @param array the array to pull values from
  2219. * @param offset the offset into the array to start at
  2220. * @returns the new vector
  2221. */
  2222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2223. /**
  2224. * Updates the given vector "result" from the starting index of the given array.
  2225. * @param array the array to pull values from
  2226. * @param offset the offset into the array to start at
  2227. * @param result the vector to store the result in
  2228. */
  2229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2230. /**
  2231. * Updates the given vector "result" from the starting index of the given Float32Array.
  2232. * @param array the array to pull values from
  2233. * @param offset the offset into the array to start at
  2234. * @param result the vector to store the result in
  2235. */
  2236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2237. /**
  2238. * Updates the given vector "result" coordinates from the given floats.
  2239. * @param x float to set from
  2240. * @param y float to set from
  2241. * @param z float to set from
  2242. * @param w float to set from
  2243. * @param result the vector to the floats in
  2244. */
  2245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2246. /**
  2247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2248. * @returns the new vector
  2249. */
  2250. static Zero(): Vector4;
  2251. /**
  2252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2253. * @returns the new vector
  2254. */
  2255. static One(): Vector4;
  2256. /**
  2257. * Returns a new normalized Vector4 from the given one.
  2258. * @param vector the vector to normalize
  2259. * @returns the vector
  2260. */
  2261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2262. /**
  2263. * Updates the given vector "result" from the normalization of the given one.
  2264. * @param vector the vector to normalize
  2265. * @param result the vector to store the result in
  2266. */
  2267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2268. /**
  2269. * Returns a vector with the minimum values from the left and right vectors
  2270. * @param left left vector to minimize
  2271. * @param right right vector to minimize
  2272. * @returns a new vector with the minimum of the left and right vector values
  2273. */
  2274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2275. /**
  2276. * Returns a vector with the maximum values from the left and right vectors
  2277. * @param left left vector to maximize
  2278. * @param right right vector to maximize
  2279. * @returns a new vector with the maximum of the left and right vector values
  2280. */
  2281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Returns the distance (float) between the vectors "value1" and "value2".
  2284. * @param value1 value to calulate the distance between
  2285. * @param value2 value to calulate the distance between
  2286. * @return the distance between the two vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2289. /**
  2290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2291. * @param value1 value to calulate the distance between
  2292. * @param value2 value to calulate the distance between
  2293. * @return the distance between the two vectors squared
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2296. /**
  2297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2298. * @param value1 value to calulate the center between
  2299. * @param value2 value to calulate the center between
  2300. * @return the center between the two vectors
  2301. */
  2302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2305. * This methods computes transformed normalized direction vectors only.
  2306. * @param vector the vector to transform
  2307. * @param transformation the transformation matrix to apply
  2308. * @returns the new vector
  2309. */
  2310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2311. /**
  2312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2313. * This methods computes transformed normalized direction vectors only.
  2314. * @param vector the vector to transform
  2315. * @param transformation the transformation matrix to apply
  2316. * @param result the vector to store the result in
  2317. */
  2318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2319. /**
  2320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param x value to transform
  2323. * @param y value to transform
  2324. * @param z value to transform
  2325. * @param w value to transform
  2326. * @param transformation the transformation matrix to apply
  2327. * @param result the vector to store the results in
  2328. */
  2329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2330. /**
  2331. * Creates a new Vector4 from a Vector3
  2332. * @param source defines the source data
  2333. * @param w defines the 4th component (default is 0)
  2334. * @returns a new Vector4
  2335. */
  2336. static FromVector3(source: Vector3, w?: number): Vector4;
  2337. }
  2338. /**
  2339. * Interface for the size containing width and height
  2340. */
  2341. export interface ISize {
  2342. /**
  2343. * Width
  2344. */
  2345. width: number;
  2346. /**
  2347. * Heighht
  2348. */
  2349. height: number;
  2350. }
  2351. /**
  2352. * Size containing widht and height
  2353. */
  2354. export class Size implements ISize {
  2355. /**
  2356. * Width
  2357. */
  2358. width: number;
  2359. /**
  2360. * Height
  2361. */
  2362. height: number;
  2363. /**
  2364. * Creates a Size object from the given width and height (floats).
  2365. * @param width width of the new size
  2366. * @param height height of the new size
  2367. */
  2368. constructor(width: number, height: number);
  2369. /**
  2370. * Returns a string with the Size width and height
  2371. * @returns a string with the Size width and height
  2372. */
  2373. toString(): string;
  2374. /**
  2375. * "Size"
  2376. * @returns the string "Size"
  2377. */
  2378. getClassName(): string;
  2379. /**
  2380. * Returns the Size hash code.
  2381. * @returns a hash code for a unique width and height
  2382. */
  2383. getHashCode(): number;
  2384. /**
  2385. * Updates the current size from the given one.
  2386. * @param src the given size
  2387. */
  2388. copyFrom(src: Size): void;
  2389. /**
  2390. * Updates in place the current Size from the given floats.
  2391. * @param width width of the new size
  2392. * @param height height of the new size
  2393. * @returns the updated Size.
  2394. */
  2395. copyFromFloats(width: number, height: number): Size;
  2396. /**
  2397. * Updates in place the current Size from the given floats.
  2398. * @param width width to set
  2399. * @param height height to set
  2400. * @returns the updated Size.
  2401. */
  2402. set(width: number, height: number): Size;
  2403. /**
  2404. * Multiplies the width and height by numbers
  2405. * @param w factor to multiple the width by
  2406. * @param h factor to multiple the height by
  2407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2408. */
  2409. multiplyByFloats(w: number, h: number): Size;
  2410. /**
  2411. * Clones the size
  2412. * @returns a new Size copied from the given one.
  2413. */
  2414. clone(): Size;
  2415. /**
  2416. * True if the current Size and the given one width and height are strictly equal.
  2417. * @param other the other size to compare against
  2418. * @returns True if the current Size and the given one width and height are strictly equal.
  2419. */
  2420. equals(other: Size): boolean;
  2421. /**
  2422. * The surface of the Size : width * height (float).
  2423. */
  2424. readonly surface: number;
  2425. /**
  2426. * Create a new size of zero
  2427. * @returns a new Size set to (0.0, 0.0)
  2428. */
  2429. static Zero(): Size;
  2430. /**
  2431. * Sums the width and height of two sizes
  2432. * @param otherSize size to add to this size
  2433. * @returns a new Size set as the addition result of the current Size and the given one.
  2434. */
  2435. add(otherSize: Size): Size;
  2436. /**
  2437. * Subtracts the width and height of two
  2438. * @param otherSize size to subtract to this size
  2439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2440. */
  2441. subtract(otherSize: Size): Size;
  2442. /**
  2443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2444. * @param start starting size to lerp between
  2445. * @param end end size to lerp between
  2446. * @param amount amount to lerp between the start and end values
  2447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2448. */
  2449. static Lerp(start: Size, end: Size, amount: number): Size;
  2450. }
  2451. /**
  2452. * Class used to store quaternion data
  2453. * @see https://en.wikipedia.org/wiki/Quaternion
  2454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2455. */
  2456. export class Quaternion {
  2457. /** defines the first component (0 by default) */
  2458. x: number;
  2459. /** defines the second component (0 by default) */
  2460. y: number;
  2461. /** defines the third component (0 by default) */
  2462. z: number;
  2463. /** defines the fourth component (1.0 by default) */
  2464. w: number;
  2465. /**
  2466. * Creates a new Quaternion from the given floats
  2467. * @param x defines the first component (0 by default)
  2468. * @param y defines the second component (0 by default)
  2469. * @param z defines the third component (0 by default)
  2470. * @param w defines the fourth component (1.0 by default)
  2471. */
  2472. constructor(
  2473. /** defines the first component (0 by default) */
  2474. x?: number,
  2475. /** defines the second component (0 by default) */
  2476. y?: number,
  2477. /** defines the third component (0 by default) */
  2478. z?: number,
  2479. /** defines the fourth component (1.0 by default) */
  2480. w?: number);
  2481. /**
  2482. * Gets a string representation for the current quaternion
  2483. * @returns a string with the Quaternion coordinates
  2484. */
  2485. toString(): string;
  2486. /**
  2487. * Gets the class name of the quaternion
  2488. * @returns the string "Quaternion"
  2489. */
  2490. getClassName(): string;
  2491. /**
  2492. * Gets a hash code for this quaternion
  2493. * @returns the quaternion hash code
  2494. */
  2495. getHashCode(): number;
  2496. /**
  2497. * Copy the quaternion to an array
  2498. * @returns a new array populated with 4 elements from the quaternion coordinates
  2499. */
  2500. asArray(): number[];
  2501. /**
  2502. * Check if two quaternions are equals
  2503. * @param otherQuaternion defines the second operand
  2504. * @return true if the current quaternion and the given one coordinates are strictly equals
  2505. */
  2506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2507. /**
  2508. * Clone the current quaternion
  2509. * @returns a new quaternion copied from the current one
  2510. */
  2511. clone(): Quaternion;
  2512. /**
  2513. * Copy a quaternion to the current one
  2514. * @param other defines the other quaternion
  2515. * @returns the updated current quaternion
  2516. */
  2517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2518. /**
  2519. * Updates the current quaternion with the given float coordinates
  2520. * @param x defines the x coordinate
  2521. * @param y defines the y coordinate
  2522. * @param z defines the z coordinate
  2523. * @param w defines the w coordinate
  2524. * @returns the updated current quaternion
  2525. */
  2526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2527. /**
  2528. * Updates the current quaternion from the given float coordinates
  2529. * @param x defines the x coordinate
  2530. * @param y defines the y coordinate
  2531. * @param z defines the z coordinate
  2532. * @param w defines the w coordinate
  2533. * @returns the updated current quaternion
  2534. */
  2535. set(x: number, y: number, z: number, w: number): Quaternion;
  2536. /**
  2537. * Adds two quaternions
  2538. * @param other defines the second operand
  2539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2540. */
  2541. add(other: DeepImmutable<Quaternion>): Quaternion;
  2542. /**
  2543. * Add a quaternion to the current one
  2544. * @param other defines the quaternion to add
  2545. * @returns the current quaternion
  2546. */
  2547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2548. /**
  2549. * Subtract two quaternions
  2550. * @param other defines the second operand
  2551. * @returns a new quaternion as the subtraction result of the given one from the current one
  2552. */
  2553. subtract(other: Quaternion): Quaternion;
  2554. /**
  2555. * Multiplies the current quaternion by a scale factor
  2556. * @param value defines the scale factor
  2557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2558. */
  2559. scale(value: number): Quaternion;
  2560. /**
  2561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2562. * @param scale defines the scale factor
  2563. * @param result defines the Quaternion object where to store the result
  2564. * @returns the unmodified current quaternion
  2565. */
  2566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2567. /**
  2568. * Multiplies in place the current quaternion by a scale factor
  2569. * @param value defines the scale factor
  2570. * @returns the current modified quaternion
  2571. */
  2572. scaleInPlace(value: number): Quaternion;
  2573. /**
  2574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2575. * @param scale defines the scale factor
  2576. * @param result defines the Quaternion object where to store the result
  2577. * @returns the unmodified current quaternion
  2578. */
  2579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2580. /**
  2581. * Multiplies two quaternions
  2582. * @param q1 defines the second operand
  2583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2584. */
  2585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2586. /**
  2587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2588. * @param q1 defines the second operand
  2589. * @param result defines the target quaternion
  2590. * @returns the current quaternion
  2591. */
  2592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2593. /**
  2594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2595. * @param q1 defines the second operand
  2596. * @returns the currentupdated quaternion
  2597. */
  2598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2599. /**
  2600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2601. * @param ref defines the target quaternion
  2602. * @returns the current quaternion
  2603. */
  2604. conjugateToRef(ref: Quaternion): Quaternion;
  2605. /**
  2606. * Conjugates in place (1-q) the current quaternion
  2607. * @returns the current updated quaternion
  2608. */
  2609. conjugateInPlace(): Quaternion;
  2610. /**
  2611. * Conjugates in place (1-q) the current quaternion
  2612. * @returns a new quaternion
  2613. */
  2614. conjugate(): Quaternion;
  2615. /**
  2616. * Gets length of current quaternion
  2617. * @returns the quaternion length (float)
  2618. */
  2619. length(): number;
  2620. /**
  2621. * Normalize in place the current quaternion
  2622. * @returns the current updated quaternion
  2623. */
  2624. normalize(): Quaternion;
  2625. /**
  2626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2627. * @param order is a reserved parameter and is ignore for now
  2628. * @returns a new Vector3 containing the Euler angles
  2629. */
  2630. toEulerAngles(order?: string): Vector3;
  2631. /**
  2632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2633. * @param result defines the vector which will be filled with the Euler angles
  2634. * @param order is a reserved parameter and is ignore for now
  2635. * @returns the current unchanged quaternion
  2636. */
  2637. toEulerAnglesToRef(result: Vector3): Quaternion;
  2638. /**
  2639. * Updates the given rotation matrix with the current quaternion values
  2640. * @param result defines the target matrix
  2641. * @returns the current unchanged quaternion
  2642. */
  2643. toRotationMatrix(result: Matrix): Quaternion;
  2644. /**
  2645. * Updates the current quaternion from the given rotation matrix values
  2646. * @param matrix defines the source matrix
  2647. * @returns the current updated quaternion
  2648. */
  2649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2650. /**
  2651. * Creates a new quaternion from a rotation matrix
  2652. * @param matrix defines the source matrix
  2653. * @returns a new quaternion created from the given rotation matrix values
  2654. */
  2655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2656. /**
  2657. * Updates the given quaternion with the given rotation matrix values
  2658. * @param matrix defines the source matrix
  2659. * @param result defines the target quaternion
  2660. */
  2661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2662. /**
  2663. * Returns the dot product (float) between the quaternions "left" and "right"
  2664. * @param left defines the left operand
  2665. * @param right defines the right operand
  2666. * @returns the dot product
  2667. */
  2668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2669. /**
  2670. * Checks if the two quaternions are close to each other
  2671. * @param quat0 defines the first quaternion to check
  2672. * @param quat1 defines the second quaternion to check
  2673. * @returns true if the two quaternions are close to each other
  2674. */
  2675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2676. /**
  2677. * Creates an empty quaternion
  2678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2679. */
  2680. static Zero(): Quaternion;
  2681. /**
  2682. * Inverse a given quaternion
  2683. * @param q defines the source quaternion
  2684. * @returns a new quaternion as the inverted current quaternion
  2685. */
  2686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2687. /**
  2688. * Inverse a given quaternion
  2689. * @param q defines the source quaternion
  2690. * @param result the quaternion the result will be stored in
  2691. * @returns the result quaternion
  2692. */
  2693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates an identity quaternion
  2696. * @returns the identity quaternion
  2697. */
  2698. static Identity(): Quaternion;
  2699. /**
  2700. * Gets a boolean indicating if the given quaternion is identity
  2701. * @param quaternion defines the quaternion to check
  2702. * @returns true if the quaternion is identity
  2703. */
  2704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2705. /**
  2706. * Creates a quaternion from a rotation around an axis
  2707. * @param axis defines the axis to use
  2708. * @param angle defines the angle to use
  2709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2710. */
  2711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2712. /**
  2713. * Creates a rotation around an axis and stores it into the given quaternion
  2714. * @param axis defines the axis to use
  2715. * @param angle defines the angle to use
  2716. * @param result defines the target quaternion
  2717. * @returns the target quaternion
  2718. */
  2719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2720. /**
  2721. * Creates a new quaternion from data stored into an array
  2722. * @param array defines the data source
  2723. * @param offset defines the offset in the source array where the data starts
  2724. * @returns a new quaternion
  2725. */
  2726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2727. /**
  2728. * Create a quaternion from Euler rotation angles
  2729. * @param x Pitch
  2730. * @param y Yaw
  2731. * @param z Roll
  2732. * @returns the new Quaternion
  2733. */
  2734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2735. /**
  2736. * Updates a quaternion from Euler rotation angles
  2737. * @param x Pitch
  2738. * @param y Yaw
  2739. * @param z Roll
  2740. * @param result the quaternion to store the result
  2741. * @returns the updated quaternion
  2742. */
  2743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2744. /**
  2745. * Create a quaternion from Euler rotation vector
  2746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2747. * @returns the new Quaternion
  2748. */
  2749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2750. /**
  2751. * Updates a quaternion from Euler rotation vector
  2752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2753. * @param result the quaternion to store the result
  2754. * @returns the updated quaternion
  2755. */
  2756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2757. /**
  2758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2759. * @param yaw defines the rotation around Y axis
  2760. * @param pitch defines the rotation around X axis
  2761. * @param roll defines the rotation around Z axis
  2762. * @returns the new quaternion
  2763. */
  2764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2765. /**
  2766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2767. * @param yaw defines the rotation around Y axis
  2768. * @param pitch defines the rotation around X axis
  2769. * @param roll defines the rotation around Z axis
  2770. * @param result defines the target quaternion
  2771. */
  2772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2775. * @param alpha defines the rotation around first axis
  2776. * @param beta defines the rotation around second axis
  2777. * @param gamma defines the rotation around third axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2781. /**
  2782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2783. * @param alpha defines the rotation around first axis
  2784. * @param beta defines the rotation around second axis
  2785. * @param gamma defines the rotation around third axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2789. /**
  2790. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2791. * @param axis1 defines the first axis
  2792. * @param axis2 defines the second axis
  2793. * @param axis3 defines the third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2797. /**
  2798. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2799. * @param axis1 defines the first axis
  2800. * @param axis2 defines the second axis
  2801. * @param axis3 defines the third axis
  2802. * @param ref defines the target quaternion
  2803. */
  2804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2805. /**
  2806. * Interpolates between two quaternions
  2807. * @param left defines first quaternion
  2808. * @param right defines second quaternion
  2809. * @param amount defines the gradient to use
  2810. * @returns the new interpolated quaternion
  2811. */
  2812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2813. /**
  2814. * Interpolates between two quaternions and stores it into a target quaternion
  2815. * @param left defines first quaternion
  2816. * @param right defines second quaternion
  2817. * @param amount defines the gradient to use
  2818. * @param result defines the target quaternion
  2819. */
  2820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2821. /**
  2822. * Interpolate between two quaternions using Hermite interpolation
  2823. * @param value1 defines first quaternion
  2824. * @param tangent1 defines the incoming tangent
  2825. * @param value2 defines second quaternion
  2826. * @param tangent2 defines the outgoing tangent
  2827. * @param amount defines the target quaternion
  2828. * @returns the new interpolated quaternion
  2829. */
  2830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2831. }
  2832. /**
  2833. * Class used to store matrix data (4x4)
  2834. */
  2835. export class Matrix {
  2836. private static _updateFlagSeed;
  2837. private static _identityReadOnly;
  2838. private _isIdentity;
  2839. private _isIdentityDirty;
  2840. private _isIdentity3x2;
  2841. private _isIdentity3x2Dirty;
  2842. /**
  2843. * Gets the update flag of the matrix which is an unique number for the matrix.
  2844. * It will be incremented every time the matrix data change.
  2845. * You can use it to speed the comparison between two versions of the same matrix.
  2846. */
  2847. updateFlag: number;
  2848. private readonly _m;
  2849. /**
  2850. * Gets the internal data of the matrix
  2851. */
  2852. readonly m: DeepImmutable<Float32Array>;
  2853. /** @hidden */
  2854. _markAsUpdated(): void;
  2855. /** @hidden */
  2856. private _updateIdentityStatus;
  2857. /**
  2858. * Creates an empty matrix (filled with zeros)
  2859. */
  2860. constructor();
  2861. /**
  2862. * Check if the current matrix is identity
  2863. * @returns true is the matrix is the identity matrix
  2864. */
  2865. isIdentity(): boolean;
  2866. /**
  2867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2868. * @returns true is the matrix is the identity matrix
  2869. */
  2870. isIdentityAs3x2(): boolean;
  2871. /**
  2872. * Gets the determinant of the matrix
  2873. * @returns the matrix determinant
  2874. */
  2875. determinant(): number;
  2876. /**
  2877. * Returns the matrix as a Float32Array
  2878. * @returns the matrix underlying array
  2879. */
  2880. toArray(): DeepImmutable<Float32Array>;
  2881. /**
  2882. * Returns the matrix as a Float32Array
  2883. * @returns the matrix underlying array.
  2884. */
  2885. asArray(): DeepImmutable<Float32Array>;
  2886. /**
  2887. * Inverts the current matrix in place
  2888. * @returns the current inverted matrix
  2889. */
  2890. invert(): Matrix;
  2891. /**
  2892. * Sets all the matrix elements to zero
  2893. * @returns the current matrix
  2894. */
  2895. reset(): Matrix;
  2896. /**
  2897. * Adds the current matrix with a second one
  2898. * @param other defines the matrix to add
  2899. * @returns a new matrix as the addition of the current matrix and the given one
  2900. */
  2901. add(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2904. * @param other defines the matrix to add
  2905. * @param result defines the target matrix
  2906. * @returns the current matrix
  2907. */
  2908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Adds in place the given matrix to the current matrix
  2911. * @param other defines the second operand
  2912. * @returns the current updated matrix
  2913. */
  2914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2915. /**
  2916. * Sets the given matrix to the current inverted Matrix
  2917. * @param other defines the target matrix
  2918. * @returns the unmodified current matrix
  2919. */
  2920. invertToRef(other: Matrix): Matrix;
  2921. /**
  2922. * add a value at the specified position in the current Matrix
  2923. * @param index the index of the value within the matrix. between 0 and 15.
  2924. * @param value the value to be added
  2925. * @returns the current updated matrix
  2926. */
  2927. addAtIndex(index: number, value: number): Matrix;
  2928. /**
  2929. * mutiply the specified position in the current Matrix by a value
  2930. * @param index the index of the value within the matrix. between 0 and 15.
  2931. * @param value the value to be added
  2932. * @returns the current updated matrix
  2933. */
  2934. multiplyAtIndex(index: number, value: number): Matrix;
  2935. /**
  2936. * Inserts the translation vector (using 3 floats) in the current matrix
  2937. * @param x defines the 1st component of the translation
  2938. * @param y defines the 2nd component of the translation
  2939. * @param z defines the 3rd component of the translation
  2940. * @returns the current updated matrix
  2941. */
  2942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2943. /**
  2944. * Adds the translation vector (using 3 floats) in the current matrix
  2945. * @param x defines the 1st component of the translation
  2946. * @param y defines the 2nd component of the translation
  2947. * @param z defines the 3rd component of the translation
  2948. * @returns the current updated matrix
  2949. */
  2950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector in the current matrix
  2953. * @param vector3 defines the translation to insert
  2954. * @returns the current updated matrix
  2955. */
  2956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2957. /**
  2958. * Gets the translation value of the current matrix
  2959. * @returns a new Vector3 as the extracted translation from the matrix
  2960. */
  2961. getTranslation(): Vector3;
  2962. /**
  2963. * Fill a Vector3 with the extracted translation from the matrix
  2964. * @param result defines the Vector3 where to store the translation
  2965. * @returns the current matrix
  2966. */
  2967. getTranslationToRef(result: Vector3): Matrix;
  2968. /**
  2969. * Remove rotation and scaling part from the matrix
  2970. * @returns the updated matrix
  2971. */
  2972. removeRotationAndScaling(): Matrix;
  2973. /**
  2974. * Multiply two matrices
  2975. * @param other defines the second operand
  2976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2977. */
  2978. multiply(other: DeepImmutable<Matrix>): Matrix;
  2979. /**
  2980. * Copy the current matrix from the given one
  2981. * @param other defines the source matrix
  2982. * @returns the current updated matrix
  2983. */
  2984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2985. /**
  2986. * Populates the given array from the starting index with the current matrix values
  2987. * @param array defines the target array
  2988. * @param offset defines the offset in the target array where to start storing values
  2989. * @returns the current matrix
  2990. */
  2991. copyToArray(array: Float32Array, offset?: number): Matrix;
  2992. /**
  2993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2994. * @param other defines the second operand
  2995. * @param result defines the matrix where to store the multiplication
  2996. * @returns the current matrix
  2997. */
  2998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2999. /**
  3000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3001. * @param other defines the second operand
  3002. * @param result defines the array where to store the multiplication
  3003. * @param offset defines the offset in the target array where to start storing values
  3004. * @returns the current matrix
  3005. */
  3006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3007. /**
  3008. * Check equality between this matrix and a second one
  3009. * @param value defines the second matrix to compare
  3010. * @returns true is the current matrix and the given one values are strictly equal
  3011. */
  3012. equals(value: DeepImmutable<Matrix>): boolean;
  3013. /**
  3014. * Clone the current matrix
  3015. * @returns a new matrix from the current matrix
  3016. */
  3017. clone(): Matrix;
  3018. /**
  3019. * Returns the name of the current matrix class
  3020. * @returns the string "Matrix"
  3021. */
  3022. getClassName(): string;
  3023. /**
  3024. * Gets the hash code of the current matrix
  3025. * @returns the hash code
  3026. */
  3027. getHashCode(): number;
  3028. /**
  3029. * Decomposes the current Matrix into a translation, rotation and scaling components
  3030. * @param scale defines the scale vector3 given as a reference to update
  3031. * @param rotation defines the rotation quaternion given as a reference to update
  3032. * @param translation defines the translation vector3 given as a reference to update
  3033. * @returns true if operation was successful
  3034. */
  3035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3036. /**
  3037. * Gets specific row of the matrix
  3038. * @param index defines the number of the row to get
  3039. * @returns the index-th row of the current matrix as a new Vector4
  3040. */
  3041. getRow(index: number): Nullable<Vector4>;
  3042. /**
  3043. * Sets the index-th row of the current matrix to the vector4 values
  3044. * @param index defines the number of the row to set
  3045. * @param row defines the target vector4
  3046. * @returns the updated current matrix
  3047. */
  3048. setRow(index: number, row: Vector4): Matrix;
  3049. /**
  3050. * Compute the transpose of the matrix
  3051. * @returns the new transposed matrix
  3052. */
  3053. transpose(): Matrix;
  3054. /**
  3055. * Compute the transpose of the matrix and store it in a given matrix
  3056. * @param result defines the target matrix
  3057. * @returns the current matrix
  3058. */
  3059. transposeToRef(result: Matrix): Matrix;
  3060. /**
  3061. * Sets the index-th row of the current matrix with the given 4 x float values
  3062. * @param index defines the row index
  3063. * @param x defines the x component to set
  3064. * @param y defines the y component to set
  3065. * @param z defines the z component to set
  3066. * @param w defines the w component to set
  3067. * @returns the updated current matrix
  3068. */
  3069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3070. /**
  3071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3072. * @param scale defines the scale factor
  3073. * @returns a new matrix
  3074. */
  3075. scale(scale: number): Matrix;
  3076. /**
  3077. * Scale the current matrix values by a factor to a given result matrix
  3078. * @param scale defines the scale factor
  3079. * @param result defines the matrix to store the result
  3080. * @returns the current matrix
  3081. */
  3082. scaleToRef(scale: number, result: Matrix): Matrix;
  3083. /**
  3084. * Scale the current matrix values by a factor and add the result to a given matrix
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Matrix to store the result
  3087. * @returns the current matrix
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3090. /**
  3091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3092. * @param ref matrix to store the result
  3093. */
  3094. toNormalMatrix(ref: Matrix): void;
  3095. /**
  3096. * Gets only rotation part of the current matrix
  3097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3098. */
  3099. getRotationMatrix(): Matrix;
  3100. /**
  3101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3102. * @param result defines the target matrix to store data to
  3103. * @returns the current matrix
  3104. */
  3105. getRotationMatrixToRef(result: Matrix): Matrix;
  3106. /**
  3107. * Toggles model matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleModelMatrixHandInPlace(): void;
  3110. /**
  3111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3112. */
  3113. toggleProjectionMatrixHandInPlace(): void;
  3114. /**
  3115. * Creates a matrix from an array
  3116. * @param array defines the source array
  3117. * @param offset defines an offset in the source array
  3118. * @returns a new Matrix set from the starting index of the given array
  3119. */
  3120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3121. /**
  3122. * Copy the content of an array into a given matrix
  3123. * @param array defines the source array
  3124. * @param offset defines an offset in the source array
  3125. * @param result defines the target matrix
  3126. */
  3127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3128. /**
  3129. * Stores an array into a matrix after having multiplied each component by a given factor
  3130. * @param array defines the source array
  3131. * @param offset defines the offset in the source array
  3132. * @param scale defines the scaling factor
  3133. * @param result defines the target matrix
  3134. */
  3135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3136. /**
  3137. * Gets an identity matrix that must not be updated
  3138. */
  3139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3140. /**
  3141. * Stores a list of values (16) inside a given matrix
  3142. * @param initialM11 defines 1st value of 1st row
  3143. * @param initialM12 defines 2nd value of 1st row
  3144. * @param initialM13 defines 3rd value of 1st row
  3145. * @param initialM14 defines 4th value of 1st row
  3146. * @param initialM21 defines 1st value of 2nd row
  3147. * @param initialM22 defines 2nd value of 2nd row
  3148. * @param initialM23 defines 3rd value of 2nd row
  3149. * @param initialM24 defines 4th value of 2nd row
  3150. * @param initialM31 defines 1st value of 3rd row
  3151. * @param initialM32 defines 2nd value of 3rd row
  3152. * @param initialM33 defines 3rd value of 3rd row
  3153. * @param initialM34 defines 4th value of 3rd row
  3154. * @param initialM41 defines 1st value of 4th row
  3155. * @param initialM42 defines 2nd value of 4th row
  3156. * @param initialM43 defines 3rd value of 4th row
  3157. * @param initialM44 defines 4th value of 4th row
  3158. * @param result defines the target matrix
  3159. */
  3160. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3161. /**
  3162. * Creates new matrix from a list of values (16)
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @returns the new matrix
  3180. */
  3181. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3182. /**
  3183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3184. * @param scale defines the scale vector3
  3185. * @param rotation defines the rotation quaternion
  3186. * @param translation defines the translation vector3
  3187. * @returns a new matrix
  3188. */
  3189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3190. /**
  3191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3192. * @param scale defines the scale vector3
  3193. * @param rotation defines the rotation quaternion
  3194. * @param translation defines the translation vector3
  3195. * @param result defines the target matrix
  3196. */
  3197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3198. /**
  3199. * Creates a new identity matrix
  3200. * @returns a new identity matrix
  3201. */
  3202. static Identity(): Matrix;
  3203. /**
  3204. * Creates a new identity matrix and stores the result in a given matrix
  3205. * @param result defines the target matrix
  3206. */
  3207. static IdentityToRef(result: Matrix): void;
  3208. /**
  3209. * Creates a new zero matrix
  3210. * @returns a new zero matrix
  3211. */
  3212. static Zero(): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis
  3215. * @param angle defines the angle (in radians) to use
  3216. * @return the new matrix
  3217. */
  3218. static RotationX(angle: number): Matrix;
  3219. /**
  3220. * Creates a new matrix as the invert of a given matrix
  3221. * @param source defines the source matrix
  3222. * @returns the new matrix
  3223. */
  3224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationXToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Y axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationY(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationYToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the Z axis
  3245. * @param angle defines the angle (in radians) to use
  3246. * @return the new matrix
  3247. */
  3248. static RotationZ(angle: number): Matrix;
  3249. /**
  3250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3251. * @param angle defines the angle (in radians) to use
  3252. * @param result defines the target matrix
  3253. */
  3254. static RotationZToRef(angle: number, result: Matrix): void;
  3255. /**
  3256. * Creates a new rotation matrix for "angle" radians around the given axis
  3257. * @param axis defines the axis to use
  3258. * @param angle defines the angle (in radians) to use
  3259. * @return the new matrix
  3260. */
  3261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3264. * @param axis defines the axis to use
  3265. * @param angle defines the angle (in radians) to use
  3266. * @param result defines the target matrix
  3267. */
  3268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3269. /**
  3270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3272. * @param from defines the vector to align
  3273. * @param to defines the vector to align to
  3274. * @param result defines the target matrix
  3275. */
  3276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3277. /**
  3278. * Creates a rotation matrix
  3279. * @param yaw defines the yaw angle in radians (Y axis)
  3280. * @param pitch defines the pitch angle in radians (X axis)
  3281. * @param roll defines the roll angle in radians (X axis)
  3282. * @returns the new rotation matrix
  3283. */
  3284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3285. /**
  3286. * Creates a rotation matrix and stores it in a given matrix
  3287. * @param yaw defines the yaw angle in radians (Y axis)
  3288. * @param pitch defines the pitch angle in radians (X axis)
  3289. * @param roll defines the roll angle in radians (X axis)
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3293. /**
  3294. * Creates a scaling matrix
  3295. * @param x defines the scale factor on X axis
  3296. * @param y defines the scale factor on Y axis
  3297. * @param z defines the scale factor on Z axis
  3298. * @returns the new matrix
  3299. */
  3300. static Scaling(x: number, y: number, z: number): Matrix;
  3301. /**
  3302. * Creates a scaling matrix and stores it in a given matrix
  3303. * @param x defines the scale factor on X axis
  3304. * @param y defines the scale factor on Y axis
  3305. * @param z defines the scale factor on Z axis
  3306. * @param result defines the target matrix
  3307. */
  3308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3309. /**
  3310. * Creates a translation matrix
  3311. * @param x defines the translation on X axis
  3312. * @param y defines the translation on Y axis
  3313. * @param z defines the translationon Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Translation(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a translation matrix and stores it in a given matrix
  3319. * @param x defines the translation on X axis
  3320. * @param y defines the translation on Y axis
  3321. * @param z defines the translationon Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3327. * @param startValue defines the start value
  3328. * @param endValue defines the end value
  3329. * @param gradient defines the gradient factor
  3330. * @returns the new matrix
  3331. */
  3332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3333. /**
  3334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3335. * @param startValue defines the start value
  3336. * @param endValue defines the end value
  3337. * @param gradient defines the gradient factor
  3338. * @param result defines the Matrix object where to store data
  3339. */
  3340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3341. /**
  3342. * Builds a new matrix whose values are computed by:
  3343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3346. * @param startValue defines the first matrix
  3347. * @param endValue defines the second matrix
  3348. * @param gradient defines the gradient between the two matrices
  3349. * @returns the new matrix
  3350. */
  3351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Update a matrix to values which are computed by:
  3354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3357. * @param startValue defines the first matrix
  3358. * @param endValue defines the second matrix
  3359. * @param gradient defines the gradient between the two matrices
  3360. * @param result defines the target matrix
  3361. */
  3362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3363. /**
  3364. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3365. * This function works in left handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3374. * This function works in left handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3383. * This function works in right handed mode
  3384. * @param eye defines the final position of the entity
  3385. * @param target defines where the entity should look at
  3386. * @param up defines the up vector for the entity
  3387. * @returns the new matrix
  3388. */
  3389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3390. /**
  3391. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3392. * This function works in right handed mode
  3393. * @param eye defines the final position of the entity
  3394. * @param target defines where the entity should look at
  3395. * @param up defines the up vector for the entity
  3396. * @param result defines the target matrix
  3397. */
  3398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param width defines the viewport width
  3402. * @param height defines the viewport height
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Store a left-handed orthographic projection to a given matrix
  3410. * @param width defines the viewport width
  3411. * @param height defines the viewport height
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. */
  3416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3417. /**
  3418. * Create a left-handed orthographic projection matrix
  3419. * @param left defines the viewport left coordinate
  3420. * @param right defines the viewport right coordinate
  3421. * @param bottom defines the viewport bottom coordinate
  3422. * @param top defines the viewport top coordinate
  3423. * @param znear defines the near clip plane
  3424. * @param zfar defines the far clip plane
  3425. * @returns a new matrix as a left-handed orthographic projection matrix
  3426. */
  3427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3428. /**
  3429. * Stores a left-handed orthographic projection into a given matrix
  3430. * @param left defines the viewport left coordinate
  3431. * @param right defines the viewport right coordinate
  3432. * @param bottom defines the viewport bottom coordinate
  3433. * @param top defines the viewport top coordinate
  3434. * @param znear defines the near clip plane
  3435. * @param zfar defines the far clip plane
  3436. * @param result defines the target matrix
  3437. */
  3438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3439. /**
  3440. * Creates a right-handed orthographic projection matrix
  3441. * @param left defines the viewport left coordinate
  3442. * @param right defines the viewport right coordinate
  3443. * @param bottom defines the viewport bottom coordinate
  3444. * @param top defines the viewport top coordinate
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a right-handed orthographic projection matrix
  3448. */
  3449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Stores a right-handed orthographic projection into a given matrix
  3452. * @param left defines the viewport left coordinate
  3453. * @param right defines the viewport right coordinate
  3454. * @param bottom defines the viewport bottom coordinate
  3455. * @param top defines the viewport top coordinate
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @param result defines the target matrix
  3459. */
  3460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param width defines the viewport width
  3464. * @param height defines the viewport height
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @returns a new matrix as a left-handed perspective projection matrix
  3468. */
  3469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Creates a left-handed perspective projection matrix
  3472. * @param fov defines the horizontal field of view
  3473. * @param aspect defines the aspect ratio
  3474. * @param znear defines the near clip plane
  3475. * @param zfar defines the far clip plane
  3476. * @returns a new matrix as a left-handed perspective projection matrix
  3477. */
  3478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3479. /**
  3480. * Stores a left-handed perspective projection into a given matrix
  3481. * @param fov defines the horizontal field of view
  3482. * @param aspect defines the aspect ratio
  3483. * @param znear defines the near clip plane
  3484. * @param zfar defines the far clip plane
  3485. * @param result defines the target matrix
  3486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3487. */
  3488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3489. /**
  3490. * Creates a right-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a right-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a right-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Stores a perspective projection for WebVR info a given matrix
  3510. * @param fov defines the field of view
  3511. * @param znear defines the near clip plane
  3512. * @param zfar defines the far clip plane
  3513. * @param result defines the target matrix
  3514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3515. */
  3516. static PerspectiveFovWebVRToRef(fov: {
  3517. upDegrees: number;
  3518. downDegrees: number;
  3519. leftDegrees: number;
  3520. rightDegrees: number;
  3521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3522. /**
  3523. * Computes a complete transformation matrix
  3524. * @param viewport defines the viewport to use
  3525. * @param world defines the world matrix
  3526. * @param view defines the view matrix
  3527. * @param projection defines the projection matrix
  3528. * @param zmin defines the near clip plane
  3529. * @param zmax defines the far clip plane
  3530. * @returns the transformation matrix
  3531. */
  3532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3533. /**
  3534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3535. * @param matrix defines the matrix to use
  3536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3537. */
  3538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3539. /**
  3540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3541. * @param matrix defines the matrix to use
  3542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3543. */
  3544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3545. /**
  3546. * Compute the transpose of a given matrix
  3547. * @param matrix defines the matrix to transpose
  3548. * @returns the new matrix
  3549. */
  3550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3551. /**
  3552. * Compute the transpose of a matrix and store it in a target matrix
  3553. * @param matrix defines the matrix to transpose
  3554. * @param result defines the target matrix
  3555. */
  3556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3557. /**
  3558. * Computes a reflection matrix from a plane
  3559. * @param plane defines the reflection plane
  3560. * @returns a new matrix
  3561. */
  3562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3563. /**
  3564. * Computes a reflection matrix from a plane
  3565. * @param plane defines the reflection plane
  3566. * @param result defines the target matrix
  3567. */
  3568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3569. /**
  3570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3571. * @param xaxis defines the value of the 1st axis
  3572. * @param yaxis defines the value of the 2nd axis
  3573. * @param zaxis defines the value of the 3rd axis
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3577. /**
  3578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3579. * @param quat defines the quaternion to use
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3583. }
  3584. /**
  3585. * Represens a plane by the equation ax + by + cz + d = 0
  3586. */
  3587. export class Plane {
  3588. /**
  3589. * Normal of the plane (a,b,c)
  3590. */
  3591. normal: Vector3;
  3592. /**
  3593. * d component of the plane
  3594. */
  3595. d: number;
  3596. /**
  3597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3598. * @param a a component of the plane
  3599. * @param b b component of the plane
  3600. * @param c c component of the plane
  3601. * @param d d component of the plane
  3602. */
  3603. constructor(a: number, b: number, c: number, d: number);
  3604. /**
  3605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3606. */
  3607. asArray(): number[];
  3608. /**
  3609. * @returns a new plane copied from the current Plane.
  3610. */
  3611. clone(): Plane;
  3612. /**
  3613. * @returns the string "Plane".
  3614. */
  3615. getClassName(): string;
  3616. /**
  3617. * @returns the Plane hash code.
  3618. */
  3619. getHashCode(): number;
  3620. /**
  3621. * Normalize the current Plane in place.
  3622. * @returns the updated Plane.
  3623. */
  3624. normalize(): Plane;
  3625. /**
  3626. * Applies a transformation the plane and returns the result
  3627. * @param transformation the transformation matrix to be applied to the plane
  3628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3629. */
  3630. transform(transformation: DeepImmutable<Matrix>): Plane;
  3631. /**
  3632. * Calcualtte the dot product between the point and the plane normal
  3633. * @param point point to calculate the dot product with
  3634. * @returns the dot product (float) of the point coordinates and the plane normal.
  3635. */
  3636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3637. /**
  3638. * Updates the current Plane from the plane defined by the three given points.
  3639. * @param point1 one of the points used to contruct the plane
  3640. * @param point2 one of the points used to contruct the plane
  3641. * @param point3 one of the points used to contruct the plane
  3642. * @returns the updated Plane.
  3643. */
  3644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3645. /**
  3646. * Checks if the plane is facing a given direction
  3647. * @param direction the direction to check if the plane is facing
  3648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3649. * @returns True is the vector "direction" is the same side than the plane normal.
  3650. */
  3651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3652. /**
  3653. * Calculates the distance to a point
  3654. * @param point point to calculate distance to
  3655. * @returns the signed distance (float) from the given point to the Plane.
  3656. */
  3657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Creates a plane from an array
  3660. * @param array the array to create a plane from
  3661. * @returns a new Plane from the given array.
  3662. */
  3663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3664. /**
  3665. * Creates a plane from three points
  3666. * @param point1 point used to create the plane
  3667. * @param point2 point used to create the plane
  3668. * @param point3 point used to create the plane
  3669. * @returns a new Plane defined by the three given points.
  3670. */
  3671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3672. /**
  3673. * Creates a plane from an origin point and a normal
  3674. * @param origin origin of the plane to be constructed
  3675. * @param normal normal of the plane to be constructed
  3676. * @returns a new Plane the normal vector to this plane at the given origin point.
  3677. * Note : the vector "normal" is updated because normalized.
  3678. */
  3679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3680. /**
  3681. * Calculates the distance from a plane and a point
  3682. * @param origin origin of the plane to be constructed
  3683. * @param normal normal of the plane to be constructed
  3684. * @param point point to calculate distance to
  3685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3686. */
  3687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3688. }
  3689. /**
  3690. * Class used to represent a viewport on screen
  3691. */
  3692. export class Viewport {
  3693. /** viewport left coordinate */
  3694. x: number;
  3695. /** viewport top coordinate */
  3696. y: number;
  3697. /**viewport width */
  3698. width: number;
  3699. /** viewport height */
  3700. height: number;
  3701. /**
  3702. * Creates a Viewport object located at (x, y) and sized (width, height)
  3703. * @param x defines viewport left coordinate
  3704. * @param y defines viewport top coordinate
  3705. * @param width defines the viewport width
  3706. * @param height defines the viewport height
  3707. */
  3708. constructor(
  3709. /** viewport left coordinate */
  3710. x: number,
  3711. /** viewport top coordinate */
  3712. y: number,
  3713. /**viewport width */
  3714. width: number,
  3715. /** viewport height */
  3716. height: number);
  3717. /**
  3718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3719. * @param renderWidth defines the rendering width
  3720. * @param renderHeight defines the rendering height
  3721. * @returns a new Viewport
  3722. */
  3723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3724. /**
  3725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3726. * @param renderWidth defines the rendering width
  3727. * @param renderHeight defines the rendering height
  3728. * @param ref defines the target viewport
  3729. * @returns the current viewport
  3730. */
  3731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3732. /**
  3733. * Returns a new Viewport copied from the current one
  3734. * @returns a new Viewport
  3735. */
  3736. clone(): Viewport;
  3737. }
  3738. /**
  3739. * Reprasents a camera frustum
  3740. */
  3741. export class Frustum {
  3742. /**
  3743. * Gets the planes representing the frustum
  3744. * @param transform matrix to be applied to the returned planes
  3745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3746. */
  3747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3748. /**
  3749. * Gets the near frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the far frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the left frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Gets the right frustum plane transformed by the transform matrix
  3768. * @param transform transformation matrix to be applied to the resulting frustum plane
  3769. * @param frustumPlane the resuling frustum plane
  3770. */
  3771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3772. /**
  3773. * Gets the top frustum plane transformed by the transform matrix
  3774. * @param transform transformation matrix to be applied to the resulting frustum plane
  3775. * @param frustumPlane the resuling frustum plane
  3776. */
  3777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3778. /**
  3779. * Gets the bottom frustum plane transformed by the transform matrix
  3780. * @param transform transformation matrix to be applied to the resulting frustum plane
  3781. * @param frustumPlane the resuling frustum plane
  3782. */
  3783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3784. /**
  3785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3786. * @param transform transformation matrix to be applied to the resulting frustum planes
  3787. * @param frustumPlanes the resuling frustum planes
  3788. */
  3789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3790. }
  3791. /** Defines supported spaces */
  3792. export enum Space {
  3793. /** Local (object) space */
  3794. LOCAL = 0,
  3795. /** World space */
  3796. WORLD = 1,
  3797. /** Bone space */
  3798. BONE = 2
  3799. }
  3800. /** Defines the 3 main axes */
  3801. export class Axis {
  3802. /** X axis */
  3803. static X: Vector3;
  3804. /** Y axis */
  3805. static Y: Vector3;
  3806. /** Z axis */
  3807. static Z: Vector3;
  3808. }
  3809. /** Class used to represent a Bezier curve */
  3810. export class BezierCurve {
  3811. /**
  3812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3813. * @param t defines the time
  3814. * @param x1 defines the left coordinate on X axis
  3815. * @param y1 defines the left coordinate on Y axis
  3816. * @param x2 defines the right coordinate on X axis
  3817. * @param y2 defines the right coordinate on Y axis
  3818. * @returns the interpolated value
  3819. */
  3820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3821. }
  3822. /**
  3823. * Defines potential orientation for back face culling
  3824. */
  3825. export enum Orientation {
  3826. /**
  3827. * Clockwise
  3828. */
  3829. CW = 0,
  3830. /** Counter clockwise */
  3831. CCW = 1
  3832. }
  3833. /**
  3834. * Defines angle representation
  3835. */
  3836. export class Angle {
  3837. private _radians;
  3838. /**
  3839. * Creates an Angle object of "radians" radians (float).
  3840. * @param radians the angle in radians
  3841. */
  3842. constructor(radians: number);
  3843. /**
  3844. * Get value in degrees
  3845. * @returns the Angle value in degrees (float)
  3846. */
  3847. degrees(): number;
  3848. /**
  3849. * Get value in radians
  3850. * @returns the Angle value in radians (float)
  3851. */
  3852. radians(): number;
  3853. /**
  3854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3855. * @param a defines first vector
  3856. * @param b defines second vector
  3857. * @returns a new Angle
  3858. */
  3859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3860. /**
  3861. * Gets a new Angle object from the given float in radians
  3862. * @param radians defines the angle value in radians
  3863. * @returns a new Angle
  3864. */
  3865. static FromRadians(radians: number): Angle;
  3866. /**
  3867. * Gets a new Angle object from the given float in degrees
  3868. * @param degrees defines the angle value in degrees
  3869. * @returns a new Angle
  3870. */
  3871. static FromDegrees(degrees: number): Angle;
  3872. }
  3873. /**
  3874. * This represents an arc in a 2d space.
  3875. */
  3876. export class Arc2 {
  3877. /** Defines the start point of the arc */
  3878. startPoint: Vector2;
  3879. /** Defines the mid point of the arc */
  3880. midPoint: Vector2;
  3881. /** Defines the end point of the arc */
  3882. endPoint: Vector2;
  3883. /**
  3884. * Defines the center point of the arc.
  3885. */
  3886. centerPoint: Vector2;
  3887. /**
  3888. * Defines the radius of the arc.
  3889. */
  3890. radius: number;
  3891. /**
  3892. * Defines the angle of the arc (from mid point to end point).
  3893. */
  3894. angle: Angle;
  3895. /**
  3896. * Defines the start angle of the arc (from start point to middle point).
  3897. */
  3898. startAngle: Angle;
  3899. /**
  3900. * Defines the orientation of the arc (clock wise/counter clock wise).
  3901. */
  3902. orientation: Orientation;
  3903. /**
  3904. * Creates an Arc object from the three given points : start, middle and end.
  3905. * @param startPoint Defines the start point of the arc
  3906. * @param midPoint Defines the midlle point of the arc
  3907. * @param endPoint Defines the end point of the arc
  3908. */
  3909. constructor(
  3910. /** Defines the start point of the arc */
  3911. startPoint: Vector2,
  3912. /** Defines the mid point of the arc */
  3913. midPoint: Vector2,
  3914. /** Defines the end point of the arc */
  3915. endPoint: Vector2);
  3916. }
  3917. /**
  3918. * Represents a 2D path made up of multiple 2D points
  3919. */
  3920. export class Path2 {
  3921. private _points;
  3922. private _length;
  3923. /**
  3924. * If the path start and end point are the same
  3925. */
  3926. closed: boolean;
  3927. /**
  3928. * Creates a Path2 object from the starting 2D coordinates x and y.
  3929. * @param x the starting points x value
  3930. * @param y the starting points y value
  3931. */
  3932. constructor(x: number, y: number);
  3933. /**
  3934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3935. * @param x the added points x value
  3936. * @param y the added points y value
  3937. * @returns the updated Path2.
  3938. */
  3939. addLineTo(x: number, y: number): Path2;
  3940. /**
  3941. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3942. * @param midX middle point x value
  3943. * @param midY middle point y value
  3944. * @param endX end point x value
  3945. * @param endY end point y value
  3946. * @param numberOfSegments (default: 36)
  3947. * @returns the updated Path2.
  3948. */
  3949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3950. /**
  3951. * Closes the Path2.
  3952. * @returns the Path2.
  3953. */
  3954. close(): Path2;
  3955. /**
  3956. * Gets the sum of the distance between each sequential point in the path
  3957. * @returns the Path2 total length (float).
  3958. */
  3959. length(): number;
  3960. /**
  3961. * Gets the points which construct the path
  3962. * @returns the Path2 internal array of points.
  3963. */
  3964. getPoints(): Vector2[];
  3965. /**
  3966. * Retreives the point at the distance aways from the starting point
  3967. * @param normalizedLengthPosition the length along the path to retreive the point from
  3968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3969. */
  3970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3971. /**
  3972. * Creates a new path starting from an x and y position
  3973. * @param x starting x value
  3974. * @param y starting y value
  3975. * @returns a new Path2 starting at the coordinates (x, y).
  3976. */
  3977. static StartingAt(x: number, y: number): Path2;
  3978. }
  3979. /**
  3980. * Represents a 3D path made up of multiple 3D points
  3981. */
  3982. export class Path3D {
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[];
  3987. private _curve;
  3988. private _distances;
  3989. private _tangents;
  3990. private _normals;
  3991. private _binormals;
  3992. private _raw;
  3993. /**
  3994. * new Path3D(path, normal, raw)
  3995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3997. * @param path an array of Vector3, the curve axis of the Path3D
  3998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4000. */
  4001. constructor(
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4006. /**
  4007. * Returns the Path3D array of successive Vector3 designing its curve.
  4008. * @returns the Path3D array of successive Vector3 designing its curve.
  4009. */
  4010. getCurve(): Vector3[];
  4011. /**
  4012. * Returns an array populated with tangent vectors on each Path3D curve point.
  4013. * @returns an array populated with tangent vectors on each Path3D curve point.
  4014. */
  4015. getTangents(): Vector3[];
  4016. /**
  4017. * Returns an array populated with normal vectors on each Path3D curve point.
  4018. * @returns an array populated with normal vectors on each Path3D curve point.
  4019. */
  4020. getNormals(): Vector3[];
  4021. /**
  4022. * Returns an array populated with binormal vectors on each Path3D curve point.
  4023. * @returns an array populated with binormal vectors on each Path3D curve point.
  4024. */
  4025. getBinormals(): Vector3[];
  4026. /**
  4027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4029. */
  4030. getDistances(): number[];
  4031. /**
  4032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4033. * @param path path which all values are copied into the curves points
  4034. * @param firstNormal which should be projected onto the curve
  4035. * @returns the same object updated.
  4036. */
  4037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4038. private _compute;
  4039. private _getFirstNonNullVector;
  4040. private _getLastNonNullVector;
  4041. private _normalVector;
  4042. }
  4043. /**
  4044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4045. * A Curve3 is designed from a series of successive Vector3.
  4046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4047. */
  4048. export class Curve3 {
  4049. private _points;
  4050. private _length;
  4051. /**
  4052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4054. * @param v1 (Vector3) the control point
  4055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4063. * @param v1 (Vector3) the first control point
  4064. * @param v2 (Vector3) the second control point
  4065. * @param v3 (Vector3) the end point of the Cubic Bezier
  4066. * @param nbPoints (integer) the wanted number of points in the curve
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4070. /**
  4071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4072. * @param p1 (Vector3) the origin point of the Hermite Spline
  4073. * @param t1 (Vector3) the tangent vector at the origin point
  4074. * @param p2 (Vector3) the end point of the Hermite Spline
  4075. * @param t2 (Vector3) the tangent vector at the end point
  4076. * @param nbPoints (integer) the wanted number of points in the curve
  4077. * @returns the created Curve3
  4078. */
  4079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4080. /**
  4081. * Returns a Curve3 object along a CatmullRom Spline curve :
  4082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4083. * @param nbPoints (integer) the wanted number of points between each curve control points
  4084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4085. * @returns the created Curve3
  4086. */
  4087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4088. /**
  4089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4090. * A Curve3 is designed from a series of successive Vector3.
  4091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4092. * @param points points which make up the curve
  4093. */
  4094. constructor(points: Vector3[]);
  4095. /**
  4096. * @returns the Curve3 stored array of successive Vector3
  4097. */
  4098. getPoints(): Vector3[];
  4099. /**
  4100. * @returns the computed length (float) of the curve.
  4101. */
  4102. length(): number;
  4103. /**
  4104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4106. * curveA and curveB keep unchanged.
  4107. * @param curve the curve to continue from this curve
  4108. * @returns the newly constructed curve
  4109. */
  4110. continue(curve: DeepImmutable<Curve3>): Curve3;
  4111. private _computeLength;
  4112. }
  4113. /**
  4114. * Contains position and normal vectors for a vertex
  4115. */
  4116. export class PositionNormalVertex {
  4117. /** the position of the vertex (defaut: 0,0,0) */
  4118. position: Vector3;
  4119. /** the normal of the vertex (defaut: 0,1,0) */
  4120. normal: Vector3;
  4121. /**
  4122. * Creates a PositionNormalVertex
  4123. * @param position the position of the vertex (defaut: 0,0,0)
  4124. * @param normal the normal of the vertex (defaut: 0,1,0)
  4125. */
  4126. constructor(
  4127. /** the position of the vertex (defaut: 0,0,0) */
  4128. position?: Vector3,
  4129. /** the normal of the vertex (defaut: 0,1,0) */
  4130. normal?: Vector3);
  4131. /**
  4132. * Clones the PositionNormalVertex
  4133. * @returns the cloned PositionNormalVertex
  4134. */
  4135. clone(): PositionNormalVertex;
  4136. }
  4137. /**
  4138. * Contains position, normal and uv vectors for a vertex
  4139. */
  4140. export class PositionNormalTextureVertex {
  4141. /** the position of the vertex (defaut: 0,0,0) */
  4142. position: Vector3;
  4143. /** the normal of the vertex (defaut: 0,1,0) */
  4144. normal: Vector3;
  4145. /** the uv of the vertex (default: 0,0) */
  4146. uv: Vector2;
  4147. /**
  4148. * Creates a PositionNormalTextureVertex
  4149. * @param position the position of the vertex (defaut: 0,0,0)
  4150. * @param normal the normal of the vertex (defaut: 0,1,0)
  4151. * @param uv the uv of the vertex (default: 0,0)
  4152. */
  4153. constructor(
  4154. /** the position of the vertex (defaut: 0,0,0) */
  4155. position?: Vector3,
  4156. /** the normal of the vertex (defaut: 0,1,0) */
  4157. normal?: Vector3,
  4158. /** the uv of the vertex (default: 0,0) */
  4159. uv?: Vector2);
  4160. /**
  4161. * Clones the PositionNormalTextureVertex
  4162. * @returns the cloned PositionNormalTextureVertex
  4163. */
  4164. clone(): PositionNormalTextureVertex;
  4165. }
  4166. /**
  4167. * @hidden
  4168. */
  4169. export class Tmp {
  4170. static Color3: Color3[];
  4171. static Color4: Color4[];
  4172. static Vector2: Vector2[];
  4173. static Vector3: Vector3[];
  4174. static Vector4: Vector4[];
  4175. static Quaternion: Quaternion[];
  4176. static Matrix: Matrix[];
  4177. }
  4178. }
  4179. declare module "babylonjs/Offline/IOfflineProvider" {
  4180. /**
  4181. * Class used to enable access to offline support
  4182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4183. */
  4184. export interface IOfflineProvider {
  4185. /**
  4186. * Gets a boolean indicating if scene must be saved in the database
  4187. */
  4188. enableSceneOffline: boolean;
  4189. /**
  4190. * Gets a boolean indicating if textures must be saved in the database
  4191. */
  4192. enableTexturesOffline: boolean;
  4193. /**
  4194. * Open the offline support and make it available
  4195. * @param successCallback defines the callback to call on success
  4196. * @param errorCallback defines the callback to call on error
  4197. */
  4198. open(successCallback: () => void, errorCallback: () => void): void;
  4199. /**
  4200. * Loads an image from the offline support
  4201. * @param url defines the url to load from
  4202. * @param image defines the target DOM image
  4203. */
  4204. loadImage(url: string, image: HTMLImageElement): void;
  4205. /**
  4206. * Loads a file from offline support
  4207. * @param url defines the URL to load from
  4208. * @param sceneLoaded defines a callback to call on success
  4209. * @param progressCallBack defines a callback to call when progress changed
  4210. * @param errorCallback defines a callback to call on error
  4211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4212. */
  4213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4214. }
  4215. }
  4216. declare module "babylonjs/Misc/observable" {
  4217. import { Nullable } from "babylonjs/types";
  4218. /**
  4219. * A class serves as a medium between the observable and its observers
  4220. */
  4221. export class EventState {
  4222. /**
  4223. * Create a new EventState
  4224. * @param mask defines the mask associated with this state
  4225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4226. * @param target defines the original target of the state
  4227. * @param currentTarget defines the current target of the state
  4228. */
  4229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4230. /**
  4231. * Initialize the current event state
  4232. * @param mask defines the mask associated with this state
  4233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4234. * @param target defines the original target of the state
  4235. * @param currentTarget defines the current target of the state
  4236. * @returns the current event state
  4237. */
  4238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4239. /**
  4240. * An Observer can set this property to true to prevent subsequent observers of being notified
  4241. */
  4242. skipNextObservers: boolean;
  4243. /**
  4244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4245. */
  4246. mask: number;
  4247. /**
  4248. * The object that originally notified the event
  4249. */
  4250. target?: any;
  4251. /**
  4252. * The current object in the bubbling phase
  4253. */
  4254. currentTarget?: any;
  4255. /**
  4256. * This will be populated with the return value of the last function that was executed.
  4257. * If it is the first function in the callback chain it will be the event data.
  4258. */
  4259. lastReturnValue?: any;
  4260. }
  4261. /**
  4262. * Represent an Observer registered to a given Observable object.
  4263. */
  4264. export class Observer<T> {
  4265. /**
  4266. * Defines the callback to call when the observer is notified
  4267. */
  4268. callback: (eventData: T, eventState: EventState) => void;
  4269. /**
  4270. * Defines the mask of the observer (used to filter notifications)
  4271. */
  4272. mask: number;
  4273. /**
  4274. * Defines the current scope used to restore the JS context
  4275. */
  4276. scope: any;
  4277. /** @hidden */
  4278. _willBeUnregistered: boolean;
  4279. /**
  4280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4281. */
  4282. unregisterOnNextCall: boolean;
  4283. /**
  4284. * Creates a new observer
  4285. * @param callback defines the callback to call when the observer is notified
  4286. * @param mask defines the mask of the observer (used to filter notifications)
  4287. * @param scope defines the current scope used to restore the JS context
  4288. */
  4289. constructor(
  4290. /**
  4291. * Defines the callback to call when the observer is notified
  4292. */
  4293. callback: (eventData: T, eventState: EventState) => void,
  4294. /**
  4295. * Defines the mask of the observer (used to filter notifications)
  4296. */
  4297. mask: number,
  4298. /**
  4299. * Defines the current scope used to restore the JS context
  4300. */
  4301. scope?: any);
  4302. }
  4303. /**
  4304. * Represent a list of observers registered to multiple Observables object.
  4305. */
  4306. export class MultiObserver<T> {
  4307. private _observers;
  4308. private _observables;
  4309. /**
  4310. * Release associated resources
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Raise a callback when one of the observable will notify
  4315. * @param observables defines a list of observables to watch
  4316. * @param callback defines the callback to call on notification
  4317. * @param mask defines the mask used to filter notifications
  4318. * @param scope defines the current scope used to restore the JS context
  4319. * @returns the new MultiObserver
  4320. */
  4321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4322. }
  4323. /**
  4324. * The Observable class is a simple implementation of the Observable pattern.
  4325. *
  4326. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4328. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4329. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4330. */
  4331. export class Observable<T> {
  4332. private _observers;
  4333. private _eventState;
  4334. private _onObserverAdded;
  4335. /**
  4336. * Creates a new observable
  4337. * @param onObserverAdded defines a callback to call when a new observer is added
  4338. */
  4339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4340. /**
  4341. * Create a new Observer with the specified callback
  4342. * @param callback the callback that will be executed for that Observer
  4343. * @param mask the mask used to filter observers
  4344. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4345. * @param scope optional scope for the callback to be called from
  4346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4347. * @returns the new observer created for the callback
  4348. */
  4349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4350. /**
  4351. * Create a new Observer with the specified callback and unregisters after the next notification
  4352. * @param callback the callback that will be executed for that Observer
  4353. * @returns the new observer created for the callback
  4354. */
  4355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4356. /**
  4357. * Remove an Observer from the Observable object
  4358. * @param observer the instance of the Observer to remove
  4359. * @returns false if it doesn't belong to this Observable
  4360. */
  4361. remove(observer: Nullable<Observer<T>>): boolean;
  4362. /**
  4363. * Remove a callback from the Observable object
  4364. * @param callback the callback to remove
  4365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4366. * @returns false if it doesn't belong to this Observable
  4367. */
  4368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4369. private _deferUnregister;
  4370. private _remove;
  4371. /**
  4372. * Moves the observable to the top of the observer list making it get called first when notified
  4373. * @param observer the observer to move
  4374. */
  4375. makeObserverTopPriority(observer: Observer<T>): void;
  4376. /**
  4377. * Moves the observable to the bottom of the observer list making it get called last when notified
  4378. * @param observer the observer to move
  4379. */
  4380. makeObserverBottomPriority(observer: Observer<T>): void;
  4381. /**
  4382. * Notify all Observers by calling their respective callback with the given data
  4383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4384. * @param eventData defines the data to send to all observers
  4385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4386. * @param target defines the original target of the state
  4387. * @param currentTarget defines the current target of the state
  4388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4389. */
  4390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4391. /**
  4392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4395. * and it is crucial that all callbacks will be executed.
  4396. * The order of the callbacks is kept, callbacks are not executed parallel.
  4397. *
  4398. * @param eventData The data to be sent to each callback
  4399. * @param mask is used to filter observers defaults to -1
  4400. * @param target defines the callback target (see EventState)
  4401. * @param currentTarget defines he current object in the bubbling phase
  4402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4403. */
  4404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4405. /**
  4406. * Notify a specific observer
  4407. * @param observer defines the observer to notify
  4408. * @param eventData defines the data to be sent to each callback
  4409. * @param mask is used to filter observers defaults to -1
  4410. */
  4411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4412. /**
  4413. * Gets a boolean indicating if the observable has at least one observer
  4414. * @returns true is the Observable has at least one Observer registered
  4415. */
  4416. hasObservers(): boolean;
  4417. /**
  4418. * Clear the list of observers
  4419. */
  4420. clear(): void;
  4421. /**
  4422. * Clone the current observable
  4423. * @returns a new observable
  4424. */
  4425. clone(): Observable<T>;
  4426. /**
  4427. * Does this observable handles observer registered with a given mask
  4428. * @param mask defines the mask to be tested
  4429. * @return whether or not one observer registered with the given mask is handeled
  4430. **/
  4431. hasSpecificMask(mask?: number): boolean;
  4432. }
  4433. }
  4434. declare module "babylonjs/Misc/filesInputStore" {
  4435. /**
  4436. * Class used to help managing file picking and drag'n'drop
  4437. * File Storage
  4438. */
  4439. export class FilesInputStore {
  4440. /**
  4441. * List of files ready to be loaded
  4442. */
  4443. static FilesToLoad: {
  4444. [key: string]: File;
  4445. };
  4446. }
  4447. }
  4448. declare module "babylonjs/Engines/constants" {
  4449. /** Defines the cross module used constants to avoid circular dependncies */
  4450. export class Constants {
  4451. /** Defines that alpha blending is disabled */
  4452. static readonly ALPHA_DISABLE: number;
  4453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4454. static readonly ALPHA_ADD: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4456. static readonly ALPHA_COMBINE: number;
  4457. /** Defines that alpha blending to DEST - SRC * DEST */
  4458. static readonly ALPHA_SUBTRACT: number;
  4459. /** Defines that alpha blending to SRC * DEST */
  4460. static readonly ALPHA_MULTIPLY: number;
  4461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4462. static readonly ALPHA_MAXIMIZED: number;
  4463. /** Defines that alpha blending to SRC + DEST */
  4464. static readonly ALPHA_ONEONE: number;
  4465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4466. static readonly ALPHA_PREMULTIPLIED: number;
  4467. /**
  4468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4470. */
  4471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4473. static readonly ALPHA_INTERPOLATE: number;
  4474. /**
  4475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4477. */
  4478. static readonly ALPHA_SCREENMODE: number;
  4479. /** Defines that the ressource is not delayed*/
  4480. static readonly DELAYLOADSTATE_NONE: number;
  4481. /** Defines that the ressource was successfully delay loaded */
  4482. static readonly DELAYLOADSTATE_LOADED: number;
  4483. /** Defines that the ressource is currently delay loading */
  4484. static readonly DELAYLOADSTATE_LOADING: number;
  4485. /** Defines that the ressource is delayed and has not started loading */
  4486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4488. static readonly NEVER: number;
  4489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4490. static readonly ALWAYS: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4492. static readonly LESS: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4494. static readonly EQUAL: number;
  4495. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4496. static readonly LEQUAL: number;
  4497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4498. static readonly GREATER: number;
  4499. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4500. static readonly GEQUAL: number;
  4501. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4502. static readonly NOTEQUAL: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be kept */
  4504. static readonly KEEP: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4506. static readonly REPLACE: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4508. static readonly INCR: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4510. static readonly DECR: number;
  4511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4512. static readonly INVERT: number;
  4513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4514. static readonly INCR_WRAP: number;
  4515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4516. static readonly DECR_WRAP: number;
  4517. /** Texture is not repeating outside of 0..1 UVs */
  4518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4519. /** Texture is repeating outside of 0..1 UVs */
  4520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4521. /** Texture is repeating and mirrored */
  4522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4523. /** ALPHA */
  4524. static readonly TEXTUREFORMAT_ALPHA: number;
  4525. /** LUMINANCE */
  4526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4527. /** LUMINANCE_ALPHA */
  4528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4529. /** RGB */
  4530. static readonly TEXTUREFORMAT_RGB: number;
  4531. /** RGBA */
  4532. static readonly TEXTUREFORMAT_RGBA: number;
  4533. /** RED */
  4534. static readonly TEXTUREFORMAT_RED: number;
  4535. /** RED (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R: number;
  4537. /** RG */
  4538. static readonly TEXTUREFORMAT_RG: number;
  4539. /** RED_INTEGER */
  4540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4541. /** RED_INTEGER (2nd reference) */
  4542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4543. /** RG_INTEGER */
  4544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4545. /** RGB_INTEGER */
  4546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4547. /** RGBA_INTEGER */
  4548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4549. /** UNSIGNED_BYTE */
  4550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4551. /** UNSIGNED_BYTE (2nd reference) */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4553. /** FLOAT */
  4554. static readonly TEXTURETYPE_FLOAT: number;
  4555. /** HALF_FLOAT */
  4556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4557. /** BYTE */
  4558. static readonly TEXTURETYPE_BYTE: number;
  4559. /** SHORT */
  4560. static readonly TEXTURETYPE_SHORT: number;
  4561. /** UNSIGNED_SHORT */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4563. /** INT */
  4564. static readonly TEXTURETYPE_INT: number;
  4565. /** UNSIGNED_INT */
  4566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4567. /** UNSIGNED_SHORT_4_4_4_4 */
  4568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4569. /** UNSIGNED_SHORT_5_5_5_1 */
  4570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4571. /** UNSIGNED_SHORT_5_6_5 */
  4572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4573. /** UNSIGNED_INT_2_10_10_10_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4575. /** UNSIGNED_INT_24_8 */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4577. /** UNSIGNED_INT_10F_11F_11F_REV */
  4578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4579. /** UNSIGNED_INT_5_9_9_9_REV */
  4580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4589. /** nearest is mag = nearest and min = nearest and mip = linear */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4593. /** Trilinear is mag = linear and min = linear and mip = linear */
  4594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = nearest and mip = nearest */
  4596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4597. /** mag = nearest and min = linear and mip = nearest */
  4598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4599. /** mag = nearest and min = linear and mip = linear */
  4600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4601. /** mag = nearest and min = linear and mip = none */
  4602. static readonly TEXTURE_NEAREST_LINEAR: number;
  4603. /** mag = nearest and min = nearest and mip = none */
  4604. static readonly TEXTURE_NEAREST_NEAREST: number;
  4605. /** mag = linear and min = nearest and mip = nearest */
  4606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4607. /** mag = linear and min = nearest and mip = linear */
  4608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4609. /** mag = linear and min = linear and mip = none */
  4610. static readonly TEXTURE_LINEAR_LINEAR: number;
  4611. /** mag = linear and min = nearest and mip = none */
  4612. static readonly TEXTURE_LINEAR_NEAREST: number;
  4613. /** Explicit coordinates mode */
  4614. static readonly TEXTURE_EXPLICIT_MODE: number;
  4615. /** Spherical coordinates mode */
  4616. static readonly TEXTURE_SPHERICAL_MODE: number;
  4617. /** Planar coordinates mode */
  4618. static readonly TEXTURE_PLANAR_MODE: number;
  4619. /** Cubic coordinates mode */
  4620. static readonly TEXTURE_CUBIC_MODE: number;
  4621. /** Projection coordinates mode */
  4622. static readonly TEXTURE_PROJECTION_MODE: number;
  4623. /** Skybox coordinates mode */
  4624. static readonly TEXTURE_SKYBOX_MODE: number;
  4625. /** Inverse Cubic coordinates mode */
  4626. static readonly TEXTURE_INVCUBIC_MODE: number;
  4627. /** Equirectangular coordinates mode */
  4628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4629. /** Equirectangular Fixed coordinates mode */
  4630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4631. /** Equirectangular Fixed Mirrored coordinates mode */
  4632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4634. static readonly SCALEMODE_FLOOR: number;
  4635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4636. static readonly SCALEMODE_NEAREST: number;
  4637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4638. static readonly SCALEMODE_CEILING: number;
  4639. /**
  4640. * The dirty texture flag value
  4641. */
  4642. static readonly MATERIAL_TextureDirtyFlag: number;
  4643. /**
  4644. * The dirty light flag value
  4645. */
  4646. static readonly MATERIAL_LightDirtyFlag: number;
  4647. /**
  4648. * The dirty fresnel flag value
  4649. */
  4650. static readonly MATERIAL_FresnelDirtyFlag: number;
  4651. /**
  4652. * The dirty attribute flag value
  4653. */
  4654. static readonly MATERIAL_AttributesDirtyFlag: number;
  4655. /**
  4656. * The dirty misc flag value
  4657. */
  4658. static readonly MATERIAL_MiscDirtyFlag: number;
  4659. /**
  4660. * The all dirty flag value
  4661. */
  4662. static readonly MATERIAL_AllDirtyFlag: number;
  4663. /**
  4664. * Returns the triangle fill mode
  4665. */
  4666. static readonly MATERIAL_TriangleFillMode: number;
  4667. /**
  4668. * Returns the wireframe mode
  4669. */
  4670. static readonly MATERIAL_WireFrameFillMode: number;
  4671. /**
  4672. * Returns the point fill mode
  4673. */
  4674. static readonly MATERIAL_PointFillMode: number;
  4675. /**
  4676. * Returns the point list draw mode
  4677. */
  4678. static readonly MATERIAL_PointListDrawMode: number;
  4679. /**
  4680. * Returns the line list draw mode
  4681. */
  4682. static readonly MATERIAL_LineListDrawMode: number;
  4683. /**
  4684. * Returns the line loop draw mode
  4685. */
  4686. static readonly MATERIAL_LineLoopDrawMode: number;
  4687. /**
  4688. * Returns the line strip draw mode
  4689. */
  4690. static readonly MATERIAL_LineStripDrawMode: number;
  4691. /**
  4692. * Returns the triangle strip draw mode
  4693. */
  4694. static readonly MATERIAL_TriangleStripDrawMode: number;
  4695. /**
  4696. * Returns the triangle fan draw mode
  4697. */
  4698. static readonly MATERIAL_TriangleFanDrawMode: number;
  4699. /**
  4700. * Stores the clock-wise side orientation
  4701. */
  4702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4703. /**
  4704. * Stores the counter clock-wise side orientation
  4705. */
  4706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4707. /**
  4708. * Nothing
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_NothingTrigger: number;
  4712. /**
  4713. * On pick
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickTrigger: number;
  4717. /**
  4718. * On left pick
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnLeftPickTrigger: number;
  4722. /**
  4723. * On right pick
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_OnRightPickTrigger: number;
  4727. /**
  4728. * On center pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnCenterPickTrigger: number;
  4732. /**
  4733. * On pick down
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickDownTrigger: number;
  4737. /**
  4738. * On double pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnDoublePickTrigger: number;
  4742. /**
  4743. * On pick up
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickUpTrigger: number;
  4747. /**
  4748. * On pick out.
  4749. * This trigger will only be raised if you also declared a OnPickDown
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnPickOutTrigger: number;
  4753. /**
  4754. * On long press
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnLongPressTrigger: number;
  4758. /**
  4759. * On pointer over
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnPointerOverTrigger: number;
  4763. /**
  4764. * On pointer out
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPointerOutTrigger: number;
  4768. /**
  4769. * On every frame
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnEveryFrameTrigger: number;
  4773. /**
  4774. * On intersection enter
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4778. /**
  4779. * On intersection exit
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnIntersectionExitTrigger: number;
  4783. /**
  4784. * On key down
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnKeyDownTrigger: number;
  4788. /**
  4789. * On key up
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnKeyUpTrigger: number;
  4793. /**
  4794. * Billboard mode will only apply to Y axis
  4795. */
  4796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4797. /**
  4798. * Billboard mode will apply to all axes
  4799. */
  4800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4801. /**
  4802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4803. */
  4804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4805. /**
  4806. * Gets or sets base Assets URL
  4807. */
  4808. static readonly PARTICLES_BaseAssetsUrl: string;
  4809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4810. * Test order :
  4811. * Is the bounding sphere outside the frustum ?
  4812. * If not, are the bounding box vertices outside the frustum ?
  4813. * It not, then the cullable object is in the frustum.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4816. /** Culling strategy : Bounding Sphere Only.
  4817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4818. * It's also less accurate than the standard because some not visible objects can still be selected.
  4819. * Test : is the bounding sphere outside the frustum ?
  4820. * If not, then the cullable object is in the frustum.
  4821. */
  4822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4823. /** Culling strategy : Optimistic Inclusion.
  4824. * This in an inclusion test first, then the standard exclusion test.
  4825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4826. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4827. * Anyway, it's as accurate as the standard strategy.
  4828. * Test :
  4829. * Is the cullable object bounding sphere center in the frustum ?
  4830. * If not, apply the default culling strategy.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4836. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4838. * Test :
  4839. * Is the cullable object bounding sphere center in the frustum ?
  4840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4843. /**
  4844. * No logging while loading
  4845. */
  4846. static readonly SCENELOADER_NO_LOGGING: number;
  4847. /**
  4848. * Minimal logging while loading
  4849. */
  4850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4851. /**
  4852. * Summary logging while loading
  4853. */
  4854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4855. /**
  4856. * Detailled logging while loading
  4857. */
  4858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4859. }
  4860. }
  4861. declare module "babylonjs/Misc/domManagement" {
  4862. /**
  4863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4864. * Babylon.js
  4865. */
  4866. export class DomManagement {
  4867. /**
  4868. * Checks if the window object exists
  4869. * @returns true if the window object exists
  4870. */
  4871. static IsWindowObjectExist(): boolean;
  4872. /**
  4873. * Extracts text content from a DOM element hierarchy
  4874. * @param element defines the root element
  4875. * @returns a string
  4876. */
  4877. static GetDOMTextContent(element: HTMLElement): string;
  4878. }
  4879. }
  4880. declare module "babylonjs/Misc/logger" {
  4881. /**
  4882. * Logger used througouht the application to allow configuration of
  4883. * the log level required for the messages.
  4884. */
  4885. export class Logger {
  4886. /**
  4887. * No log
  4888. */
  4889. static readonly NoneLogLevel: number;
  4890. /**
  4891. * Only message logs
  4892. */
  4893. static readonly MessageLogLevel: number;
  4894. /**
  4895. * Only warning logs
  4896. */
  4897. static readonly WarningLogLevel: number;
  4898. /**
  4899. * Only error logs
  4900. */
  4901. static readonly ErrorLogLevel: number;
  4902. /**
  4903. * All logs
  4904. */
  4905. static readonly AllLogLevel: number;
  4906. private static _LogCache;
  4907. /**
  4908. * Gets a value indicating the number of loading errors
  4909. * @ignorenaming
  4910. */
  4911. static errorsCount: number;
  4912. /**
  4913. * Callback called when a new log is added
  4914. */
  4915. static OnNewCacheEntry: (entry: string) => void;
  4916. private static _AddLogEntry;
  4917. private static _FormatMessage;
  4918. private static _LogDisabled;
  4919. private static _LogEnabled;
  4920. private static _WarnDisabled;
  4921. private static _WarnEnabled;
  4922. private static _ErrorDisabled;
  4923. private static _ErrorEnabled;
  4924. /**
  4925. * Log a message to the console
  4926. */
  4927. static Log: (message: string) => void;
  4928. /**
  4929. * Write a warning message to the console
  4930. */
  4931. static Warn: (message: string) => void;
  4932. /**
  4933. * Write an error message to the console
  4934. */
  4935. static Error: (message: string) => void;
  4936. /**
  4937. * Gets current log cache (list of logs)
  4938. */
  4939. static readonly LogCache: string;
  4940. /**
  4941. * Clears the log cache
  4942. */
  4943. static ClearLogCache(): void;
  4944. /**
  4945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4946. */
  4947. static LogLevels: number;
  4948. }
  4949. }
  4950. declare module "babylonjs/Misc/typeStore" {
  4951. /** @hidden */
  4952. export class _TypeStore {
  4953. /** @hidden */
  4954. static RegisteredTypes: {
  4955. [key: string]: Object;
  4956. };
  4957. /** @hidden */
  4958. static GetClass(fqdn: string): any;
  4959. }
  4960. }
  4961. declare module "babylonjs/Misc/deepCopier" {
  4962. /**
  4963. * Class containing a set of static utilities functions for deep copy.
  4964. */
  4965. export class DeepCopier {
  4966. /**
  4967. * Tries to copy an object by duplicating every property
  4968. * @param source defines the source object
  4969. * @param destination defines the target object
  4970. * @param doNotCopyList defines a list of properties to avoid
  4971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4972. */
  4973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/precisionDate" {
  4977. /**
  4978. * Class containing a set of static utilities functions for precision date
  4979. */
  4980. export class PrecisionDate {
  4981. /**
  4982. * Gets either window.performance.now() if supported or Date.now() else
  4983. */
  4984. static readonly Now: number;
  4985. }
  4986. }
  4987. declare module "babylonjs/Misc/devTools" {
  4988. /** @hidden */
  4989. export class _DevTools {
  4990. static WarnImport(name: string): string;
  4991. }
  4992. }
  4993. declare module "babylonjs/Misc/webRequest" {
  4994. /**
  4995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4996. */
  4997. export class WebRequest {
  4998. private _xhr;
  4999. /**
  5000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5001. * i.e. when loading files, where the server/service expects an Authorization header
  5002. */
  5003. static CustomRequestHeaders: {
  5004. [key: string]: string;
  5005. };
  5006. /**
  5007. * Add callback functions in this array to update all the requests before they get sent to the network
  5008. */
  5009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5010. private _injectCustomRequestHeaders;
  5011. /**
  5012. * Gets or sets a function to be called when loading progress changes
  5013. */
  5014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5015. /**
  5016. * Returns client's state
  5017. */
  5018. readonly readyState: number;
  5019. /**
  5020. * Returns client's status
  5021. */
  5022. readonly status: number;
  5023. /**
  5024. * Returns client's status as a text
  5025. */
  5026. readonly statusText: string;
  5027. /**
  5028. * Returns client's response
  5029. */
  5030. readonly response: any;
  5031. /**
  5032. * Returns client's response url
  5033. */
  5034. readonly responseURL: string;
  5035. /**
  5036. * Returns client's response as text
  5037. */
  5038. readonly responseText: string;
  5039. /**
  5040. * Gets or sets the expected response type
  5041. */
  5042. responseType: XMLHttpRequestResponseType;
  5043. /** @hidden */
  5044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5045. /** @hidden */
  5046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5047. /**
  5048. * Cancels any network activity
  5049. */
  5050. abort(): void;
  5051. /**
  5052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5053. * @param body defines an optional request body
  5054. */
  5055. send(body?: Document | BodyInit | null): void;
  5056. /**
  5057. * Sets the request method, request URL
  5058. * @param method defines the method to use (GET, POST, etc..)
  5059. * @param url defines the url to connect with
  5060. */
  5061. open(method: string, url: string): void;
  5062. }
  5063. }
  5064. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5065. /**
  5066. * Class used to evalaute queries containing `and` and `or` operators
  5067. */
  5068. export class AndOrNotEvaluator {
  5069. /**
  5070. * Evaluate a query
  5071. * @param query defines the query to evaluate
  5072. * @param evaluateCallback defines the callback used to filter result
  5073. * @returns true if the query matches
  5074. */
  5075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5076. private static _HandleParenthesisContent;
  5077. private static _SimplifyNegation;
  5078. }
  5079. }
  5080. declare module "babylonjs/Misc/tags" {
  5081. /**
  5082. * Class used to store custom tags
  5083. */
  5084. export class Tags {
  5085. /**
  5086. * Adds support for tags on the given object
  5087. * @param obj defines the object to use
  5088. */
  5089. static EnableFor(obj: any): void;
  5090. /**
  5091. * Removes tags support
  5092. * @param obj defines the object to use
  5093. */
  5094. static DisableFor(obj: any): void;
  5095. /**
  5096. * Gets a boolean indicating if the given object has tags
  5097. * @param obj defines the object to use
  5098. * @returns a boolean
  5099. */
  5100. static HasTags(obj: any): boolean;
  5101. /**
  5102. * Gets the tags available on a given object
  5103. * @param obj defines the object to use
  5104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5105. * @returns the tags
  5106. */
  5107. static GetTags(obj: any, asString?: boolean): any;
  5108. /**
  5109. * Adds tags to an object
  5110. * @param obj defines the object to use
  5111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5113. */
  5114. static AddTagsTo(obj: any, tagsString: string): void;
  5115. /**
  5116. * @hidden
  5117. */
  5118. static _AddTagTo(obj: any, tag: string): void;
  5119. /**
  5120. * Removes specific tags from a specific object
  5121. * @param obj defines the object to use
  5122. * @param tagsString defines the tags to remove
  5123. */
  5124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5125. /**
  5126. * @hidden
  5127. */
  5128. static _RemoveTagFrom(obj: any, tag: string): void;
  5129. /**
  5130. * Defines if tags hosted on an object match a given query
  5131. * @param obj defines the object to use
  5132. * @param tagsQuery defines the tag query
  5133. * @returns a boolean
  5134. */
  5135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5136. }
  5137. }
  5138. declare module "babylonjs/Materials/materialDefines" {
  5139. /**
  5140. * Manages the defines for the Material
  5141. */
  5142. export class MaterialDefines {
  5143. private _keys;
  5144. private _isDirty;
  5145. /** @hidden */
  5146. _renderId: number;
  5147. /** @hidden */
  5148. _areLightsDirty: boolean;
  5149. /** @hidden */
  5150. _areAttributesDirty: boolean;
  5151. /** @hidden */
  5152. _areTexturesDirty: boolean;
  5153. /** @hidden */
  5154. _areFresnelDirty: boolean;
  5155. /** @hidden */
  5156. _areMiscDirty: boolean;
  5157. /** @hidden */
  5158. _areImageProcessingDirty: boolean;
  5159. /** @hidden */
  5160. _normals: boolean;
  5161. /** @hidden */
  5162. _uvs: boolean;
  5163. /** @hidden */
  5164. _needNormals: boolean;
  5165. /** @hidden */
  5166. _needUVs: boolean;
  5167. /**
  5168. * Specifies if the material needs to be re-calculated
  5169. */
  5170. readonly isDirty: boolean;
  5171. /**
  5172. * Marks the material to indicate that it has been re-calculated
  5173. */
  5174. markAsProcessed(): void;
  5175. /**
  5176. * Marks the material to indicate that it needs to be re-calculated
  5177. */
  5178. markAsUnprocessed(): void;
  5179. /**
  5180. * Marks the material to indicate all of its defines need to be re-calculated
  5181. */
  5182. markAllAsDirty(): void;
  5183. /**
  5184. * Marks the material to indicate that image processing needs to be re-calculated
  5185. */
  5186. markAsImageProcessingDirty(): void;
  5187. /**
  5188. * Marks the material to indicate the lights need to be re-calculated
  5189. */
  5190. markAsLightDirty(): void;
  5191. /**
  5192. * Marks the attribute state as changed
  5193. */
  5194. markAsAttributesDirty(): void;
  5195. /**
  5196. * Marks the texture state as changed
  5197. */
  5198. markAsTexturesDirty(): void;
  5199. /**
  5200. * Marks the fresnel state as changed
  5201. */
  5202. markAsFresnelDirty(): void;
  5203. /**
  5204. * Marks the misc state as changed
  5205. */
  5206. markAsMiscDirty(): void;
  5207. /**
  5208. * Rebuilds the material defines
  5209. */
  5210. rebuild(): void;
  5211. /**
  5212. * Specifies if two material defines are equal
  5213. * @param other - A material define instance to compare to
  5214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5215. */
  5216. isEqual(other: MaterialDefines): boolean;
  5217. /**
  5218. * Clones this instance's defines to another instance
  5219. * @param other - material defines to clone values to
  5220. */
  5221. cloneTo(other: MaterialDefines): void;
  5222. /**
  5223. * Resets the material define values
  5224. */
  5225. reset(): void;
  5226. /**
  5227. * Converts the material define values to a string
  5228. * @returns - String of material define information
  5229. */
  5230. toString(): string;
  5231. }
  5232. }
  5233. declare module "babylonjs/Engines/IPipelineContext" {
  5234. /**
  5235. * Class used to store and describe the pipeline context associated with an effect
  5236. */
  5237. export interface IPipelineContext {
  5238. /**
  5239. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5240. */
  5241. isAsync: boolean;
  5242. /**
  5243. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5244. */
  5245. isReady: boolean;
  5246. /** @hidden */
  5247. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5248. }
  5249. }
  5250. declare module "babylonjs/Meshes/dataBuffer" {
  5251. /**
  5252. * Class used to store gfx data (like WebGLBuffer)
  5253. */
  5254. export class DataBuffer {
  5255. /**
  5256. * Gets or sets the number of objects referencing this buffer
  5257. */
  5258. references: number;
  5259. /** Gets or sets the size of the underlying buffer */
  5260. capacity: number;
  5261. /**
  5262. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5263. */
  5264. is32Bits: boolean;
  5265. /**
  5266. * Gets the underlying buffer
  5267. */
  5268. readonly underlyingResource: any;
  5269. }
  5270. }
  5271. declare module "babylonjs/Misc/performanceMonitor" {
  5272. /**
  5273. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5274. */
  5275. export class PerformanceMonitor {
  5276. private _enabled;
  5277. private _rollingFrameTime;
  5278. private _lastFrameTimeMs;
  5279. /**
  5280. * constructor
  5281. * @param frameSampleSize The number of samples required to saturate the sliding window
  5282. */
  5283. constructor(frameSampleSize?: number);
  5284. /**
  5285. * Samples current frame
  5286. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5287. */
  5288. sampleFrame(timeMs?: number): void;
  5289. /**
  5290. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5291. */
  5292. readonly averageFrameTime: number;
  5293. /**
  5294. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5295. */
  5296. readonly averageFrameTimeVariance: number;
  5297. /**
  5298. * Returns the frame time of the most recent frame
  5299. */
  5300. readonly instantaneousFrameTime: number;
  5301. /**
  5302. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5303. */
  5304. readonly averageFPS: number;
  5305. /**
  5306. * Returns the average framerate in frames per second using the most recent frame time
  5307. */
  5308. readonly instantaneousFPS: number;
  5309. /**
  5310. * Returns true if enough samples have been taken to completely fill the sliding window
  5311. */
  5312. readonly isSaturated: boolean;
  5313. /**
  5314. * Enables contributions to the sliding window sample set
  5315. */
  5316. enable(): void;
  5317. /**
  5318. * Disables contributions to the sliding window sample set
  5319. * Samples will not be interpolated over the disabled period
  5320. */
  5321. disable(): void;
  5322. /**
  5323. * Returns true if sampling is enabled
  5324. */
  5325. readonly isEnabled: boolean;
  5326. /**
  5327. * Resets performance monitor
  5328. */
  5329. reset(): void;
  5330. }
  5331. /**
  5332. * RollingAverage
  5333. *
  5334. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5335. */
  5336. export class RollingAverage {
  5337. /**
  5338. * Current average
  5339. */
  5340. average: number;
  5341. /**
  5342. * Current variance
  5343. */
  5344. variance: number;
  5345. protected _samples: Array<number>;
  5346. protected _sampleCount: number;
  5347. protected _pos: number;
  5348. protected _m2: number;
  5349. /**
  5350. * constructor
  5351. * @param length The number of samples required to saturate the sliding window
  5352. */
  5353. constructor(length: number);
  5354. /**
  5355. * Adds a sample to the sample set
  5356. * @param v The sample value
  5357. */
  5358. add(v: number): void;
  5359. /**
  5360. * Returns previously added values or null if outside of history or outside the sliding window domain
  5361. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5362. * @return Value previously recorded with add() or null if outside of range
  5363. */
  5364. history(i: number): number;
  5365. /**
  5366. * Returns true if enough samples have been taken to completely fill the sliding window
  5367. * @return true if sample-set saturated
  5368. */
  5369. isSaturated(): boolean;
  5370. /**
  5371. * Resets the rolling average (equivalent to 0 samples taken so far)
  5372. */
  5373. reset(): void;
  5374. /**
  5375. * Wraps a value around the sample range boundaries
  5376. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5377. * @return Wrapped position in sample range
  5378. */
  5379. protected _wrapPosition(i: number): number;
  5380. }
  5381. }
  5382. declare module "babylonjs/Misc/stringDictionary" {
  5383. import { Nullable } from "babylonjs/types";
  5384. /**
  5385. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5386. * The underlying implementation relies on an associative array to ensure the best performances.
  5387. * The value can be anything including 'null' but except 'undefined'
  5388. */
  5389. export class StringDictionary<T> {
  5390. /**
  5391. * This will clear this dictionary and copy the content from the 'source' one.
  5392. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5393. * @param source the dictionary to take the content from and copy to this dictionary
  5394. */
  5395. copyFrom(source: StringDictionary<T>): void;
  5396. /**
  5397. * Get a value based from its key
  5398. * @param key the given key to get the matching value from
  5399. * @return the value if found, otherwise undefined is returned
  5400. */
  5401. get(key: string): T | undefined;
  5402. /**
  5403. * Get a value from its key or add it if it doesn't exist.
  5404. * This method will ensure you that a given key/data will be present in the dictionary.
  5405. * @param key the given key to get the matching value from
  5406. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5407. * The factory will only be invoked if there's no data for the given key.
  5408. * @return the value corresponding to the key.
  5409. */
  5410. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5411. /**
  5412. * Get a value from its key if present in the dictionary otherwise add it
  5413. * @param key the key to get the value from
  5414. * @param val if there's no such key/value pair in the dictionary add it with this value
  5415. * @return the value corresponding to the key
  5416. */
  5417. getOrAdd(key: string, val: T): T;
  5418. /**
  5419. * Check if there's a given key in the dictionary
  5420. * @param key the key to check for
  5421. * @return true if the key is present, false otherwise
  5422. */
  5423. contains(key: string): boolean;
  5424. /**
  5425. * Add a new key and its corresponding value
  5426. * @param key the key to add
  5427. * @param value the value corresponding to the key
  5428. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5429. */
  5430. add(key: string, value: T): boolean;
  5431. /**
  5432. * Update a specific value associated to a key
  5433. * @param key defines the key to use
  5434. * @param value defines the value to store
  5435. * @returns true if the value was updated (or false if the key was not found)
  5436. */
  5437. set(key: string, value: T): boolean;
  5438. /**
  5439. * Get the element of the given key and remove it from the dictionary
  5440. * @param key defines the key to search
  5441. * @returns the value associated with the key or null if not found
  5442. */
  5443. getAndRemove(key: string): Nullable<T>;
  5444. /**
  5445. * Remove a key/value from the dictionary.
  5446. * @param key the key to remove
  5447. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5448. */
  5449. remove(key: string): boolean;
  5450. /**
  5451. * Clear the whole content of the dictionary
  5452. */
  5453. clear(): void;
  5454. /**
  5455. * Gets the current count
  5456. */
  5457. readonly count: number;
  5458. /**
  5459. * Execute a callback on each key/val of the dictionary.
  5460. * Note that you can remove any element in this dictionary in the callback implementation
  5461. * @param callback the callback to execute on a given key/value pair
  5462. */
  5463. forEach(callback: (key: string, val: T) => void): void;
  5464. /**
  5465. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5466. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5467. * Note that you can remove any element in this dictionary in the callback implementation
  5468. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5469. * @returns the first item
  5470. */
  5471. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5472. private _count;
  5473. private _data;
  5474. }
  5475. }
  5476. declare module "babylonjs/Misc/promise" {
  5477. /**
  5478. * Helper class that provides a small promise polyfill
  5479. */
  5480. export class PromisePolyfill {
  5481. /**
  5482. * Static function used to check if the polyfill is required
  5483. * If this is the case then the function will inject the polyfill to window.Promise
  5484. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5485. */
  5486. static Apply(force?: boolean): void;
  5487. }
  5488. }
  5489. declare module "babylonjs/Meshes/buffer" {
  5490. import { Nullable, DataArray } from "babylonjs/types";
  5491. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5492. /**
  5493. * Class used to store data that will be store in GPU memory
  5494. */
  5495. export class Buffer {
  5496. private _engine;
  5497. private _buffer;
  5498. /** @hidden */
  5499. _data: Nullable<DataArray>;
  5500. private _updatable;
  5501. private _instanced;
  5502. /**
  5503. * Gets the byte stride.
  5504. */
  5505. readonly byteStride: number;
  5506. /**
  5507. * Constructor
  5508. * @param engine the engine
  5509. * @param data the data to use for this buffer
  5510. * @param updatable whether the data is updatable
  5511. * @param stride the stride (optional)
  5512. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5513. * @param instanced whether the buffer is instanced (optional)
  5514. * @param useBytes set to true if the stride in in bytes (optional)
  5515. */
  5516. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5517. /**
  5518. * Create a new VertexBuffer based on the current buffer
  5519. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5520. * @param offset defines offset in the buffer (0 by default)
  5521. * @param size defines the size in floats of attributes (position is 3 for instance)
  5522. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5523. * @param instanced defines if the vertex buffer contains indexed data
  5524. * @param useBytes defines if the offset and stride are in bytes
  5525. * @returns the new vertex buffer
  5526. */
  5527. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5528. /**
  5529. * Gets a boolean indicating if the Buffer is updatable?
  5530. * @returns true if the buffer is updatable
  5531. */
  5532. isUpdatable(): boolean;
  5533. /**
  5534. * Gets current buffer's data
  5535. * @returns a DataArray or null
  5536. */
  5537. getData(): Nullable<DataArray>;
  5538. /**
  5539. * Gets underlying native buffer
  5540. * @returns underlying native buffer
  5541. */
  5542. getBuffer(): Nullable<DataBuffer>;
  5543. /**
  5544. * Gets the stride in float32 units (i.e. byte stride / 4).
  5545. * May not be an integer if the byte stride is not divisible by 4.
  5546. * DEPRECATED. Use byteStride instead.
  5547. * @returns the stride in float32 units
  5548. */
  5549. getStrideSize(): number;
  5550. /**
  5551. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5552. * @param data defines the data to store
  5553. */
  5554. create(data?: Nullable<DataArray>): void;
  5555. /** @hidden */
  5556. _rebuild(): void;
  5557. /**
  5558. * Update current buffer data
  5559. * @param data defines the data to store
  5560. */
  5561. update(data: DataArray): void;
  5562. /**
  5563. * Updates the data directly.
  5564. * @param data the new data
  5565. * @param offset the new offset
  5566. * @param vertexCount the vertex count (optional)
  5567. * @param useBytes set to true if the offset is in bytes
  5568. */
  5569. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5570. /**
  5571. * Release all resources
  5572. */
  5573. dispose(): void;
  5574. }
  5575. /**
  5576. * Specialized buffer used to store vertex data
  5577. */
  5578. export class VertexBuffer {
  5579. /** @hidden */
  5580. _buffer: Buffer;
  5581. private _kind;
  5582. private _size;
  5583. private _ownsBuffer;
  5584. private _instanced;
  5585. private _instanceDivisor;
  5586. /**
  5587. * The byte type.
  5588. */
  5589. static readonly BYTE: number;
  5590. /**
  5591. * The unsigned byte type.
  5592. */
  5593. static readonly UNSIGNED_BYTE: number;
  5594. /**
  5595. * The short type.
  5596. */
  5597. static readonly SHORT: number;
  5598. /**
  5599. * The unsigned short type.
  5600. */
  5601. static readonly UNSIGNED_SHORT: number;
  5602. /**
  5603. * The integer type.
  5604. */
  5605. static readonly INT: number;
  5606. /**
  5607. * The unsigned integer type.
  5608. */
  5609. static readonly UNSIGNED_INT: number;
  5610. /**
  5611. * The float type.
  5612. */
  5613. static readonly FLOAT: number;
  5614. /**
  5615. * Gets or sets the instance divisor when in instanced mode
  5616. */
  5617. instanceDivisor: number;
  5618. /**
  5619. * Gets the byte stride.
  5620. */
  5621. readonly byteStride: number;
  5622. /**
  5623. * Gets the byte offset.
  5624. */
  5625. readonly byteOffset: number;
  5626. /**
  5627. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5628. */
  5629. readonly normalized: boolean;
  5630. /**
  5631. * Gets the data type of each component in the array.
  5632. */
  5633. readonly type: number;
  5634. /**
  5635. * Constructor
  5636. * @param engine the engine
  5637. * @param data the data to use for this vertex buffer
  5638. * @param kind the vertex buffer kind
  5639. * @param updatable whether the data is updatable
  5640. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5641. * @param stride the stride (optional)
  5642. * @param instanced whether the buffer is instanced (optional)
  5643. * @param offset the offset of the data (optional)
  5644. * @param size the number of components (optional)
  5645. * @param type the type of the component (optional)
  5646. * @param normalized whether the data contains normalized data (optional)
  5647. * @param useBytes set to true if stride and offset are in bytes (optional)
  5648. */
  5649. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5650. /** @hidden */
  5651. _rebuild(): void;
  5652. /**
  5653. * Returns the kind of the VertexBuffer (string)
  5654. * @returns a string
  5655. */
  5656. getKind(): string;
  5657. /**
  5658. * Gets a boolean indicating if the VertexBuffer is updatable?
  5659. * @returns true if the buffer is updatable
  5660. */
  5661. isUpdatable(): boolean;
  5662. /**
  5663. * Gets current buffer's data
  5664. * @returns a DataArray or null
  5665. */
  5666. getData(): Nullable<DataArray>;
  5667. /**
  5668. * Gets underlying native buffer
  5669. * @returns underlying native buffer
  5670. */
  5671. getBuffer(): Nullable<DataBuffer>;
  5672. /**
  5673. * Gets the stride in float32 units (i.e. byte stride / 4).
  5674. * May not be an integer if the byte stride is not divisible by 4.
  5675. * DEPRECATED. Use byteStride instead.
  5676. * @returns the stride in float32 units
  5677. */
  5678. getStrideSize(): number;
  5679. /**
  5680. * Returns the offset as a multiple of the type byte length.
  5681. * DEPRECATED. Use byteOffset instead.
  5682. * @returns the offset in bytes
  5683. */
  5684. getOffset(): number;
  5685. /**
  5686. * Returns the number of components per vertex attribute (integer)
  5687. * @returns the size in float
  5688. */
  5689. getSize(): number;
  5690. /**
  5691. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5692. * @returns true if this buffer is instanced
  5693. */
  5694. getIsInstanced(): boolean;
  5695. /**
  5696. * Returns the instancing divisor, zero for non-instanced (integer).
  5697. * @returns a number
  5698. */
  5699. getInstanceDivisor(): number;
  5700. /**
  5701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5702. * @param data defines the data to store
  5703. */
  5704. create(data?: DataArray): void;
  5705. /**
  5706. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5707. * This function will create a new buffer if the current one is not updatable
  5708. * @param data defines the data to store
  5709. */
  5710. update(data: DataArray): void;
  5711. /**
  5712. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5713. * Returns the directly updated WebGLBuffer.
  5714. * @param data the new data
  5715. * @param offset the new offset
  5716. * @param useBytes set to true if the offset is in bytes
  5717. */
  5718. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5719. /**
  5720. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5721. */
  5722. dispose(): void;
  5723. /**
  5724. * Enumerates each value of this vertex buffer as numbers.
  5725. * @param count the number of values to enumerate
  5726. * @param callback the callback function called for each value
  5727. */
  5728. forEach(count: number, callback: (value: number, index: number) => void): void;
  5729. /**
  5730. * Positions
  5731. */
  5732. static readonly PositionKind: string;
  5733. /**
  5734. * Normals
  5735. */
  5736. static readonly NormalKind: string;
  5737. /**
  5738. * Tangents
  5739. */
  5740. static readonly TangentKind: string;
  5741. /**
  5742. * Texture coordinates
  5743. */
  5744. static readonly UVKind: string;
  5745. /**
  5746. * Texture coordinates 2
  5747. */
  5748. static readonly UV2Kind: string;
  5749. /**
  5750. * Texture coordinates 3
  5751. */
  5752. static readonly UV3Kind: string;
  5753. /**
  5754. * Texture coordinates 4
  5755. */
  5756. static readonly UV4Kind: string;
  5757. /**
  5758. * Texture coordinates 5
  5759. */
  5760. static readonly UV5Kind: string;
  5761. /**
  5762. * Texture coordinates 6
  5763. */
  5764. static readonly UV6Kind: string;
  5765. /**
  5766. * Colors
  5767. */
  5768. static readonly ColorKind: string;
  5769. /**
  5770. * Matrix indices (for bones)
  5771. */
  5772. static readonly MatricesIndicesKind: string;
  5773. /**
  5774. * Matrix weights (for bones)
  5775. */
  5776. static readonly MatricesWeightsKind: string;
  5777. /**
  5778. * Additional matrix indices (for bones)
  5779. */
  5780. static readonly MatricesIndicesExtraKind: string;
  5781. /**
  5782. * Additional matrix weights (for bones)
  5783. */
  5784. static readonly MatricesWeightsExtraKind: string;
  5785. /**
  5786. * Deduces the stride given a kind.
  5787. * @param kind The kind string to deduce
  5788. * @returns The deduced stride
  5789. */
  5790. static DeduceStride(kind: string): number;
  5791. /**
  5792. * Gets the byte length of the given type.
  5793. * @param type the type
  5794. * @returns the number of bytes
  5795. */
  5796. static GetTypeByteLength(type: number): number;
  5797. /**
  5798. * Enumerates each value of the given parameters as numbers.
  5799. * @param data the data to enumerate
  5800. * @param byteOffset the byte offset of the data
  5801. * @param byteStride the byte stride of the data
  5802. * @param componentCount the number of components per element
  5803. * @param componentType the type of the component
  5804. * @param count the total number of components
  5805. * @param normalized whether the data is normalized
  5806. * @param callback the callback function called for each value
  5807. */
  5808. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5809. private static _GetFloatValue;
  5810. }
  5811. }
  5812. declare module "babylonjs/Maths/sphericalPolynomial" {
  5813. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5814. /**
  5815. * Class representing spherical harmonics coefficients to the 3rd degree
  5816. */
  5817. export class SphericalHarmonics {
  5818. /**
  5819. * Defines whether or not the harmonics have been prescaled for rendering.
  5820. */
  5821. preScaled: boolean;
  5822. /**
  5823. * The l0,0 coefficients of the spherical harmonics
  5824. */
  5825. l00: Vector3;
  5826. /**
  5827. * The l1,-1 coefficients of the spherical harmonics
  5828. */
  5829. l1_1: Vector3;
  5830. /**
  5831. * The l1,0 coefficients of the spherical harmonics
  5832. */
  5833. l10: Vector3;
  5834. /**
  5835. * The l1,1 coefficients of the spherical harmonics
  5836. */
  5837. l11: Vector3;
  5838. /**
  5839. * The l2,-2 coefficients of the spherical harmonics
  5840. */
  5841. l2_2: Vector3;
  5842. /**
  5843. * The l2,-1 coefficients of the spherical harmonics
  5844. */
  5845. l2_1: Vector3;
  5846. /**
  5847. * The l2,0 coefficients of the spherical harmonics
  5848. */
  5849. l20: Vector3;
  5850. /**
  5851. * The l2,1 coefficients of the spherical harmonics
  5852. */
  5853. l21: Vector3;
  5854. /**
  5855. * The l2,2 coefficients of the spherical harmonics
  5856. */
  5857. l22: Vector3;
  5858. /**
  5859. * Adds a light to the spherical harmonics
  5860. * @param direction the direction of the light
  5861. * @param color the color of the light
  5862. * @param deltaSolidAngle the delta solid angle of the light
  5863. */
  5864. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5865. /**
  5866. * Scales the spherical harmonics by the given amount
  5867. * @param scale the amount to scale
  5868. */
  5869. scaleInPlace(scale: number): void;
  5870. /**
  5871. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5872. *
  5873. * ```
  5874. * E_lm = A_l * L_lm
  5875. * ```
  5876. *
  5877. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5878. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5879. * the scaling factors are given in equation 9.
  5880. */
  5881. convertIncidentRadianceToIrradiance(): void;
  5882. /**
  5883. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5884. *
  5885. * ```
  5886. * L = (1/pi) * E * rho
  5887. * ```
  5888. *
  5889. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5890. */
  5891. convertIrradianceToLambertianRadiance(): void;
  5892. /**
  5893. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5894. * required operations at run time.
  5895. *
  5896. * This is simply done by scaling back the SH with Ylm constants parameter.
  5897. * The trigonometric part being applied by the shader at run time.
  5898. */
  5899. preScaleForRendering(): void;
  5900. /**
  5901. * Constructs a spherical harmonics from an array.
  5902. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5903. * @returns the spherical harmonics
  5904. */
  5905. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5906. /**
  5907. * Gets the spherical harmonics from polynomial
  5908. * @param polynomial the spherical polynomial
  5909. * @returns the spherical harmonics
  5910. */
  5911. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5912. }
  5913. /**
  5914. * Class representing spherical polynomial coefficients to the 3rd degree
  5915. */
  5916. export class SphericalPolynomial {
  5917. private _harmonics;
  5918. /**
  5919. * The spherical harmonics used to create the polynomials.
  5920. */
  5921. readonly preScaledHarmonics: SphericalHarmonics;
  5922. /**
  5923. * The x coefficients of the spherical polynomial
  5924. */
  5925. x: Vector3;
  5926. /**
  5927. * The y coefficients of the spherical polynomial
  5928. */
  5929. y: Vector3;
  5930. /**
  5931. * The z coefficients of the spherical polynomial
  5932. */
  5933. z: Vector3;
  5934. /**
  5935. * The xx coefficients of the spherical polynomial
  5936. */
  5937. xx: Vector3;
  5938. /**
  5939. * The yy coefficients of the spherical polynomial
  5940. */
  5941. yy: Vector3;
  5942. /**
  5943. * The zz coefficients of the spherical polynomial
  5944. */
  5945. zz: Vector3;
  5946. /**
  5947. * The xy coefficients of the spherical polynomial
  5948. */
  5949. xy: Vector3;
  5950. /**
  5951. * The yz coefficients of the spherical polynomial
  5952. */
  5953. yz: Vector3;
  5954. /**
  5955. * The zx coefficients of the spherical polynomial
  5956. */
  5957. zx: Vector3;
  5958. /**
  5959. * Adds an ambient color to the spherical polynomial
  5960. * @param color the color to add
  5961. */
  5962. addAmbient(color: Color3): void;
  5963. /**
  5964. * Scales the spherical polynomial by the given amount
  5965. * @param scale the amount to scale
  5966. */
  5967. scaleInPlace(scale: number): void;
  5968. /**
  5969. * Gets the spherical polynomial from harmonics
  5970. * @param harmonics the spherical harmonics
  5971. * @returns the spherical polynomial
  5972. */
  5973. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5974. /**
  5975. * Constructs a spherical polynomial from an array.
  5976. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5977. * @returns the spherical polynomial
  5978. */
  5979. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5983. import { Nullable } from "babylonjs/types";
  5984. /**
  5985. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5986. */
  5987. export interface CubeMapInfo {
  5988. /**
  5989. * The pixel array for the front face.
  5990. * This is stored in format, left to right, up to down format.
  5991. */
  5992. front: Nullable<ArrayBufferView>;
  5993. /**
  5994. * The pixel array for the back face.
  5995. * This is stored in format, left to right, up to down format.
  5996. */
  5997. back: Nullable<ArrayBufferView>;
  5998. /**
  5999. * The pixel array for the left face.
  6000. * This is stored in format, left to right, up to down format.
  6001. */
  6002. left: Nullable<ArrayBufferView>;
  6003. /**
  6004. * The pixel array for the right face.
  6005. * This is stored in format, left to right, up to down format.
  6006. */
  6007. right: Nullable<ArrayBufferView>;
  6008. /**
  6009. * The pixel array for the up face.
  6010. * This is stored in format, left to right, up to down format.
  6011. */
  6012. up: Nullable<ArrayBufferView>;
  6013. /**
  6014. * The pixel array for the down face.
  6015. * This is stored in format, left to right, up to down format.
  6016. */
  6017. down: Nullable<ArrayBufferView>;
  6018. /**
  6019. * The size of the cubemap stored.
  6020. *
  6021. * Each faces will be size * size pixels.
  6022. */
  6023. size: number;
  6024. /**
  6025. * The format of the texture.
  6026. *
  6027. * RGBA, RGB.
  6028. */
  6029. format: number;
  6030. /**
  6031. * The type of the texture data.
  6032. *
  6033. * UNSIGNED_INT, FLOAT.
  6034. */
  6035. type: number;
  6036. /**
  6037. * Specifies whether the texture is in gamma space.
  6038. */
  6039. gammaSpace: boolean;
  6040. }
  6041. /**
  6042. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6043. */
  6044. export class PanoramaToCubeMapTools {
  6045. private static FACE_FRONT;
  6046. private static FACE_BACK;
  6047. private static FACE_RIGHT;
  6048. private static FACE_LEFT;
  6049. private static FACE_DOWN;
  6050. private static FACE_UP;
  6051. /**
  6052. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6053. *
  6054. * @param float32Array The source data.
  6055. * @param inputWidth The width of the input panorama.
  6056. * @param inputHeight The height of the input panorama.
  6057. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6058. * @return The cubemap data
  6059. */
  6060. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6061. private static CreateCubemapTexture;
  6062. private static CalcProjectionSpherical;
  6063. }
  6064. }
  6065. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6066. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6068. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6069. /**
  6070. * Helper class dealing with the extraction of spherical polynomial dataArray
  6071. * from a cube map.
  6072. */
  6073. export class CubeMapToSphericalPolynomialTools {
  6074. private static FileFaces;
  6075. /**
  6076. * Converts a texture to the according Spherical Polynomial data.
  6077. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6078. *
  6079. * @param texture The texture to extract the information from.
  6080. * @return The Spherical Polynomial data.
  6081. */
  6082. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6083. /**
  6084. * Converts a cubemap to the according Spherical Polynomial data.
  6085. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6086. *
  6087. * @param cubeInfo The Cube map to extract the information from.
  6088. * @return The Spherical Polynomial data.
  6089. */
  6090. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6091. }
  6092. }
  6093. declare module "babylonjs/Engines/engineStore" {
  6094. import { Nullable } from "babylonjs/types";
  6095. import { Engine } from "babylonjs/Engines/engine";
  6096. import { Scene } from "babylonjs/scene";
  6097. /**
  6098. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6099. * during the life time of the application.
  6100. */
  6101. export class EngineStore {
  6102. /** Gets the list of created engines */
  6103. static Instances: import("babylonjs/Engines/engine").Engine[];
  6104. /**
  6105. * Gets the latest created engine
  6106. */
  6107. static readonly LastCreatedEngine: Nullable<Engine>;
  6108. /**
  6109. * Gets the latest created scene
  6110. */
  6111. static readonly LastCreatedScene: Nullable<Scene>;
  6112. }
  6113. }
  6114. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6115. /**
  6116. * Define options used to create a render target texture
  6117. */
  6118. export class RenderTargetCreationOptions {
  6119. /**
  6120. * Specifies is mipmaps must be generated
  6121. */
  6122. generateMipMaps?: boolean;
  6123. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6124. generateDepthBuffer?: boolean;
  6125. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6126. generateStencilBuffer?: boolean;
  6127. /** Defines texture type (int by default) */
  6128. type?: number;
  6129. /** Defines sampling mode (trilinear by default) */
  6130. samplingMode?: number;
  6131. /** Defines format (RGBA by default) */
  6132. format?: number;
  6133. }
  6134. }
  6135. declare module "babylonjs/States/alphaCullingState" {
  6136. /**
  6137. * @hidden
  6138. **/
  6139. export class _AlphaState {
  6140. private _isAlphaBlendDirty;
  6141. private _isBlendFunctionParametersDirty;
  6142. private _isBlendEquationParametersDirty;
  6143. private _isBlendConstantsDirty;
  6144. private _alphaBlend;
  6145. private _blendFunctionParameters;
  6146. private _blendEquationParameters;
  6147. private _blendConstants;
  6148. /**
  6149. * Initializes the state.
  6150. */
  6151. constructor();
  6152. readonly isDirty: boolean;
  6153. alphaBlend: boolean;
  6154. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6155. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6156. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module "babylonjs/States/depthCullingState" {
  6162. import { Nullable } from "babylonjs/types";
  6163. /**
  6164. * @hidden
  6165. **/
  6166. export class _DepthCullingState {
  6167. private _isDepthTestDirty;
  6168. private _isDepthMaskDirty;
  6169. private _isDepthFuncDirty;
  6170. private _isCullFaceDirty;
  6171. private _isCullDirty;
  6172. private _isZOffsetDirty;
  6173. private _isFrontFaceDirty;
  6174. private _depthTest;
  6175. private _depthMask;
  6176. private _depthFunc;
  6177. private _cull;
  6178. private _cullFace;
  6179. private _zOffset;
  6180. private _frontFace;
  6181. /**
  6182. * Initializes the state.
  6183. */
  6184. constructor();
  6185. readonly isDirty: boolean;
  6186. zOffset: number;
  6187. cullFace: Nullable<number>;
  6188. cull: Nullable<boolean>;
  6189. depthFunc: Nullable<number>;
  6190. depthMask: boolean;
  6191. depthTest: boolean;
  6192. frontFace: Nullable<number>;
  6193. reset(): void;
  6194. apply(gl: WebGLRenderingContext): void;
  6195. }
  6196. }
  6197. declare module "babylonjs/States/stencilState" {
  6198. /**
  6199. * @hidden
  6200. **/
  6201. export class _StencilState {
  6202. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6203. static readonly ALWAYS: number;
  6204. /** Passed to stencilOperation to specify that stencil value must be kept */
  6205. static readonly KEEP: number;
  6206. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6207. static readonly REPLACE: number;
  6208. private _isStencilTestDirty;
  6209. private _isStencilMaskDirty;
  6210. private _isStencilFuncDirty;
  6211. private _isStencilOpDirty;
  6212. private _stencilTest;
  6213. private _stencilMask;
  6214. private _stencilFunc;
  6215. private _stencilFuncRef;
  6216. private _stencilFuncMask;
  6217. private _stencilOpStencilFail;
  6218. private _stencilOpDepthFail;
  6219. private _stencilOpStencilDepthPass;
  6220. readonly isDirty: boolean;
  6221. stencilFunc: number;
  6222. stencilFuncRef: number;
  6223. stencilFuncMask: number;
  6224. stencilOpStencilFail: number;
  6225. stencilOpDepthFail: number;
  6226. stencilOpStencilDepthPass: number;
  6227. stencilMask: number;
  6228. stencilTest: boolean;
  6229. constructor();
  6230. reset(): void;
  6231. apply(gl: WebGLRenderingContext): void;
  6232. }
  6233. }
  6234. declare module "babylonjs/States/index" {
  6235. export * from "babylonjs/States/alphaCullingState";
  6236. export * from "babylonjs/States/depthCullingState";
  6237. export * from "babylonjs/States/stencilState";
  6238. }
  6239. declare module "babylonjs/Instrumentation/timeToken" {
  6240. import { Nullable } from "babylonjs/types";
  6241. /**
  6242. * @hidden
  6243. **/
  6244. export class _TimeToken {
  6245. _startTimeQuery: Nullable<WebGLQuery>;
  6246. _endTimeQuery: Nullable<WebGLQuery>;
  6247. _timeElapsedQuery: Nullable<WebGLQuery>;
  6248. _timeElapsedQueryEnded: boolean;
  6249. }
  6250. }
  6251. declare module "babylonjs/Materials/Textures/internalTexture" {
  6252. import { Observable } from "babylonjs/Misc/observable";
  6253. import { Nullable, int } from "babylonjs/types";
  6254. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6255. import { Engine } from "babylonjs/Engines/engine";
  6256. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6257. /**
  6258. * Class used to store data associated with WebGL texture data for the engine
  6259. * This class should not be used directly
  6260. */
  6261. export class InternalTexture {
  6262. /** hidden */
  6263. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6264. /**
  6265. * The source of the texture data is unknown
  6266. */
  6267. static DATASOURCE_UNKNOWN: number;
  6268. /**
  6269. * Texture data comes from an URL
  6270. */
  6271. static DATASOURCE_URL: number;
  6272. /**
  6273. * Texture data is only used for temporary storage
  6274. */
  6275. static DATASOURCE_TEMP: number;
  6276. /**
  6277. * Texture data comes from raw data (ArrayBuffer)
  6278. */
  6279. static DATASOURCE_RAW: number;
  6280. /**
  6281. * Texture content is dynamic (video or dynamic texture)
  6282. */
  6283. static DATASOURCE_DYNAMIC: number;
  6284. /**
  6285. * Texture content is generated by rendering to it
  6286. */
  6287. static DATASOURCE_RENDERTARGET: number;
  6288. /**
  6289. * Texture content is part of a multi render target process
  6290. */
  6291. static DATASOURCE_MULTIRENDERTARGET: number;
  6292. /**
  6293. * Texture data comes from a cube data file
  6294. */
  6295. static DATASOURCE_CUBE: number;
  6296. /**
  6297. * Texture data comes from a raw cube data
  6298. */
  6299. static DATASOURCE_CUBERAW: number;
  6300. /**
  6301. * Texture data come from a prefiltered cube data file
  6302. */
  6303. static DATASOURCE_CUBEPREFILTERED: number;
  6304. /**
  6305. * Texture content is raw 3D data
  6306. */
  6307. static DATASOURCE_RAW3D: number;
  6308. /**
  6309. * Texture content is a depth texture
  6310. */
  6311. static DATASOURCE_DEPTHTEXTURE: number;
  6312. /**
  6313. * Texture data comes from a raw cube data encoded with RGBD
  6314. */
  6315. static DATASOURCE_CUBERAW_RGBD: number;
  6316. /**
  6317. * Defines if the texture is ready
  6318. */
  6319. isReady: boolean;
  6320. /**
  6321. * Defines if the texture is a cube texture
  6322. */
  6323. isCube: boolean;
  6324. /**
  6325. * Defines if the texture contains 3D data
  6326. */
  6327. is3D: boolean;
  6328. /**
  6329. * Defines if the texture contains multiview data
  6330. */
  6331. isMultiview: boolean;
  6332. /**
  6333. * Gets the URL used to load this texture
  6334. */
  6335. url: string;
  6336. /**
  6337. * Gets the sampling mode of the texture
  6338. */
  6339. samplingMode: number;
  6340. /**
  6341. * Gets a boolean indicating if the texture needs mipmaps generation
  6342. */
  6343. generateMipMaps: boolean;
  6344. /**
  6345. * Gets the number of samples used by the texture (WebGL2+ only)
  6346. */
  6347. samples: number;
  6348. /**
  6349. * Gets the type of the texture (int, float...)
  6350. */
  6351. type: number;
  6352. /**
  6353. * Gets the format of the texture (RGB, RGBA...)
  6354. */
  6355. format: number;
  6356. /**
  6357. * Observable called when the texture is loaded
  6358. */
  6359. onLoadedObservable: Observable<InternalTexture>;
  6360. /**
  6361. * Gets the width of the texture
  6362. */
  6363. width: number;
  6364. /**
  6365. * Gets the height of the texture
  6366. */
  6367. height: number;
  6368. /**
  6369. * Gets the depth of the texture
  6370. */
  6371. depth: number;
  6372. /**
  6373. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6374. */
  6375. baseWidth: number;
  6376. /**
  6377. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6378. */
  6379. baseHeight: number;
  6380. /**
  6381. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6382. */
  6383. baseDepth: number;
  6384. /**
  6385. * Gets a boolean indicating if the texture is inverted on Y axis
  6386. */
  6387. invertY: boolean;
  6388. /** @hidden */
  6389. _invertVScale: boolean;
  6390. /** @hidden */
  6391. _associatedChannel: number;
  6392. /** @hidden */
  6393. _dataSource: number;
  6394. /** @hidden */
  6395. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6396. /** @hidden */
  6397. _bufferView: Nullable<ArrayBufferView>;
  6398. /** @hidden */
  6399. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6400. /** @hidden */
  6401. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6402. /** @hidden */
  6403. _size: number;
  6404. /** @hidden */
  6405. _extension: string;
  6406. /** @hidden */
  6407. _files: Nullable<string[]>;
  6408. /** @hidden */
  6409. _workingCanvas: Nullable<HTMLCanvasElement>;
  6410. /** @hidden */
  6411. _workingContext: Nullable<CanvasRenderingContext2D>;
  6412. /** @hidden */
  6413. _framebuffer: Nullable<WebGLFramebuffer>;
  6414. /** @hidden */
  6415. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6416. /** @hidden */
  6417. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6418. /** @hidden */
  6419. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6420. /** @hidden */
  6421. _attachments: Nullable<number[]>;
  6422. /** @hidden */
  6423. _cachedCoordinatesMode: Nullable<number>;
  6424. /** @hidden */
  6425. _cachedWrapU: Nullable<number>;
  6426. /** @hidden */
  6427. _cachedWrapV: Nullable<number>;
  6428. /** @hidden */
  6429. _cachedWrapR: Nullable<number>;
  6430. /** @hidden */
  6431. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6432. /** @hidden */
  6433. _isDisabled: boolean;
  6434. /** @hidden */
  6435. _compression: Nullable<string>;
  6436. /** @hidden */
  6437. _generateStencilBuffer: boolean;
  6438. /** @hidden */
  6439. _generateDepthBuffer: boolean;
  6440. /** @hidden */
  6441. _comparisonFunction: number;
  6442. /** @hidden */
  6443. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6444. /** @hidden */
  6445. _lodGenerationScale: number;
  6446. /** @hidden */
  6447. _lodGenerationOffset: number;
  6448. /** @hidden */
  6449. _colorTextureArray: Nullable<WebGLTexture>;
  6450. /** @hidden */
  6451. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6452. /** @hidden */
  6453. _lodTextureHigh: Nullable<BaseTexture>;
  6454. /** @hidden */
  6455. _lodTextureMid: Nullable<BaseTexture>;
  6456. /** @hidden */
  6457. _lodTextureLow: Nullable<BaseTexture>;
  6458. /** @hidden */
  6459. _isRGBD: boolean;
  6460. /** @hidden */
  6461. _webGLTexture: Nullable<WebGLTexture>;
  6462. /** @hidden */
  6463. _references: number;
  6464. private _engine;
  6465. /**
  6466. * Gets the Engine the texture belongs to.
  6467. * @returns The babylon engine
  6468. */
  6469. getEngine(): Engine;
  6470. /**
  6471. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6472. */
  6473. readonly dataSource: number;
  6474. /**
  6475. * Creates a new InternalTexture
  6476. * @param engine defines the engine to use
  6477. * @param dataSource defines the type of data that will be used
  6478. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6479. */
  6480. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6481. /**
  6482. * Increments the number of references (ie. the number of Texture that point to it)
  6483. */
  6484. incrementReferences(): void;
  6485. /**
  6486. * Change the size of the texture (not the size of the content)
  6487. * @param width defines the new width
  6488. * @param height defines the new height
  6489. * @param depth defines the new depth (1 by default)
  6490. */
  6491. updateSize(width: int, height: int, depth?: int): void;
  6492. /** @hidden */
  6493. _rebuild(): void;
  6494. /** @hidden */
  6495. _swapAndDie(target: InternalTexture): void;
  6496. /**
  6497. * Dispose the current allocated resources
  6498. */
  6499. dispose(): void;
  6500. }
  6501. }
  6502. declare module "babylonjs/Animations/easing" {
  6503. /**
  6504. * This represents the main contract an easing function should follow.
  6505. * Easing functions are used throughout the animation system.
  6506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6507. */
  6508. export interface IEasingFunction {
  6509. /**
  6510. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6511. * of the easing function.
  6512. * The link below provides some of the most common examples of easing functions.
  6513. * @see https://easings.net/
  6514. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6515. * @returns the corresponding value on the curve defined by the easing function
  6516. */
  6517. ease(gradient: number): number;
  6518. }
  6519. /**
  6520. * Base class used for every default easing function.
  6521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6522. */
  6523. export class EasingFunction implements IEasingFunction {
  6524. /**
  6525. * Interpolation follows the mathematical formula associated with the easing function.
  6526. */
  6527. static readonly EASINGMODE_EASEIN: number;
  6528. /**
  6529. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6530. */
  6531. static readonly EASINGMODE_EASEOUT: number;
  6532. /**
  6533. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6534. */
  6535. static readonly EASINGMODE_EASEINOUT: number;
  6536. private _easingMode;
  6537. /**
  6538. * Sets the easing mode of the current function.
  6539. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6540. */
  6541. setEasingMode(easingMode: number): void;
  6542. /**
  6543. * Gets the current easing mode.
  6544. * @returns the easing mode
  6545. */
  6546. getEasingMode(): number;
  6547. /**
  6548. * @hidden
  6549. */
  6550. easeInCore(gradient: number): number;
  6551. /**
  6552. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6553. * of the easing function.
  6554. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6555. * @returns the corresponding value on the curve defined by the easing function
  6556. */
  6557. ease(gradient: number): number;
  6558. }
  6559. /**
  6560. * Easing function with a circle shape (see link below).
  6561. * @see https://easings.net/#easeInCirc
  6562. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6563. */
  6564. export class CircleEase extends EasingFunction implements IEasingFunction {
  6565. /** @hidden */
  6566. easeInCore(gradient: number): number;
  6567. }
  6568. /**
  6569. * Easing function with a ease back shape (see link below).
  6570. * @see https://easings.net/#easeInBack
  6571. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6572. */
  6573. export class BackEase extends EasingFunction implements IEasingFunction {
  6574. /** Defines the amplitude of the function */
  6575. amplitude: number;
  6576. /**
  6577. * Instantiates a back ease easing
  6578. * @see https://easings.net/#easeInBack
  6579. * @param amplitude Defines the amplitude of the function
  6580. */
  6581. constructor(
  6582. /** Defines the amplitude of the function */
  6583. amplitude?: number);
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a bouncing shape (see link below).
  6589. * @see https://easings.net/#easeInBounce
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class BounceEase extends EasingFunction implements IEasingFunction {
  6593. /** Defines the number of bounces */
  6594. bounces: number;
  6595. /** Defines the amplitude of the bounce */
  6596. bounciness: number;
  6597. /**
  6598. * Instantiates a bounce easing
  6599. * @see https://easings.net/#easeInBounce
  6600. * @param bounces Defines the number of bounces
  6601. * @param bounciness Defines the amplitude of the bounce
  6602. */
  6603. constructor(
  6604. /** Defines the number of bounces */
  6605. bounces?: number,
  6606. /** Defines the amplitude of the bounce */
  6607. bounciness?: number);
  6608. /** @hidden */
  6609. easeInCore(gradient: number): number;
  6610. }
  6611. /**
  6612. * Easing function with a power of 3 shape (see link below).
  6613. * @see https://easings.net/#easeInCubic
  6614. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6615. */
  6616. export class CubicEase extends EasingFunction implements IEasingFunction {
  6617. /** @hidden */
  6618. easeInCore(gradient: number): number;
  6619. }
  6620. /**
  6621. * Easing function with an elastic shape (see link below).
  6622. * @see https://easings.net/#easeInElastic
  6623. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6624. */
  6625. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6626. /** Defines the number of oscillations*/
  6627. oscillations: number;
  6628. /** Defines the amplitude of the oscillations*/
  6629. springiness: number;
  6630. /**
  6631. * Instantiates an elastic easing function
  6632. * @see https://easings.net/#easeInElastic
  6633. * @param oscillations Defines the number of oscillations
  6634. * @param springiness Defines the amplitude of the oscillations
  6635. */
  6636. constructor(
  6637. /** Defines the number of oscillations*/
  6638. oscillations?: number,
  6639. /** Defines the amplitude of the oscillations*/
  6640. springiness?: number);
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with an exponential shape (see link below).
  6646. * @see https://easings.net/#easeInExpo
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6650. /** Defines the exponent of the function */
  6651. exponent: number;
  6652. /**
  6653. * Instantiates an exponential easing function
  6654. * @see https://easings.net/#easeInExpo
  6655. * @param exponent Defines the exponent of the function
  6656. */
  6657. constructor(
  6658. /** Defines the exponent of the function */
  6659. exponent?: number);
  6660. /** @hidden */
  6661. easeInCore(gradient: number): number;
  6662. }
  6663. /**
  6664. * Easing function with a power shape (see link below).
  6665. * @see https://easings.net/#easeInQuad
  6666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6667. */
  6668. export class PowerEase extends EasingFunction implements IEasingFunction {
  6669. /** Defines the power of the function */
  6670. power: number;
  6671. /**
  6672. * Instantiates an power base easing function
  6673. * @see https://easings.net/#easeInQuad
  6674. * @param power Defines the power of the function
  6675. */
  6676. constructor(
  6677. /** Defines the power of the function */
  6678. power?: number);
  6679. /** @hidden */
  6680. easeInCore(gradient: number): number;
  6681. }
  6682. /**
  6683. * Easing function with a power of 2 shape (see link below).
  6684. * @see https://easings.net/#easeInQuad
  6685. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6686. */
  6687. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6688. /** @hidden */
  6689. easeInCore(gradient: number): number;
  6690. }
  6691. /**
  6692. * Easing function with a power of 4 shape (see link below).
  6693. * @see https://easings.net/#easeInQuart
  6694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6695. */
  6696. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6697. /** @hidden */
  6698. easeInCore(gradient: number): number;
  6699. }
  6700. /**
  6701. * Easing function with a power of 5 shape (see link below).
  6702. * @see https://easings.net/#easeInQuint
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6706. /** @hidden */
  6707. easeInCore(gradient: number): number;
  6708. }
  6709. /**
  6710. * Easing function with a sin shape (see link below).
  6711. * @see https://easings.net/#easeInSine
  6712. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6713. */
  6714. export class SineEase extends EasingFunction implements IEasingFunction {
  6715. /** @hidden */
  6716. easeInCore(gradient: number): number;
  6717. }
  6718. /**
  6719. * Easing function with a bezier shape (see link below).
  6720. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6721. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6722. */
  6723. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6724. /** Defines the x component of the start tangent in the bezier curve */
  6725. x1: number;
  6726. /** Defines the y component of the start tangent in the bezier curve */
  6727. y1: number;
  6728. /** Defines the x component of the end tangent in the bezier curve */
  6729. x2: number;
  6730. /** Defines the y component of the end tangent in the bezier curve */
  6731. y2: number;
  6732. /**
  6733. * Instantiates a bezier function
  6734. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6735. * @param x1 Defines the x component of the start tangent in the bezier curve
  6736. * @param y1 Defines the y component of the start tangent in the bezier curve
  6737. * @param x2 Defines the x component of the end tangent in the bezier curve
  6738. * @param y2 Defines the y component of the end tangent in the bezier curve
  6739. */
  6740. constructor(
  6741. /** Defines the x component of the start tangent in the bezier curve */
  6742. x1?: number,
  6743. /** Defines the y component of the start tangent in the bezier curve */
  6744. y1?: number,
  6745. /** Defines the x component of the end tangent in the bezier curve */
  6746. x2?: number,
  6747. /** Defines the y component of the end tangent in the bezier curve */
  6748. y2?: number);
  6749. /** @hidden */
  6750. easeInCore(gradient: number): number;
  6751. }
  6752. }
  6753. declare module "babylonjs/Animations/animationKey" {
  6754. /**
  6755. * Defines an interface which represents an animation key frame
  6756. */
  6757. export interface IAnimationKey {
  6758. /**
  6759. * Frame of the key frame
  6760. */
  6761. frame: number;
  6762. /**
  6763. * Value at the specifies key frame
  6764. */
  6765. value: any;
  6766. /**
  6767. * The input tangent for the cubic hermite spline
  6768. */
  6769. inTangent?: any;
  6770. /**
  6771. * The output tangent for the cubic hermite spline
  6772. */
  6773. outTangent?: any;
  6774. /**
  6775. * The animation interpolation type
  6776. */
  6777. interpolation?: AnimationKeyInterpolation;
  6778. }
  6779. /**
  6780. * Enum for the animation key frame interpolation type
  6781. */
  6782. export enum AnimationKeyInterpolation {
  6783. /**
  6784. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6785. */
  6786. STEP = 1
  6787. }
  6788. }
  6789. declare module "babylonjs/Animations/animationRange" {
  6790. /**
  6791. * Represents the range of an animation
  6792. */
  6793. export class AnimationRange {
  6794. /**The name of the animation range**/
  6795. name: string;
  6796. /**The starting frame of the animation */
  6797. from: number;
  6798. /**The ending frame of the animation*/
  6799. to: number;
  6800. /**
  6801. * Initializes the range of an animation
  6802. * @param name The name of the animation range
  6803. * @param from The starting frame of the animation
  6804. * @param to The ending frame of the animation
  6805. */
  6806. constructor(
  6807. /**The name of the animation range**/
  6808. name: string,
  6809. /**The starting frame of the animation */
  6810. from: number,
  6811. /**The ending frame of the animation*/
  6812. to: number);
  6813. /**
  6814. * Makes a copy of the animation range
  6815. * @returns A copy of the animation range
  6816. */
  6817. clone(): AnimationRange;
  6818. }
  6819. }
  6820. declare module "babylonjs/Animations/animationEvent" {
  6821. /**
  6822. * Composed of a frame, and an action function
  6823. */
  6824. export class AnimationEvent {
  6825. /** The frame for which the event is triggered **/
  6826. frame: number;
  6827. /** The event to perform when triggered **/
  6828. action: (currentFrame: number) => void;
  6829. /** Specifies if the event should be triggered only once**/
  6830. onlyOnce?: boolean | undefined;
  6831. /**
  6832. * Specifies if the animation event is done
  6833. */
  6834. isDone: boolean;
  6835. /**
  6836. * Initializes the animation event
  6837. * @param frame The frame for which the event is triggered
  6838. * @param action The event to perform when triggered
  6839. * @param onlyOnce Specifies if the event should be triggered only once
  6840. */
  6841. constructor(
  6842. /** The frame for which the event is triggered **/
  6843. frame: number,
  6844. /** The event to perform when triggered **/
  6845. action: (currentFrame: number) => void,
  6846. /** Specifies if the event should be triggered only once**/
  6847. onlyOnce?: boolean | undefined);
  6848. /** @hidden */
  6849. _clone(): AnimationEvent;
  6850. }
  6851. }
  6852. declare module "babylonjs/Behaviors/behavior" {
  6853. import { Nullable } from "babylonjs/types";
  6854. /**
  6855. * Interface used to define a behavior
  6856. */
  6857. export interface Behavior<T> {
  6858. /** gets or sets behavior's name */
  6859. name: string;
  6860. /**
  6861. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6862. */
  6863. init(): void;
  6864. /**
  6865. * Called when the behavior is attached to a target
  6866. * @param target defines the target where the behavior is attached to
  6867. */
  6868. attach(target: T): void;
  6869. /**
  6870. * Called when the behavior is detached from its target
  6871. */
  6872. detach(): void;
  6873. }
  6874. /**
  6875. * Interface implemented by classes supporting behaviors
  6876. */
  6877. export interface IBehaviorAware<T> {
  6878. /**
  6879. * Attach a behavior
  6880. * @param behavior defines the behavior to attach
  6881. * @returns the current host
  6882. */
  6883. addBehavior(behavior: Behavior<T>): T;
  6884. /**
  6885. * Remove a behavior from the current object
  6886. * @param behavior defines the behavior to detach
  6887. * @returns the current host
  6888. */
  6889. removeBehavior(behavior: Behavior<T>): T;
  6890. /**
  6891. * Gets a behavior using its name to search
  6892. * @param name defines the name to search
  6893. * @returns the behavior or null if not found
  6894. */
  6895. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6896. }
  6897. }
  6898. declare module "babylonjs/Collisions/intersectionInfo" {
  6899. import { Nullable } from "babylonjs/types";
  6900. /**
  6901. * @hidden
  6902. */
  6903. export class IntersectionInfo {
  6904. bu: Nullable<number>;
  6905. bv: Nullable<number>;
  6906. distance: number;
  6907. faceId: number;
  6908. subMeshId: number;
  6909. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6910. }
  6911. }
  6912. declare module "babylonjs/Culling/boundingSphere" {
  6913. import { DeepImmutable } from "babylonjs/types";
  6914. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6915. /**
  6916. * Class used to store bounding sphere information
  6917. */
  6918. export class BoundingSphere {
  6919. /**
  6920. * Gets the center of the bounding sphere in local space
  6921. */
  6922. readonly center: Vector3;
  6923. /**
  6924. * Radius of the bounding sphere in local space
  6925. */
  6926. radius: number;
  6927. /**
  6928. * Gets the center of the bounding sphere in world space
  6929. */
  6930. readonly centerWorld: Vector3;
  6931. /**
  6932. * Radius of the bounding sphere in world space
  6933. */
  6934. radiusWorld: number;
  6935. /**
  6936. * Gets the minimum vector in local space
  6937. */
  6938. readonly minimum: Vector3;
  6939. /**
  6940. * Gets the maximum vector in local space
  6941. */
  6942. readonly maximum: Vector3;
  6943. private _worldMatrix;
  6944. private static readonly TmpVector3;
  6945. /**
  6946. * Creates a new bounding sphere
  6947. * @param min defines the minimum vector (in local space)
  6948. * @param max defines the maximum vector (in local space)
  6949. * @param worldMatrix defines the new world matrix
  6950. */
  6951. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6952. /**
  6953. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6954. * @param min defines the new minimum vector (in local space)
  6955. * @param max defines the new maximum vector (in local space)
  6956. * @param worldMatrix defines the new world matrix
  6957. */
  6958. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6959. /**
  6960. * Scale the current bounding sphere by applying a scale factor
  6961. * @param factor defines the scale factor to apply
  6962. * @returns the current bounding box
  6963. */
  6964. scale(factor: number): BoundingSphere;
  6965. /**
  6966. * Gets the world matrix of the bounding box
  6967. * @returns a matrix
  6968. */
  6969. getWorldMatrix(): DeepImmutable<Matrix>;
  6970. /** @hidden */
  6971. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6972. /**
  6973. * Tests if the bounding sphere is intersecting the frustum planes
  6974. * @param frustumPlanes defines the frustum planes to test
  6975. * @returns true if there is an intersection
  6976. */
  6977. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6978. /**
  6979. * Tests if the bounding sphere center is in between the frustum planes.
  6980. * Used for optimistic fast inclusion.
  6981. * @param frustumPlanes defines the frustum planes to test
  6982. * @returns true if the sphere center is in between the frustum planes
  6983. */
  6984. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6985. /**
  6986. * Tests if a point is inside the bounding sphere
  6987. * @param point defines the point to test
  6988. * @returns true if the point is inside the bounding sphere
  6989. */
  6990. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6991. /**
  6992. * Checks if two sphere intersct
  6993. * @param sphere0 sphere 0
  6994. * @param sphere1 sphere 1
  6995. * @returns true if the speres intersect
  6996. */
  6997. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6998. }
  6999. }
  7000. declare module "babylonjs/Culling/boundingBox" {
  7001. import { DeepImmutable } from "babylonjs/types";
  7002. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7003. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7004. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7005. /**
  7006. * Class used to store bounding box information
  7007. */
  7008. export class BoundingBox implements ICullable {
  7009. /**
  7010. * Gets the 8 vectors representing the bounding box in local space
  7011. */
  7012. readonly vectors: Vector3[];
  7013. /**
  7014. * Gets the center of the bounding box in local space
  7015. */
  7016. readonly center: Vector3;
  7017. /**
  7018. * Gets the center of the bounding box in world space
  7019. */
  7020. readonly centerWorld: Vector3;
  7021. /**
  7022. * Gets the extend size in local space
  7023. */
  7024. readonly extendSize: Vector3;
  7025. /**
  7026. * Gets the extend size in world space
  7027. */
  7028. readonly extendSizeWorld: Vector3;
  7029. /**
  7030. * Gets the OBB (object bounding box) directions
  7031. */
  7032. readonly directions: Vector3[];
  7033. /**
  7034. * Gets the 8 vectors representing the bounding box in world space
  7035. */
  7036. readonly vectorsWorld: Vector3[];
  7037. /**
  7038. * Gets the minimum vector in world space
  7039. */
  7040. readonly minimumWorld: Vector3;
  7041. /**
  7042. * Gets the maximum vector in world space
  7043. */
  7044. readonly maximumWorld: Vector3;
  7045. /**
  7046. * Gets the minimum vector in local space
  7047. */
  7048. readonly minimum: Vector3;
  7049. /**
  7050. * Gets the maximum vector in local space
  7051. */
  7052. readonly maximum: Vector3;
  7053. private _worldMatrix;
  7054. private static readonly TmpVector3;
  7055. /**
  7056. * @hidden
  7057. */
  7058. _tag: number;
  7059. /**
  7060. * Creates a new bounding box
  7061. * @param min defines the minimum vector (in local space)
  7062. * @param max defines the maximum vector (in local space)
  7063. * @param worldMatrix defines the new world matrix
  7064. */
  7065. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7066. /**
  7067. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7068. * @param min defines the new minimum vector (in local space)
  7069. * @param max defines the new maximum vector (in local space)
  7070. * @param worldMatrix defines the new world matrix
  7071. */
  7072. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7073. /**
  7074. * Scale the current bounding box by applying a scale factor
  7075. * @param factor defines the scale factor to apply
  7076. * @returns the current bounding box
  7077. */
  7078. scale(factor: number): BoundingBox;
  7079. /**
  7080. * Gets the world matrix of the bounding box
  7081. * @returns a matrix
  7082. */
  7083. getWorldMatrix(): DeepImmutable<Matrix>;
  7084. /** @hidden */
  7085. _update(world: DeepImmutable<Matrix>): void;
  7086. /**
  7087. * Tests if the bounding box is intersecting the frustum planes
  7088. * @param frustumPlanes defines the frustum planes to test
  7089. * @returns true if there is an intersection
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7092. /**
  7093. * Tests if the bounding box is entirely inside the frustum planes
  7094. * @param frustumPlanes defines the frustum planes to test
  7095. * @returns true if there is an inclusion
  7096. */
  7097. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7098. /**
  7099. * Tests if a point is inside the bounding box
  7100. * @param point defines the point to test
  7101. * @returns true if the point is inside the bounding box
  7102. */
  7103. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7104. /**
  7105. * Tests if the bounding box intersects with a bounding sphere
  7106. * @param sphere defines the sphere to test
  7107. * @returns true if there is an intersection
  7108. */
  7109. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7110. /**
  7111. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7112. * @param min defines the min vector to use
  7113. * @param max defines the max vector to use
  7114. * @returns true if there is an intersection
  7115. */
  7116. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7117. /**
  7118. * Tests if two bounding boxes are intersections
  7119. * @param box0 defines the first box to test
  7120. * @param box1 defines the second box to test
  7121. * @returns true if there is an intersection
  7122. */
  7123. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7124. /**
  7125. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7126. * @param minPoint defines the minimum vector of the bounding box
  7127. * @param maxPoint defines the maximum vector of the bounding box
  7128. * @param sphereCenter defines the sphere center
  7129. * @param sphereRadius defines the sphere radius
  7130. * @returns true if there is an intersection
  7131. */
  7132. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7133. /**
  7134. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7135. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7136. * @param frustumPlanes defines the frustum planes to test
  7137. * @return true if there is an inclusion
  7138. */
  7139. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7140. /**
  7141. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7142. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7143. * @param frustumPlanes defines the frustum planes to test
  7144. * @return true if there is an intersection
  7145. */
  7146. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. }
  7148. }
  7149. declare module "babylonjs/Collisions/collider" {
  7150. import { Nullable, IndicesArray } from "babylonjs/types";
  7151. import { Vector3, Plane } from "babylonjs/Maths/math";
  7152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7153. /** @hidden */
  7154. export class Collider {
  7155. /** Define if a collision was found */
  7156. collisionFound: boolean;
  7157. /**
  7158. * Define last intersection point in local space
  7159. */
  7160. intersectionPoint: Vector3;
  7161. /**
  7162. * Define last collided mesh
  7163. */
  7164. collidedMesh: Nullable<AbstractMesh>;
  7165. private _collisionPoint;
  7166. private _planeIntersectionPoint;
  7167. private _tempVector;
  7168. private _tempVector2;
  7169. private _tempVector3;
  7170. private _tempVector4;
  7171. private _edge;
  7172. private _baseToVertex;
  7173. private _destinationPoint;
  7174. private _slidePlaneNormal;
  7175. private _displacementVector;
  7176. /** @hidden */
  7177. _radius: Vector3;
  7178. /** @hidden */
  7179. _retry: number;
  7180. private _velocity;
  7181. private _basePoint;
  7182. private _epsilon;
  7183. /** @hidden */
  7184. _velocityWorldLength: number;
  7185. /** @hidden */
  7186. _basePointWorld: Vector3;
  7187. private _velocityWorld;
  7188. private _normalizedVelocity;
  7189. /** @hidden */
  7190. _initialVelocity: Vector3;
  7191. /** @hidden */
  7192. _initialPosition: Vector3;
  7193. private _nearestDistance;
  7194. private _collisionMask;
  7195. collisionMask: number;
  7196. /**
  7197. * Gets the plane normal used to compute the sliding response (in local space)
  7198. */
  7199. readonly slidePlaneNormal: Vector3;
  7200. /** @hidden */
  7201. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7202. /** @hidden */
  7203. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7204. /** @hidden */
  7205. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7206. /** @hidden */
  7207. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7208. /** @hidden */
  7209. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7210. /** @hidden */
  7211. _getResponse(pos: Vector3, vel: Vector3): void;
  7212. }
  7213. }
  7214. declare module "babylonjs/Culling/boundingInfo" {
  7215. import { DeepImmutable } from "babylonjs/types";
  7216. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7217. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7218. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7219. import { Collider } from "babylonjs/Collisions/collider";
  7220. /**
  7221. * Interface for cullable objects
  7222. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7223. */
  7224. export interface ICullable {
  7225. /**
  7226. * Checks if the object or part of the object is in the frustum
  7227. * @param frustumPlanes Camera near/planes
  7228. * @returns true if the object is in frustum otherwise false
  7229. */
  7230. isInFrustum(frustumPlanes: Plane[]): boolean;
  7231. /**
  7232. * Checks if a cullable object (mesh...) is in the camera frustum
  7233. * Unlike isInFrustum this cheks the full bounding box
  7234. * @param frustumPlanes Camera near/planes
  7235. * @returns true if the object is in frustum otherwise false
  7236. */
  7237. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7238. }
  7239. /**
  7240. * Info for a bounding data of a mesh
  7241. */
  7242. export class BoundingInfo implements ICullable {
  7243. /**
  7244. * Bounding box for the mesh
  7245. */
  7246. readonly boundingBox: BoundingBox;
  7247. /**
  7248. * Bounding sphere for the mesh
  7249. */
  7250. readonly boundingSphere: BoundingSphere;
  7251. private _isLocked;
  7252. private static readonly TmpVector3;
  7253. /**
  7254. * Constructs bounding info
  7255. * @param minimum min vector of the bounding box/sphere
  7256. * @param maximum max vector of the bounding box/sphere
  7257. * @param worldMatrix defines the new world matrix
  7258. */
  7259. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7260. /**
  7261. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7262. * @param min defines the new minimum vector (in local space)
  7263. * @param max defines the new maximum vector (in local space)
  7264. * @param worldMatrix defines the new world matrix
  7265. */
  7266. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7267. /**
  7268. * min vector of the bounding box/sphere
  7269. */
  7270. readonly minimum: Vector3;
  7271. /**
  7272. * max vector of the bounding box/sphere
  7273. */
  7274. readonly maximum: Vector3;
  7275. /**
  7276. * If the info is locked and won't be updated to avoid perf overhead
  7277. */
  7278. isLocked: boolean;
  7279. /**
  7280. * Updates the bounding sphere and box
  7281. * @param world world matrix to be used to update
  7282. */
  7283. update(world: DeepImmutable<Matrix>): void;
  7284. /**
  7285. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7286. * @param center New center of the bounding info
  7287. * @param extend New extend of the bounding info
  7288. * @returns the current bounding info
  7289. */
  7290. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7291. /**
  7292. * Scale the current bounding info by applying a scale factor
  7293. * @param factor defines the scale factor to apply
  7294. * @returns the current bounding info
  7295. */
  7296. scale(factor: number): BoundingInfo;
  7297. /**
  7298. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7299. * @param frustumPlanes defines the frustum to test
  7300. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7301. * @returns true if the bounding info is in the frustum planes
  7302. */
  7303. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7304. /**
  7305. * Gets the world distance between the min and max points of the bounding box
  7306. */
  7307. readonly diagonalLength: number;
  7308. /**
  7309. * Checks if a cullable object (mesh...) is in the camera frustum
  7310. * Unlike isInFrustum this cheks the full bounding box
  7311. * @param frustumPlanes Camera near/planes
  7312. * @returns true if the object is in frustum otherwise false
  7313. */
  7314. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7315. /** @hidden */
  7316. _checkCollision(collider: Collider): boolean;
  7317. /**
  7318. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7319. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7320. * @param point the point to check intersection with
  7321. * @returns if the point intersects
  7322. */
  7323. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7324. /**
  7325. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7326. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7327. * @param boundingInfo the bounding info to check intersection with
  7328. * @param precise if the intersection should be done using OBB
  7329. * @returns if the bounding info intersects
  7330. */
  7331. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7332. }
  7333. }
  7334. declare module "babylonjs/Misc/smartArray" {
  7335. /**
  7336. * Defines an array and its length.
  7337. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7338. */
  7339. export interface ISmartArrayLike<T> {
  7340. /**
  7341. * The data of the array.
  7342. */
  7343. data: Array<T>;
  7344. /**
  7345. * The active length of the array.
  7346. */
  7347. length: number;
  7348. }
  7349. /**
  7350. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7351. */
  7352. export class SmartArray<T> implements ISmartArrayLike<T> {
  7353. /**
  7354. * The full set of data from the array.
  7355. */
  7356. data: Array<T>;
  7357. /**
  7358. * The active length of the array.
  7359. */
  7360. length: number;
  7361. protected _id: number;
  7362. /**
  7363. * Instantiates a Smart Array.
  7364. * @param capacity defines the default capacity of the array.
  7365. */
  7366. constructor(capacity: number);
  7367. /**
  7368. * Pushes a value at the end of the active data.
  7369. * @param value defines the object to push in the array.
  7370. */
  7371. push(value: T): void;
  7372. /**
  7373. * Iterates over the active data and apply the lambda to them.
  7374. * @param func defines the action to apply on each value.
  7375. */
  7376. forEach(func: (content: T) => void): void;
  7377. /**
  7378. * Sorts the full sets of data.
  7379. * @param compareFn defines the comparison function to apply.
  7380. */
  7381. sort(compareFn: (a: T, b: T) => number): void;
  7382. /**
  7383. * Resets the active data to an empty array.
  7384. */
  7385. reset(): void;
  7386. /**
  7387. * Releases all the data from the array as well as the array.
  7388. */
  7389. dispose(): void;
  7390. /**
  7391. * Concats the active data with a given array.
  7392. * @param array defines the data to concatenate with.
  7393. */
  7394. concat(array: any): void;
  7395. /**
  7396. * Returns the position of a value in the active data.
  7397. * @param value defines the value to find the index for
  7398. * @returns the index if found in the active data otherwise -1
  7399. */
  7400. indexOf(value: T): number;
  7401. /**
  7402. * Returns whether an element is part of the active data.
  7403. * @param value defines the value to look for
  7404. * @returns true if found in the active data otherwise false
  7405. */
  7406. contains(value: T): boolean;
  7407. private static _GlobalId;
  7408. }
  7409. /**
  7410. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7411. * The data in this array can only be present once
  7412. */
  7413. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7414. private _duplicateId;
  7415. /**
  7416. * Pushes a value at the end of the active data.
  7417. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7418. * @param value defines the object to push in the array.
  7419. */
  7420. push(value: T): void;
  7421. /**
  7422. * Pushes a value at the end of the active data.
  7423. * If the data is already present, it won t be added again
  7424. * @param value defines the object to push in the array.
  7425. * @returns true if added false if it was already present
  7426. */
  7427. pushNoDuplicate(value: T): boolean;
  7428. /**
  7429. * Resets the active data to an empty array.
  7430. */
  7431. reset(): void;
  7432. /**
  7433. * Concats the active data with a given array.
  7434. * This ensures no dupplicate will be present in the result.
  7435. * @param array defines the data to concatenate with.
  7436. */
  7437. concatWithNoDuplicate(array: any): void;
  7438. }
  7439. }
  7440. declare module "babylonjs/Materials/multiMaterial" {
  7441. import { Nullable } from "babylonjs/types";
  7442. import { Scene } from "babylonjs/scene";
  7443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7444. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7446. import { Material } from "babylonjs/Materials/material";
  7447. /**
  7448. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7449. * separate meshes. This can be use to improve performances.
  7450. * @see http://doc.babylonjs.com/how_to/multi_materials
  7451. */
  7452. export class MultiMaterial extends Material {
  7453. private _subMaterials;
  7454. /**
  7455. * Gets or Sets the list of Materials used within the multi material.
  7456. * They need to be ordered according to the submeshes order in the associated mesh
  7457. */
  7458. subMaterials: Nullable<Material>[];
  7459. /**
  7460. * Function used to align with Node.getChildren()
  7461. * @returns the list of Materials used within the multi material
  7462. */
  7463. getChildren(): Nullable<Material>[];
  7464. /**
  7465. * Instantiates a new Multi Material
  7466. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7467. * separate meshes. This can be use to improve performances.
  7468. * @see http://doc.babylonjs.com/how_to/multi_materials
  7469. * @param name Define the name in the scene
  7470. * @param scene Define the scene the material belongs to
  7471. */
  7472. constructor(name: string, scene: Scene);
  7473. private _hookArray;
  7474. /**
  7475. * Get one of the submaterial by its index in the submaterials array
  7476. * @param index The index to look the sub material at
  7477. * @returns The Material if the index has been defined
  7478. */
  7479. getSubMaterial(index: number): Nullable<Material>;
  7480. /**
  7481. * Get the list of active textures for the whole sub materials list.
  7482. * @returns All the textures that will be used during the rendering
  7483. */
  7484. getActiveTextures(): BaseTexture[];
  7485. /**
  7486. * Gets the current class name of the material e.g. "MultiMaterial"
  7487. * Mainly use in serialization.
  7488. * @returns the class name
  7489. */
  7490. getClassName(): string;
  7491. /**
  7492. * Checks if the material is ready to render the requested sub mesh
  7493. * @param mesh Define the mesh the submesh belongs to
  7494. * @param subMesh Define the sub mesh to look readyness for
  7495. * @param useInstances Define whether or not the material is used with instances
  7496. * @returns true if ready, otherwise false
  7497. */
  7498. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7499. /**
  7500. * Clones the current material and its related sub materials
  7501. * @param name Define the name of the newly cloned material
  7502. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7503. * @returns the cloned material
  7504. */
  7505. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7506. /**
  7507. * Serializes the materials into a JSON representation.
  7508. * @returns the JSON representation
  7509. */
  7510. serialize(): any;
  7511. /**
  7512. * Dispose the material and release its associated resources
  7513. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7514. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7515. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7516. */
  7517. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7518. /**
  7519. * Creates a MultiMaterial from parsed MultiMaterial data.
  7520. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7521. * @param scene defines the hosting scene
  7522. * @returns a new MultiMaterial
  7523. */
  7524. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7525. }
  7526. }
  7527. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7528. /**
  7529. * Class used to represent data loading progression
  7530. */
  7531. export class SceneLoaderFlags {
  7532. private static _ForceFullSceneLoadingForIncremental;
  7533. private static _ShowLoadingScreen;
  7534. private static _CleanBoneMatrixWeights;
  7535. private static _loggingLevel;
  7536. /**
  7537. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7538. */
  7539. static ForceFullSceneLoadingForIncremental: boolean;
  7540. /**
  7541. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7542. */
  7543. static ShowLoadingScreen: boolean;
  7544. /**
  7545. * Defines the current logging level (while loading the scene)
  7546. * @ignorenaming
  7547. */
  7548. static loggingLevel: number;
  7549. /**
  7550. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7551. */
  7552. static CleanBoneMatrixWeights: boolean;
  7553. }
  7554. }
  7555. declare module "babylonjs/Meshes/transformNode" {
  7556. import { DeepImmutable } from "babylonjs/types";
  7557. import { Observable } from "babylonjs/Misc/observable";
  7558. import { Nullable } from "babylonjs/types";
  7559. import { Camera } from "babylonjs/Cameras/camera";
  7560. import { Scene } from "babylonjs/scene";
  7561. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7562. import { Node } from "babylonjs/node";
  7563. import { Bone } from "babylonjs/Bones/bone";
  7564. /**
  7565. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  7566. * @see https://doc.babylonjs.com/how_to/transformnode
  7567. */
  7568. export class TransformNode extends Node {
  7569. /**
  7570. * Object will not rotate to face the camera
  7571. */
  7572. static BILLBOARDMODE_NONE: number;
  7573. /**
  7574. * Object will rotate to face the camera but only on the x axis
  7575. */
  7576. static BILLBOARDMODE_X: number;
  7577. /**
  7578. * Object will rotate to face the camera but only on the y axis
  7579. */
  7580. static BILLBOARDMODE_Y: number;
  7581. /**
  7582. * Object will rotate to face the camera but only on the z axis
  7583. */
  7584. static BILLBOARDMODE_Z: number;
  7585. /**
  7586. * Object will rotate to face the camera
  7587. */
  7588. static BILLBOARDMODE_ALL: number;
  7589. private _forward;
  7590. private _forwardInverted;
  7591. private _up;
  7592. private _right;
  7593. private _rightInverted;
  7594. private _position;
  7595. private _rotation;
  7596. private _rotationQuaternion;
  7597. protected _scaling: Vector3;
  7598. protected _isDirty: boolean;
  7599. private _transformToBoneReferal;
  7600. private _billboardMode;
  7601. /**
  7602. * Gets or sets the billboard mode. Default is 0.
  7603. *
  7604. * | Value | Type | Description |
  7605. * | --- | --- | --- |
  7606. * | 0 | BILLBOARDMODE_NONE | |
  7607. * | 1 | BILLBOARDMODE_X | |
  7608. * | 2 | BILLBOARDMODE_Y | |
  7609. * | 4 | BILLBOARDMODE_Z | |
  7610. * | 7 | BILLBOARDMODE_ALL | |
  7611. *
  7612. */
  7613. billboardMode: number;
  7614. private _preserveParentRotationForBillboard;
  7615. /**
  7616. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7617. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7618. */
  7619. preserveParentRotationForBillboard: boolean;
  7620. /**
  7621. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  7622. */
  7623. scalingDeterminant: number;
  7624. private _infiniteDistance;
  7625. /**
  7626. * Gets or sets the distance of the object to max, often used by skybox
  7627. */
  7628. infiniteDistance: boolean;
  7629. /**
  7630. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7631. * By default the system will update normals to compensate
  7632. */
  7633. ignoreNonUniformScaling: boolean;
  7634. /**
  7635. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7636. */
  7637. reIntegrateRotationIntoRotationQuaternion: boolean;
  7638. /** @hidden */
  7639. _poseMatrix: Nullable<Matrix>;
  7640. /** @hidden */
  7641. _localMatrix: Matrix;
  7642. private _usePivotMatrix;
  7643. private _absolutePosition;
  7644. private _pivotMatrix;
  7645. private _pivotMatrixInverse;
  7646. protected _postMultiplyPivotMatrix: boolean;
  7647. protected _isWorldMatrixFrozen: boolean;
  7648. /** @hidden */
  7649. _indexInSceneTransformNodesArray: number;
  7650. /**
  7651. * An event triggered after the world matrix is updated
  7652. */
  7653. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7654. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7655. /**
  7656. * Gets a string identifying the name of the class
  7657. * @returns "TransformNode" string
  7658. */
  7659. getClassName(): string;
  7660. /**
  7661. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7662. */
  7663. position: Vector3;
  7664. /**
  7665. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7666. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7667. */
  7668. rotation: Vector3;
  7669. /**
  7670. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7671. */
  7672. scaling: Vector3;
  7673. /**
  7674. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7675. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7676. */
  7677. rotationQuaternion: Nullable<Quaternion>;
  7678. /**
  7679. * The forward direction of that transform in world space.
  7680. */
  7681. readonly forward: Vector3;
  7682. /**
  7683. * The up direction of that transform in world space.
  7684. */
  7685. readonly up: Vector3;
  7686. /**
  7687. * The right direction of that transform in world space.
  7688. */
  7689. readonly right: Vector3;
  7690. /**
  7691. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7692. * @param matrix the matrix to copy the pose from
  7693. * @returns this TransformNode.
  7694. */
  7695. updatePoseMatrix(matrix: Matrix): TransformNode;
  7696. /**
  7697. * Returns the mesh Pose matrix.
  7698. * @returns the pose matrix
  7699. */
  7700. getPoseMatrix(): Matrix;
  7701. /** @hidden */
  7702. _isSynchronized(): boolean;
  7703. /** @hidden */
  7704. _initCache(): void;
  7705. /**
  7706. * Flag the transform node as dirty (Forcing it to update everything)
  7707. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7708. * @returns this transform node
  7709. */
  7710. markAsDirty(property: string): TransformNode;
  7711. /**
  7712. * Returns the current mesh absolute position.
  7713. * Returns a Vector3.
  7714. */
  7715. readonly absolutePosition: Vector3;
  7716. /**
  7717. * Sets a new matrix to apply before all other transformation
  7718. * @param matrix defines the transform matrix
  7719. * @returns the current TransformNode
  7720. */
  7721. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7722. /**
  7723. * Sets a new pivot matrix to the current node
  7724. * @param matrix defines the new pivot matrix to use
  7725. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  7726. * @returns the current TransformNode
  7727. */
  7728. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7729. /**
  7730. * Returns the mesh pivot matrix.
  7731. * Default : Identity.
  7732. * @returns the matrix
  7733. */
  7734. getPivotMatrix(): Matrix;
  7735. /**
  7736. * Prevents the World matrix to be computed any longer.
  7737. * @returns the TransformNode.
  7738. */
  7739. freezeWorldMatrix(): TransformNode;
  7740. /**
  7741. * Allows back the World matrix computation.
  7742. * @returns the TransformNode.
  7743. */
  7744. unfreezeWorldMatrix(): this;
  7745. /**
  7746. * True if the World matrix has been frozen.
  7747. */
  7748. readonly isWorldMatrixFrozen: boolean;
  7749. /**
  7750. * Retuns the mesh absolute position in the World.
  7751. * @returns a Vector3.
  7752. */
  7753. getAbsolutePosition(): Vector3;
  7754. /**
  7755. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7756. * @param absolutePosition the absolute position to set
  7757. * @returns the TransformNode.
  7758. */
  7759. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7760. /**
  7761. * Sets the mesh position in its local space.
  7762. * @param vector3 the position to set in localspace
  7763. * @returns the TransformNode.
  7764. */
  7765. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7766. /**
  7767. * Returns the mesh position in the local space from the current World matrix values.
  7768. * @returns a new Vector3.
  7769. */
  7770. getPositionExpressedInLocalSpace(): Vector3;
  7771. /**
  7772. * Translates the mesh along the passed Vector3 in its local space.
  7773. * @param vector3 the distance to translate in localspace
  7774. * @returns the TransformNode.
  7775. */
  7776. locallyTranslate(vector3: Vector3): TransformNode;
  7777. private static _lookAtVectorCache;
  7778. /**
  7779. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7780. * @param targetPoint the position (must be in same space as current mesh) to look at
  7781. * @param yawCor optional yaw (y-axis) correction in radians
  7782. * @param pitchCor optional pitch (x-axis) correction in radians
  7783. * @param rollCor optional roll (z-axis) correction in radians
  7784. * @param space the choosen space of the target
  7785. * @returns the TransformNode.
  7786. */
  7787. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7788. /**
  7789. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7790. * This Vector3 is expressed in the World space.
  7791. * @param localAxis axis to rotate
  7792. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7793. */
  7794. getDirection(localAxis: Vector3): Vector3;
  7795. /**
  7796. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7797. * localAxis is expressed in the mesh local space.
  7798. * result is computed in the Wordl space from the mesh World matrix.
  7799. * @param localAxis axis to rotate
  7800. * @param result the resulting transformnode
  7801. * @returns this TransformNode.
  7802. */
  7803. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7804. /**
  7805. * Sets this transform node rotation to the given local axis.
  7806. * @param localAxis the axis in local space
  7807. * @param yawCor optional yaw (y-axis) correction in radians
  7808. * @param pitchCor optional pitch (x-axis) correction in radians
  7809. * @param rollCor optional roll (z-axis) correction in radians
  7810. * @returns this TransformNode
  7811. */
  7812. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7813. /**
  7814. * Sets a new pivot point to the current node
  7815. * @param point defines the new pivot point to use
  7816. * @param space defines if the point is in world or local space (local by default)
  7817. * @returns the current TransformNode
  7818. */
  7819. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7820. /**
  7821. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7822. * @returns the pivot point
  7823. */
  7824. getPivotPoint(): Vector3;
  7825. /**
  7826. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7827. * @param result the vector3 to store the result
  7828. * @returns this TransformNode.
  7829. */
  7830. getPivotPointToRef(result: Vector3): TransformNode;
  7831. /**
  7832. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7833. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7834. */
  7835. getAbsolutePivotPoint(): Vector3;
  7836. /**
  7837. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7838. * @param result vector3 to store the result
  7839. * @returns this TransformNode.
  7840. */
  7841. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7842. /**
  7843. * Defines the passed node as the parent of the current node.
  7844. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7845. * @see https://doc.babylonjs.com/how_to/parenting
  7846. * @param node the node ot set as the parent
  7847. * @returns this TransformNode.
  7848. */
  7849. setParent(node: Nullable<Node>): TransformNode;
  7850. private _nonUniformScaling;
  7851. /**
  7852. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7853. */
  7854. readonly nonUniformScaling: boolean;
  7855. /** @hidden */
  7856. _updateNonUniformScalingState(value: boolean): boolean;
  7857. /**
  7858. * Attach the current TransformNode to another TransformNode associated with a bone
  7859. * @param bone Bone affecting the TransformNode
  7860. * @param affectedTransformNode TransformNode associated with the bone
  7861. * @returns this object
  7862. */
  7863. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7864. /**
  7865. * Detach the transform node if its associated with a bone
  7866. * @returns this object
  7867. */
  7868. detachFromBone(): TransformNode;
  7869. private static _rotationAxisCache;
  7870. /**
  7871. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7872. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7873. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7874. * The passed axis is also normalized.
  7875. * @param axis the axis to rotate around
  7876. * @param amount the amount to rotate in radians
  7877. * @param space Space to rotate in (Default: local)
  7878. * @returns the TransformNode.
  7879. */
  7880. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7881. /**
  7882. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7883. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7884. * The passed axis is also normalized. .
  7885. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7886. * @param point the point to rotate around
  7887. * @param axis the axis to rotate around
  7888. * @param amount the amount to rotate in radians
  7889. * @returns the TransformNode
  7890. */
  7891. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7892. /**
  7893. * Translates the mesh along the axis vector for the passed distance in the given space.
  7894. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7895. * @param axis the axis to translate in
  7896. * @param distance the distance to translate
  7897. * @param space Space to rotate in (Default: local)
  7898. * @returns the TransformNode.
  7899. */
  7900. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7901. /**
  7902. * Adds a rotation step to the mesh current rotation.
  7903. * x, y, z are Euler angles expressed in radians.
  7904. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7905. * This means this rotation is made in the mesh local space only.
  7906. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7907. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7908. * ```javascript
  7909. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7910. * ```
  7911. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7912. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  7913. * @param x Rotation to add
  7914. * @param y Rotation to add
  7915. * @param z Rotation to add
  7916. * @returns the TransformNode.
  7917. */
  7918. addRotation(x: number, y: number, z: number): TransformNode;
  7919. /**
  7920. * @hidden
  7921. */
  7922. protected _getEffectiveParent(): Nullable<Node>;
  7923. /**
  7924. * Computes the world matrix of the node
  7925. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7926. * @returns the world matrix
  7927. */
  7928. computeWorldMatrix(force?: boolean): Matrix;
  7929. protected _afterComputeWorldMatrix(): void;
  7930. /**
  7931. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7932. * @param func callback function to add
  7933. *
  7934. * @returns the TransformNode.
  7935. */
  7936. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7937. /**
  7938. * Removes a registered callback function.
  7939. * @param func callback function to remove
  7940. * @returns the TransformNode.
  7941. */
  7942. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7943. /**
  7944. * Gets the position of the current mesh in camera space
  7945. * @param camera defines the camera to use
  7946. * @returns a position
  7947. */
  7948. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7949. /**
  7950. * Returns the distance from the mesh to the active camera
  7951. * @param camera defines the camera to use
  7952. * @returns the distance
  7953. */
  7954. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7955. /**
  7956. * Clone the current transform node
  7957. * @param name Name of the new clone
  7958. * @param newParent New parent for the clone
  7959. * @param doNotCloneChildren Do not clone children hierarchy
  7960. * @returns the new transform node
  7961. */
  7962. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7963. /**
  7964. * Serializes the objects information.
  7965. * @param currentSerializationObject defines the object to serialize in
  7966. * @returns the serialized object
  7967. */
  7968. serialize(currentSerializationObject?: any): any;
  7969. /**
  7970. * Returns a new TransformNode object parsed from the source provided.
  7971. * @param parsedTransformNode is the source.
  7972. * @param scene the scne the object belongs to
  7973. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7974. * @returns a new TransformNode object parsed from the source provided.
  7975. */
  7976. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7977. /**
  7978. * Get all child-transformNodes of this node
  7979. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  7980. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  7981. * @returns an array of TransformNode
  7982. */
  7983. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7984. /**
  7985. * Releases resources associated with this transform node.
  7986. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7987. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7988. */
  7989. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7990. }
  7991. }
  7992. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7993. /**
  7994. * Class used to override all child animations of a given target
  7995. */
  7996. export class AnimationPropertiesOverride {
  7997. /**
  7998. * Gets or sets a value indicating if animation blending must be used
  7999. */
  8000. enableBlending: boolean;
  8001. /**
  8002. * Gets or sets the blending speed to use when enableBlending is true
  8003. */
  8004. blendingSpeed: number;
  8005. /**
  8006. * Gets or sets the default loop mode to use
  8007. */
  8008. loopMode: number;
  8009. }
  8010. }
  8011. declare module "babylonjs/Bones/bone" {
  8012. import { Skeleton } from "babylonjs/Bones/skeleton";
  8013. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8014. import { Nullable } from "babylonjs/types";
  8015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8016. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8017. import { Node } from "babylonjs/node";
  8018. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8019. /**
  8020. * Class used to store bone information
  8021. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8022. */
  8023. export class Bone extends Node {
  8024. /**
  8025. * defines the bone name
  8026. */
  8027. name: string;
  8028. private static _tmpVecs;
  8029. private static _tmpQuat;
  8030. private static _tmpMats;
  8031. /**
  8032. * Gets the list of child bones
  8033. */
  8034. children: Bone[];
  8035. /** Gets the animations associated with this bone */
  8036. animations: import("babylonjs/Animations/animation").Animation[];
  8037. /**
  8038. * Gets or sets bone length
  8039. */
  8040. length: number;
  8041. /**
  8042. * @hidden Internal only
  8043. * Set this value to map this bone to a different index in the transform matrices
  8044. * Set this value to -1 to exclude the bone from the transform matrices
  8045. */
  8046. _index: Nullable<number>;
  8047. private _skeleton;
  8048. private _localMatrix;
  8049. private _restPose;
  8050. private _baseMatrix;
  8051. private _absoluteTransform;
  8052. private _invertedAbsoluteTransform;
  8053. private _parent;
  8054. private _scalingDeterminant;
  8055. private _worldTransform;
  8056. private _localScaling;
  8057. private _localRotation;
  8058. private _localPosition;
  8059. private _needToDecompose;
  8060. private _needToCompose;
  8061. /** @hidden */
  8062. _linkedTransformNode: Nullable<TransformNode>;
  8063. /** @hidden */
  8064. /** @hidden */
  8065. _matrix: Matrix;
  8066. /**
  8067. * Create a new bone
  8068. * @param name defines the bone name
  8069. * @param skeleton defines the parent skeleton
  8070. * @param parentBone defines the parent (can be null if the bone is the root)
  8071. * @param localMatrix defines the local matrix
  8072. * @param restPose defines the rest pose matrix
  8073. * @param baseMatrix defines the base matrix
  8074. * @param index defines index of the bone in the hiearchy
  8075. */
  8076. constructor(
  8077. /**
  8078. * defines the bone name
  8079. */
  8080. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8081. /**
  8082. * Gets the current object class name.
  8083. * @return the class name
  8084. */
  8085. getClassName(): string;
  8086. /**
  8087. * Gets the parent skeleton
  8088. * @returns a skeleton
  8089. */
  8090. getSkeleton(): Skeleton;
  8091. /**
  8092. * Gets parent bone
  8093. * @returns a bone or null if the bone is the root of the bone hierarchy
  8094. */
  8095. getParent(): Nullable<Bone>;
  8096. /**
  8097. * Returns an array containing the root bones
  8098. * @returns an array containing the root bones
  8099. */
  8100. getChildren(): Array<Bone>;
  8101. /**
  8102. * Sets the parent bone
  8103. * @param parent defines the parent (can be null if the bone is the root)
  8104. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8105. */
  8106. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8107. /**
  8108. * Gets the local matrix
  8109. * @returns a matrix
  8110. */
  8111. getLocalMatrix(): Matrix;
  8112. /**
  8113. * Gets the base matrix (initial matrix which remains unchanged)
  8114. * @returns a matrix
  8115. */
  8116. getBaseMatrix(): Matrix;
  8117. /**
  8118. * Gets the rest pose matrix
  8119. * @returns a matrix
  8120. */
  8121. getRestPose(): Matrix;
  8122. /**
  8123. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8124. */
  8125. getWorldMatrix(): Matrix;
  8126. /**
  8127. * Sets the local matrix to rest pose matrix
  8128. */
  8129. returnToRest(): void;
  8130. /**
  8131. * Gets the inverse of the absolute transform matrix.
  8132. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8133. * @returns a matrix
  8134. */
  8135. getInvertedAbsoluteTransform(): Matrix;
  8136. /**
  8137. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8138. * @returns a matrix
  8139. */
  8140. getAbsoluteTransform(): Matrix;
  8141. /**
  8142. * Links with the given transform node.
  8143. * The local matrix of this bone is copied from the transform node every frame.
  8144. * @param transformNode defines the transform node to link to
  8145. */
  8146. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8147. /** Gets or sets current position (in local space) */
  8148. position: Vector3;
  8149. /** Gets or sets current rotation (in local space) */
  8150. rotation: Vector3;
  8151. /** Gets or sets current rotation quaternion (in local space) */
  8152. rotationQuaternion: Quaternion;
  8153. /** Gets or sets current scaling (in local space) */
  8154. scaling: Vector3;
  8155. /**
  8156. * Gets the animation properties override
  8157. */
  8158. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8159. private _decompose;
  8160. private _compose;
  8161. /**
  8162. * Update the base and local matrices
  8163. * @param matrix defines the new base or local matrix
  8164. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8165. * @param updateLocalMatrix defines if the local matrix should be updated
  8166. */
  8167. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8168. /** @hidden */
  8169. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8170. /**
  8171. * Flag the bone as dirty (Forcing it to update everything)
  8172. */
  8173. markAsDirty(): void;
  8174. private _markAsDirtyAndCompose;
  8175. private _markAsDirtyAndDecompose;
  8176. /**
  8177. * Translate the bone in local or world space
  8178. * @param vec The amount to translate the bone
  8179. * @param space The space that the translation is in
  8180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8181. */
  8182. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8183. /**
  8184. * Set the postion of the bone in local or world space
  8185. * @param position The position to set the bone
  8186. * @param space The space that the position is in
  8187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8188. */
  8189. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8190. /**
  8191. * Set the absolute position of the bone (world space)
  8192. * @param position The position to set the bone
  8193. * @param mesh The mesh that this bone is attached to
  8194. */
  8195. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8196. /**
  8197. * Scale the bone on the x, y and z axes (in local space)
  8198. * @param x The amount to scale the bone on the x axis
  8199. * @param y The amount to scale the bone on the y axis
  8200. * @param z The amount to scale the bone on the z axis
  8201. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8202. */
  8203. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8204. /**
  8205. * Set the bone scaling in local space
  8206. * @param scale defines the scaling vector
  8207. */
  8208. setScale(scale: Vector3): void;
  8209. /**
  8210. * Gets the current scaling in local space
  8211. * @returns the current scaling vector
  8212. */
  8213. getScale(): Vector3;
  8214. /**
  8215. * Gets the current scaling in local space and stores it in a target vector
  8216. * @param result defines the target vector
  8217. */
  8218. getScaleToRef(result: Vector3): void;
  8219. /**
  8220. * Set the yaw, pitch, and roll of the bone in local or world space
  8221. * @param yaw The rotation of the bone on the y axis
  8222. * @param pitch The rotation of the bone on the x axis
  8223. * @param roll The rotation of the bone on the z axis
  8224. * @param space The space that the axes of rotation are in
  8225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8226. */
  8227. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8228. /**
  8229. * Add a rotation to the bone on an axis in local or world space
  8230. * @param axis The axis to rotate the bone on
  8231. * @param amount The amount to rotate the bone
  8232. * @param space The space that the axis is in
  8233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8234. */
  8235. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8236. /**
  8237. * Set the rotation of the bone to a particular axis angle in local or world space
  8238. * @param axis The axis to rotate the bone on
  8239. * @param angle The angle that the bone should be rotated to
  8240. * @param space The space that the axis is in
  8241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8242. */
  8243. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8244. /**
  8245. * Set the euler rotation of the bone in local of world space
  8246. * @param rotation The euler rotation that the bone should be set to
  8247. * @param space The space that the rotation is in
  8248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8249. */
  8250. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8251. /**
  8252. * Set the quaternion rotation of the bone in local of world space
  8253. * @param quat The quaternion rotation that the bone should be set to
  8254. * @param space The space that the rotation is in
  8255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8256. */
  8257. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8258. /**
  8259. * Set the rotation matrix of the bone in local of world space
  8260. * @param rotMat The rotation matrix that the bone should be set to
  8261. * @param space The space that the rotation is in
  8262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8263. */
  8264. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8265. private _rotateWithMatrix;
  8266. private _getNegativeRotationToRef;
  8267. /**
  8268. * Get the position of the bone in local or world space
  8269. * @param space The space that the returned position is in
  8270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8271. * @returns The position of the bone
  8272. */
  8273. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8274. /**
  8275. * Copy the position of the bone to a vector3 in local or world space
  8276. * @param space The space that the returned position is in
  8277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8278. * @param result The vector3 to copy the position to
  8279. */
  8280. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8281. /**
  8282. * Get the absolute position of the bone (world space)
  8283. * @param mesh The mesh that this bone is attached to
  8284. * @returns The absolute position of the bone
  8285. */
  8286. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8287. /**
  8288. * Copy the absolute position of the bone (world space) to the result param
  8289. * @param mesh The mesh that this bone is attached to
  8290. * @param result The vector3 to copy the absolute position to
  8291. */
  8292. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8293. /**
  8294. * Compute the absolute transforms of this bone and its children
  8295. */
  8296. computeAbsoluteTransforms(): void;
  8297. /**
  8298. * Get the world direction from an axis that is in the local space of the bone
  8299. * @param localAxis The local direction that is used to compute the world direction
  8300. * @param mesh The mesh that this bone is attached to
  8301. * @returns The world direction
  8302. */
  8303. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8304. /**
  8305. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8306. * @param localAxis The local direction that is used to compute the world direction
  8307. * @param mesh The mesh that this bone is attached to
  8308. * @param result The vector3 that the world direction will be copied to
  8309. */
  8310. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8311. /**
  8312. * Get the euler rotation of the bone in local or world space
  8313. * @param space The space that the rotation should be in
  8314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8315. * @returns The euler rotation
  8316. */
  8317. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8318. /**
  8319. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8320. * @param space The space that the rotation should be in
  8321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8322. * @param result The vector3 that the rotation should be copied to
  8323. */
  8324. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8325. /**
  8326. * Get the quaternion rotation of the bone in either local or world space
  8327. * @param space The space that the rotation should be in
  8328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8329. * @returns The quaternion rotation
  8330. */
  8331. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8332. /**
  8333. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8334. * @param space The space that the rotation should be in
  8335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8336. * @param result The quaternion that the rotation should be copied to
  8337. */
  8338. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8339. /**
  8340. * Get the rotation matrix of the bone in local or world space
  8341. * @param space The space that the rotation should be in
  8342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8343. * @returns The rotation matrix
  8344. */
  8345. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8346. /**
  8347. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8348. * @param space The space that the rotation should be in
  8349. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8350. * @param result The quaternion that the rotation should be copied to
  8351. */
  8352. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8353. /**
  8354. * Get the world position of a point that is in the local space of the bone
  8355. * @param position The local position
  8356. * @param mesh The mesh that this bone is attached to
  8357. * @returns The world position
  8358. */
  8359. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8360. /**
  8361. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8362. * @param position The local position
  8363. * @param mesh The mesh that this bone is attached to
  8364. * @param result The vector3 that the world position should be copied to
  8365. */
  8366. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8367. /**
  8368. * Get the local position of a point that is in world space
  8369. * @param position The world position
  8370. * @param mesh The mesh that this bone is attached to
  8371. * @returns The local position
  8372. */
  8373. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8374. /**
  8375. * Get the local position of a point that is in world space and copy it to the result param
  8376. * @param position The world position
  8377. * @param mesh The mesh that this bone is attached to
  8378. * @param result The vector3 that the local position should be copied to
  8379. */
  8380. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8381. }
  8382. }
  8383. declare module "babylonjs/Misc/iInspectable" {
  8384. /**
  8385. * Enum that determines the text-wrapping mode to use.
  8386. */
  8387. export enum InspectableType {
  8388. /**
  8389. * Checkbox for booleans
  8390. */
  8391. Checkbox = 0,
  8392. /**
  8393. * Sliders for numbers
  8394. */
  8395. Slider = 1,
  8396. /**
  8397. * Vector3
  8398. */
  8399. Vector3 = 2,
  8400. /**
  8401. * Quaternions
  8402. */
  8403. Quaternion = 3,
  8404. /**
  8405. * Color3
  8406. */
  8407. Color3 = 4
  8408. }
  8409. /**
  8410. * Interface used to define custom inspectable properties.
  8411. * This interface is used by the inspector to display custom property grids
  8412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8413. */
  8414. export interface IInspectable {
  8415. /**
  8416. * Gets the label to display
  8417. */
  8418. label: string;
  8419. /**
  8420. * Gets the name of the property to edit
  8421. */
  8422. propertyName: string;
  8423. /**
  8424. * Gets the type of the editor to use
  8425. */
  8426. type: InspectableType;
  8427. /**
  8428. * Gets the minimum value of the property when using in "slider" mode
  8429. */
  8430. min?: number;
  8431. /**
  8432. * Gets the maximum value of the property when using in "slider" mode
  8433. */
  8434. max?: number;
  8435. /**
  8436. * Gets the setp to use when using in "slider" mode
  8437. */
  8438. step?: number;
  8439. }
  8440. }
  8441. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8442. import { Nullable } from "babylonjs/types";
  8443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8444. /**
  8445. * This represents the required contract to create a new type of texture loader.
  8446. */
  8447. export interface IInternalTextureLoader {
  8448. /**
  8449. * Defines wether the loader supports cascade loading the different faces.
  8450. */
  8451. supportCascades: boolean;
  8452. /**
  8453. * This returns if the loader support the current file information.
  8454. * @param extension defines the file extension of the file being loaded
  8455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8456. * @param fallback defines the fallback internal texture if any
  8457. * @param isBase64 defines whether the texture is encoded as a base64
  8458. * @param isBuffer defines whether the texture data are stored as a buffer
  8459. * @returns true if the loader can load the specified file
  8460. */
  8461. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8462. /**
  8463. * Transform the url before loading if required.
  8464. * @param rootUrl the url of the texture
  8465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8466. * @returns the transformed texture
  8467. */
  8468. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8469. /**
  8470. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8471. * @param rootUrl the url of the texture
  8472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8473. * @returns the fallback texture
  8474. */
  8475. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8476. /**
  8477. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8478. * @param data contains the texture data
  8479. * @param texture defines the BabylonJS internal texture
  8480. * @param createPolynomials will be true if polynomials have been requested
  8481. * @param onLoad defines the callback to trigger once the texture is ready
  8482. * @param onError defines the callback to trigger in case of error
  8483. */
  8484. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8485. /**
  8486. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8487. * @param data contains the texture data
  8488. * @param texture defines the BabylonJS internal texture
  8489. * @param callback defines the method to call once ready to upload
  8490. */
  8491. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8492. }
  8493. }
  8494. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8496. import { Nullable } from "babylonjs/types";
  8497. import { Scene } from "babylonjs/scene";
  8498. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8499. module "babylonjs/Engines/engine" {
  8500. interface Engine {
  8501. /**
  8502. * Creates a depth stencil cube texture.
  8503. * This is only available in WebGL 2.
  8504. * @param size The size of face edge in the cube texture.
  8505. * @param options The options defining the cube texture.
  8506. * @returns The cube texture
  8507. */
  8508. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8509. /**
  8510. * Creates a cube texture
  8511. * @param rootUrl defines the url where the files to load is located
  8512. * @param scene defines the current scene
  8513. * @param files defines the list of files to load (1 per face)
  8514. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8515. * @param onLoad defines an optional callback raised when the texture is loaded
  8516. * @param onError defines an optional callback raised if there is an issue to load the texture
  8517. * @param format defines the format of the data
  8518. * @param forcedExtension defines the extension to use to pick the right loader
  8519. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8520. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8521. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8522. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8523. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8524. * @returns the cube texture as an InternalTexture
  8525. */
  8526. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8527. /**
  8528. * Creates a cube texture
  8529. * @param rootUrl defines the url where the files to load is located
  8530. * @param scene defines the current scene
  8531. * @param files defines the list of files to load (1 per face)
  8532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8533. * @param onLoad defines an optional callback raised when the texture is loaded
  8534. * @param onError defines an optional callback raised if there is an issue to load the texture
  8535. * @param format defines the format of the data
  8536. * @param forcedExtension defines the extension to use to pick the right loader
  8537. * @returns the cube texture as an InternalTexture
  8538. */
  8539. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  8540. /**
  8541. * Creates a cube texture
  8542. * @param rootUrl defines the url where the files to load is located
  8543. * @param scene defines the current scene
  8544. * @param files defines the list of files to load (1 per face)
  8545. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8546. * @param onLoad defines an optional callback raised when the texture is loaded
  8547. * @param onError defines an optional callback raised if there is an issue to load the texture
  8548. * @param format defines the format of the data
  8549. * @param forcedExtension defines the extension to use to pick the right loader
  8550. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8551. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8552. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8553. * @returns the cube texture as an InternalTexture
  8554. */
  8555. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8556. /** @hidden */
  8557. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8558. /** @hidden */
  8559. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8560. /** @hidden */
  8561. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8562. /** @hidden */
  8563. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8564. }
  8565. }
  8566. }
  8567. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8568. import { Nullable } from "babylonjs/types";
  8569. import { Scene } from "babylonjs/scene";
  8570. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8572. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8573. /**
  8574. * Class for creating a cube texture
  8575. */
  8576. export class CubeTexture extends BaseTexture {
  8577. private _delayedOnLoad;
  8578. /**
  8579. * The url of the texture
  8580. */
  8581. url: string;
  8582. /**
  8583. * Gets or sets the center of the bounding box associated with the cube texture.
  8584. * It must define where the camera used to render the texture was set
  8585. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8586. */
  8587. boundingBoxPosition: Vector3;
  8588. private _boundingBoxSize;
  8589. /**
  8590. * Gets or sets the size of the bounding box associated with the cube texture
  8591. * When defined, the cubemap will switch to local mode
  8592. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8593. * @example https://www.babylonjs-playground.com/#RNASML
  8594. */
  8595. /**
  8596. * Returns the bounding box size
  8597. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8598. */
  8599. boundingBoxSize: Vector3;
  8600. protected _rotationY: number;
  8601. /**
  8602. * Sets texture matrix rotation angle around Y axis in radians.
  8603. */
  8604. /**
  8605. * Gets texture matrix rotation angle around Y axis radians.
  8606. */
  8607. rotationY: number;
  8608. /**
  8609. * Are mip maps generated for this texture or not.
  8610. */
  8611. readonly noMipmap: boolean;
  8612. private _noMipmap;
  8613. private _files;
  8614. private _extensions;
  8615. private _textureMatrix;
  8616. private _format;
  8617. private _createPolynomials;
  8618. /** @hidden */
  8619. _prefiltered: boolean;
  8620. /**
  8621. * Creates a cube texture from an array of image urls
  8622. * @param files defines an array of image urls
  8623. * @param scene defines the hosting scene
  8624. * @param noMipmap specifies if mip maps are not used
  8625. * @returns a cube texture
  8626. */
  8627. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8628. /**
  8629. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8630. * @param url defines the url of the prefiltered texture
  8631. * @param scene defines the scene the texture is attached to
  8632. * @param forcedExtension defines the extension of the file if different from the url
  8633. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8634. * @return the prefiltered texture
  8635. */
  8636. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8637. /**
  8638. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8639. * as prefiltered data.
  8640. * @param rootUrl defines the url of the texture or the root name of the six images
  8641. * @param scene defines the scene the texture is attached to
  8642. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8643. * @param noMipmap defines if mipmaps should be created or not
  8644. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8645. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8646. * @param onError defines a callback triggered in case of error during load
  8647. * @param format defines the internal format to use for the texture once loaded
  8648. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8649. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8650. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8651. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8652. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8653. * @return the cube texture
  8654. */
  8655. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  8656. /**
  8657. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8658. */
  8659. readonly isPrefiltered: boolean;
  8660. /**
  8661. * Get the current class name of the texture useful for serialization or dynamic coding.
  8662. * @returns "CubeTexture"
  8663. */
  8664. getClassName(): string;
  8665. /**
  8666. * Update the url (and optional buffer) of this texture if url was null during construction.
  8667. * @param url the url of the texture
  8668. * @param forcedExtension defines the extension to use
  8669. * @param onLoad callback called when the texture is loaded (defaults to null)
  8670. */
  8671. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8672. /**
  8673. * Delays loading of the cube texture
  8674. * @param forcedExtension defines the extension to use
  8675. */
  8676. delayLoad(forcedExtension?: string): void;
  8677. /**
  8678. * Returns the reflection texture matrix
  8679. * @returns the reflection texture matrix
  8680. */
  8681. getReflectionTextureMatrix(): Matrix;
  8682. /**
  8683. * Sets the reflection texture matrix
  8684. * @param value Reflection texture matrix
  8685. */
  8686. setReflectionTextureMatrix(value: Matrix): void;
  8687. /**
  8688. * Parses text to create a cube texture
  8689. * @param parsedTexture define the serialized text to read from
  8690. * @param scene defines the hosting scene
  8691. * @param rootUrl defines the root url of the cube texture
  8692. * @returns a cube texture
  8693. */
  8694. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8695. /**
  8696. * Makes a clone, or deep copy, of the cube texture
  8697. * @returns a new cube texture
  8698. */
  8699. clone(): CubeTexture;
  8700. }
  8701. }
  8702. declare module "babylonjs/Shaders/postprocess.vertex" {
  8703. /** @hidden */
  8704. export var postprocessVertexShader: {
  8705. name: string;
  8706. shader: string;
  8707. };
  8708. }
  8709. declare module "babylonjs/Cameras/targetCamera" {
  8710. import { Nullable } from "babylonjs/types";
  8711. import { Camera } from "babylonjs/Cameras/camera";
  8712. import { Scene } from "babylonjs/scene";
  8713. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8714. /**
  8715. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8716. * This is the base of the follow, arc rotate cameras and Free camera
  8717. * @see http://doc.babylonjs.com/features/cameras
  8718. */
  8719. export class TargetCamera extends Camera {
  8720. private static _RigCamTransformMatrix;
  8721. private static _TargetTransformMatrix;
  8722. private static _TargetFocalPoint;
  8723. /**
  8724. * Define the current direction the camera is moving to
  8725. */
  8726. cameraDirection: Vector3;
  8727. /**
  8728. * Define the current rotation the camera is rotating to
  8729. */
  8730. cameraRotation: Vector2;
  8731. /**
  8732. * When set, the up vector of the camera will be updated by the rotation of the camera
  8733. */
  8734. updateUpVectorFromRotation: boolean;
  8735. private _tmpQuaternion;
  8736. /**
  8737. * Define the current rotation of the camera
  8738. */
  8739. rotation: Vector3;
  8740. /**
  8741. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8742. */
  8743. rotationQuaternion: Quaternion;
  8744. /**
  8745. * Define the current speed of the camera
  8746. */
  8747. speed: number;
  8748. /**
  8749. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8750. * around all axis.
  8751. */
  8752. noRotationConstraint: boolean;
  8753. /**
  8754. * Define the current target of the camera as an object or a position.
  8755. */
  8756. lockedTarget: any;
  8757. /** @hidden */
  8758. _currentTarget: Vector3;
  8759. /** @hidden */
  8760. _initialFocalDistance: number;
  8761. /** @hidden */
  8762. _viewMatrix: Matrix;
  8763. /** @hidden */
  8764. _camMatrix: Matrix;
  8765. /** @hidden */
  8766. _cameraTransformMatrix: Matrix;
  8767. /** @hidden */
  8768. _cameraRotationMatrix: Matrix;
  8769. /** @hidden */
  8770. _referencePoint: Vector3;
  8771. /** @hidden */
  8772. _transformedReferencePoint: Vector3;
  8773. protected _globalCurrentTarget: Vector3;
  8774. protected _globalCurrentUpVector: Vector3;
  8775. /** @hidden */
  8776. _reset: () => void;
  8777. private _defaultUp;
  8778. /**
  8779. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8780. * This is the base of the follow, arc rotate cameras and Free camera
  8781. * @see http://doc.babylonjs.com/features/cameras
  8782. * @param name Defines the name of the camera in the scene
  8783. * @param position Defines the start position of the camera in the scene
  8784. * @param scene Defines the scene the camera belongs to
  8785. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8786. */
  8787. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8788. /**
  8789. * Gets the position in front of the camera at a given distance.
  8790. * @param distance The distance from the camera we want the position to be
  8791. * @returns the position
  8792. */
  8793. getFrontPosition(distance: number): Vector3;
  8794. /** @hidden */
  8795. _getLockedTargetPosition(): Nullable<Vector3>;
  8796. private _storedPosition;
  8797. private _storedRotation;
  8798. private _storedRotationQuaternion;
  8799. /**
  8800. * Store current camera state of the camera (fov, position, rotation, etc..)
  8801. * @returns the camera
  8802. */
  8803. storeState(): Camera;
  8804. /**
  8805. * Restored camera state. You must call storeState() first
  8806. * @returns whether it was successful or not
  8807. * @hidden
  8808. */
  8809. _restoreStateValues(): boolean;
  8810. /** @hidden */
  8811. _initCache(): void;
  8812. /** @hidden */
  8813. _updateCache(ignoreParentClass?: boolean): void;
  8814. /** @hidden */
  8815. _isSynchronizedViewMatrix(): boolean;
  8816. /** @hidden */
  8817. _computeLocalCameraSpeed(): number;
  8818. /**
  8819. * Defines the target the camera should look at.
  8820. * This will automatically adapt alpha beta and radius to fit within the new target.
  8821. * @param target Defines the new target as a Vector or a mesh
  8822. */
  8823. setTarget(target: Vector3): void;
  8824. /**
  8825. * Return the current target position of the camera. This value is expressed in local space.
  8826. * @returns the target position
  8827. */
  8828. getTarget(): Vector3;
  8829. /** @hidden */
  8830. _decideIfNeedsToMove(): boolean;
  8831. /** @hidden */
  8832. _updatePosition(): void;
  8833. /** @hidden */
  8834. _checkInputs(): void;
  8835. protected _updateCameraRotationMatrix(): void;
  8836. /**
  8837. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8838. * @returns the current camera
  8839. */
  8840. private _rotateUpVectorWithCameraRotationMatrix;
  8841. private _cachedRotationZ;
  8842. private _cachedQuaternionRotationZ;
  8843. /** @hidden */
  8844. _getViewMatrix(): Matrix;
  8845. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8846. /**
  8847. * @hidden
  8848. */
  8849. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8850. /**
  8851. * @hidden
  8852. */
  8853. _updateRigCameras(): void;
  8854. private _getRigCamPositionAndTarget;
  8855. /**
  8856. * Gets the current object class name.
  8857. * @return the class name
  8858. */
  8859. getClassName(): string;
  8860. }
  8861. }
  8862. declare module "babylonjs/Cameras/cameraInputsManager" {
  8863. import { Nullable } from "babylonjs/types";
  8864. import { Camera } from "babylonjs/Cameras/camera";
  8865. /**
  8866. * @ignore
  8867. * This is a list of all the different input types that are available in the application.
  8868. * Fo instance: ArcRotateCameraGamepadInput...
  8869. */
  8870. export var CameraInputTypes: {};
  8871. /**
  8872. * This is the contract to implement in order to create a new input class.
  8873. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8874. */
  8875. export interface ICameraInput<TCamera extends Camera> {
  8876. /**
  8877. * Defines the camera the input is attached to.
  8878. */
  8879. camera: Nullable<TCamera>;
  8880. /**
  8881. * Gets the class name of the current intput.
  8882. * @returns the class name
  8883. */
  8884. getClassName(): string;
  8885. /**
  8886. * Get the friendly name associated with the input class.
  8887. * @returns the input friendly name
  8888. */
  8889. getSimpleName(): string;
  8890. /**
  8891. * Attach the input controls to a specific dom element to get the input from.
  8892. * @param element Defines the element the controls should be listened from
  8893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8894. */
  8895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8896. /**
  8897. * Detach the current controls from the specified dom element.
  8898. * @param element Defines the element to stop listening the inputs from
  8899. */
  8900. detachControl(element: Nullable<HTMLElement>): void;
  8901. /**
  8902. * Update the current camera state depending on the inputs that have been used this frame.
  8903. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8904. */
  8905. checkInputs?: () => void;
  8906. }
  8907. /**
  8908. * Represents a map of input types to input instance or input index to input instance.
  8909. */
  8910. export interface CameraInputsMap<TCamera extends Camera> {
  8911. /**
  8912. * Accessor to the input by input type.
  8913. */
  8914. [name: string]: ICameraInput<TCamera>;
  8915. /**
  8916. * Accessor to the input by input index.
  8917. */
  8918. [idx: number]: ICameraInput<TCamera>;
  8919. }
  8920. /**
  8921. * This represents the input manager used within a camera.
  8922. * It helps dealing with all the different kind of input attached to a camera.
  8923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8924. */
  8925. export class CameraInputsManager<TCamera extends Camera> {
  8926. /**
  8927. * Defines the list of inputs attahed to the camera.
  8928. */
  8929. attached: CameraInputsMap<TCamera>;
  8930. /**
  8931. * Defines the dom element the camera is collecting inputs from.
  8932. * This is null if the controls have not been attached.
  8933. */
  8934. attachedElement: Nullable<HTMLElement>;
  8935. /**
  8936. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8937. */
  8938. noPreventDefault: boolean;
  8939. /**
  8940. * Defined the camera the input manager belongs to.
  8941. */
  8942. camera: TCamera;
  8943. /**
  8944. * Update the current camera state depending on the inputs that have been used this frame.
  8945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8946. */
  8947. checkInputs: () => void;
  8948. /**
  8949. * Instantiate a new Camera Input Manager.
  8950. * @param camera Defines the camera the input manager blongs to
  8951. */
  8952. constructor(camera: TCamera);
  8953. /**
  8954. * Add an input method to a camera
  8955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8956. * @param input camera input method
  8957. */
  8958. add(input: ICameraInput<TCamera>): void;
  8959. /**
  8960. * Remove a specific input method from a camera
  8961. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8962. * @param inputToRemove camera input method
  8963. */
  8964. remove(inputToRemove: ICameraInput<TCamera>): void;
  8965. /**
  8966. * Remove a specific input type from a camera
  8967. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8968. * @param inputType the type of the input to remove
  8969. */
  8970. removeByType(inputType: string): void;
  8971. private _addCheckInputs;
  8972. /**
  8973. * Attach the input controls to the currently attached dom element to listen the events from.
  8974. * @param input Defines the input to attach
  8975. */
  8976. attachInput(input: ICameraInput<TCamera>): void;
  8977. /**
  8978. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8979. * @param element Defines the dom element to collect the events from
  8980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8981. */
  8982. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8983. /**
  8984. * Detach the current manager inputs controls from a specific dom element.
  8985. * @param element Defines the dom element to collect the events from
  8986. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8987. */
  8988. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8989. /**
  8990. * Rebuild the dynamic inputCheck function from the current list of
  8991. * defined inputs in the manager.
  8992. */
  8993. rebuildInputCheck(): void;
  8994. /**
  8995. * Remove all attached input methods from a camera
  8996. */
  8997. clear(): void;
  8998. /**
  8999. * Serialize the current input manager attached to a camera.
  9000. * This ensures than once parsed,
  9001. * the input associated to the camera will be identical to the current ones
  9002. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9003. */
  9004. serialize(serializedCamera: any): void;
  9005. /**
  9006. * Parses an input manager serialized JSON to restore the previous list of inputs
  9007. * and states associated to a camera.
  9008. * @param parsedCamera Defines the JSON to parse
  9009. */
  9010. parse(parsedCamera: any): void;
  9011. }
  9012. }
  9013. declare module "babylonjs/Events/keyboardEvents" {
  9014. /**
  9015. * Gather the list of keyboard event types as constants.
  9016. */
  9017. export class KeyboardEventTypes {
  9018. /**
  9019. * The keydown event is fired when a key becomes active (pressed).
  9020. */
  9021. static readonly KEYDOWN: number;
  9022. /**
  9023. * The keyup event is fired when a key has been released.
  9024. */
  9025. static readonly KEYUP: number;
  9026. }
  9027. /**
  9028. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9029. */
  9030. export class KeyboardInfo {
  9031. /**
  9032. * Defines the type of event (KeyboardEventTypes)
  9033. */
  9034. type: number;
  9035. /**
  9036. * Defines the related dom event
  9037. */
  9038. event: KeyboardEvent;
  9039. /**
  9040. * Instantiates a new keyboard info.
  9041. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9042. * @param type Defines the type of event (KeyboardEventTypes)
  9043. * @param event Defines the related dom event
  9044. */
  9045. constructor(
  9046. /**
  9047. * Defines the type of event (KeyboardEventTypes)
  9048. */
  9049. type: number,
  9050. /**
  9051. * Defines the related dom event
  9052. */
  9053. event: KeyboardEvent);
  9054. }
  9055. /**
  9056. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9057. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9058. */
  9059. export class KeyboardInfoPre extends KeyboardInfo {
  9060. /**
  9061. * Defines the type of event (KeyboardEventTypes)
  9062. */
  9063. type: number;
  9064. /**
  9065. * Defines the related dom event
  9066. */
  9067. event: KeyboardEvent;
  9068. /**
  9069. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9070. */
  9071. skipOnPointerObservable: boolean;
  9072. /**
  9073. * Instantiates a new keyboard pre info.
  9074. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9075. * @param type Defines the type of event (KeyboardEventTypes)
  9076. * @param event Defines the related dom event
  9077. */
  9078. constructor(
  9079. /**
  9080. * Defines the type of event (KeyboardEventTypes)
  9081. */
  9082. type: number,
  9083. /**
  9084. * Defines the related dom event
  9085. */
  9086. event: KeyboardEvent);
  9087. }
  9088. }
  9089. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9090. import { Nullable } from "babylonjs/types";
  9091. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9092. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9093. /**
  9094. * Manage the keyboard inputs to control the movement of a free camera.
  9095. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9096. */
  9097. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9098. /**
  9099. * Defines the camera the input is attached to.
  9100. */
  9101. camera: FreeCamera;
  9102. /**
  9103. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9104. */
  9105. keysUp: number[];
  9106. /**
  9107. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9108. */
  9109. keysDown: number[];
  9110. /**
  9111. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9112. */
  9113. keysLeft: number[];
  9114. /**
  9115. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9116. */
  9117. keysRight: number[];
  9118. private _keys;
  9119. private _onCanvasBlurObserver;
  9120. private _onKeyboardObserver;
  9121. private _engine;
  9122. private _scene;
  9123. /**
  9124. * Attach the input controls to a specific dom element to get the input from.
  9125. * @param element Defines the element the controls should be listened from
  9126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9127. */
  9128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9129. /**
  9130. * Detach the current controls from the specified dom element.
  9131. * @param element Defines the element to stop listening the inputs from
  9132. */
  9133. detachControl(element: Nullable<HTMLElement>): void;
  9134. /**
  9135. * Update the current camera state depending on the inputs that have been used this frame.
  9136. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9137. */
  9138. checkInputs(): void;
  9139. /**
  9140. * Gets the class name of the current intput.
  9141. * @returns the class name
  9142. */
  9143. getClassName(): string;
  9144. /** @hidden */
  9145. _onLostFocus(): void;
  9146. /**
  9147. * Get the friendly name associated with the input class.
  9148. * @returns the input friendly name
  9149. */
  9150. getSimpleName(): string;
  9151. }
  9152. }
  9153. declare module "babylonjs/Lights/shadowLight" {
  9154. import { Camera } from "babylonjs/Cameras/camera";
  9155. import { Scene } from "babylonjs/scene";
  9156. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9158. import { Light } from "babylonjs/Lights/light";
  9159. /**
  9160. * Interface describing all the common properties and methods a shadow light needs to implement.
  9161. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9162. * as well as binding the different shadow properties to the effects.
  9163. */
  9164. export interface IShadowLight extends Light {
  9165. /**
  9166. * The light id in the scene (used in scene.findLighById for instance)
  9167. */
  9168. id: string;
  9169. /**
  9170. * The position the shdow will be casted from.
  9171. */
  9172. position: Vector3;
  9173. /**
  9174. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9175. */
  9176. direction: Vector3;
  9177. /**
  9178. * The transformed position. Position of the light in world space taking parenting in account.
  9179. */
  9180. transformedPosition: Vector3;
  9181. /**
  9182. * The transformed direction. Direction of the light in world space taking parenting in account.
  9183. */
  9184. transformedDirection: Vector3;
  9185. /**
  9186. * The friendly name of the light in the scene.
  9187. */
  9188. name: string;
  9189. /**
  9190. * Defines the shadow projection clipping minimum z value.
  9191. */
  9192. shadowMinZ: number;
  9193. /**
  9194. * Defines the shadow projection clipping maximum z value.
  9195. */
  9196. shadowMaxZ: number;
  9197. /**
  9198. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9199. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9200. */
  9201. computeTransformedInformation(): boolean;
  9202. /**
  9203. * Gets the scene the light belongs to.
  9204. * @returns The scene
  9205. */
  9206. getScene(): Scene;
  9207. /**
  9208. * Callback defining a custom Projection Matrix Builder.
  9209. * This can be used to override the default projection matrix computation.
  9210. */
  9211. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9212. /**
  9213. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9214. * @param matrix The materix to updated with the projection information
  9215. * @param viewMatrix The transform matrix of the light
  9216. * @param renderList The list of mesh to render in the map
  9217. * @returns The current light
  9218. */
  9219. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9220. /**
  9221. * Gets the current depth scale used in ESM.
  9222. * @returns The scale
  9223. */
  9224. getDepthScale(): number;
  9225. /**
  9226. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9227. * @returns true if a cube texture needs to be use
  9228. */
  9229. needCube(): boolean;
  9230. /**
  9231. * Detects if the projection matrix requires to be recomputed this frame.
  9232. * @returns true if it requires to be recomputed otherwise, false.
  9233. */
  9234. needProjectionMatrixCompute(): boolean;
  9235. /**
  9236. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9237. */
  9238. forceProjectionMatrixCompute(): void;
  9239. /**
  9240. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9241. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9242. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9243. */
  9244. getShadowDirection(faceIndex?: number): Vector3;
  9245. /**
  9246. * Gets the minZ used for shadow according to both the scene and the light.
  9247. * @param activeCamera The camera we are returning the min for
  9248. * @returns the depth min z
  9249. */
  9250. getDepthMinZ(activeCamera: Camera): number;
  9251. /**
  9252. * Gets the maxZ used for shadow according to both the scene and the light.
  9253. * @param activeCamera The camera we are returning the max for
  9254. * @returns the depth max z
  9255. */
  9256. getDepthMaxZ(activeCamera: Camera): number;
  9257. }
  9258. /**
  9259. * Base implementation IShadowLight
  9260. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9261. */
  9262. export abstract class ShadowLight extends Light implements IShadowLight {
  9263. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9264. protected _position: Vector3;
  9265. protected _setPosition(value: Vector3): void;
  9266. /**
  9267. * Sets the position the shadow will be casted from. Also use as the light position for both
  9268. * point and spot lights.
  9269. */
  9270. /**
  9271. * Sets the position the shadow will be casted from. Also use as the light position for both
  9272. * point and spot lights.
  9273. */
  9274. position: Vector3;
  9275. protected _direction: Vector3;
  9276. protected _setDirection(value: Vector3): void;
  9277. /**
  9278. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9279. * Also use as the light direction on spot and directional lights.
  9280. */
  9281. /**
  9282. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9283. * Also use as the light direction on spot and directional lights.
  9284. */
  9285. direction: Vector3;
  9286. private _shadowMinZ;
  9287. /**
  9288. * Gets the shadow projection clipping minimum z value.
  9289. */
  9290. /**
  9291. * Sets the shadow projection clipping minimum z value.
  9292. */
  9293. shadowMinZ: number;
  9294. private _shadowMaxZ;
  9295. /**
  9296. * Sets the shadow projection clipping maximum z value.
  9297. */
  9298. /**
  9299. * Gets the shadow projection clipping maximum z value.
  9300. */
  9301. shadowMaxZ: number;
  9302. /**
  9303. * Callback defining a custom Projection Matrix Builder.
  9304. * This can be used to override the default projection matrix computation.
  9305. */
  9306. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9307. /**
  9308. * The transformed position. Position of the light in world space taking parenting in account.
  9309. */
  9310. transformedPosition: Vector3;
  9311. /**
  9312. * The transformed direction. Direction of the light in world space taking parenting in account.
  9313. */
  9314. transformedDirection: Vector3;
  9315. private _needProjectionMatrixCompute;
  9316. /**
  9317. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9318. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9319. */
  9320. computeTransformedInformation(): boolean;
  9321. /**
  9322. * Return the depth scale used for the shadow map.
  9323. * @returns the depth scale.
  9324. */
  9325. getDepthScale(): number;
  9326. /**
  9327. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9328. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9329. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9330. */
  9331. getShadowDirection(faceIndex?: number): Vector3;
  9332. /**
  9333. * Returns the ShadowLight absolute position in the World.
  9334. * @returns the position vector in world space
  9335. */
  9336. getAbsolutePosition(): Vector3;
  9337. /**
  9338. * Sets the ShadowLight direction toward the passed target.
  9339. * @param target The point to target in local space
  9340. * @returns the updated ShadowLight direction
  9341. */
  9342. setDirectionToTarget(target: Vector3): Vector3;
  9343. /**
  9344. * Returns the light rotation in euler definition.
  9345. * @returns the x y z rotation in local space.
  9346. */
  9347. getRotation(): Vector3;
  9348. /**
  9349. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9350. * @returns true if a cube texture needs to be use
  9351. */
  9352. needCube(): boolean;
  9353. /**
  9354. * Detects if the projection matrix requires to be recomputed this frame.
  9355. * @returns true if it requires to be recomputed otherwise, false.
  9356. */
  9357. needProjectionMatrixCompute(): boolean;
  9358. /**
  9359. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9360. */
  9361. forceProjectionMatrixCompute(): void;
  9362. /** @hidden */
  9363. _initCache(): void;
  9364. /** @hidden */
  9365. _isSynchronized(): boolean;
  9366. /**
  9367. * Computes the world matrix of the node
  9368. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9369. * @returns the world matrix
  9370. */
  9371. computeWorldMatrix(force?: boolean): Matrix;
  9372. /**
  9373. * Gets the minZ used for shadow according to both the scene and the light.
  9374. * @param activeCamera The camera we are returning the min for
  9375. * @returns the depth min z
  9376. */
  9377. getDepthMinZ(activeCamera: Camera): number;
  9378. /**
  9379. * Gets the maxZ used for shadow according to both the scene and the light.
  9380. * @param activeCamera The camera we are returning the max for
  9381. * @returns the depth max z
  9382. */
  9383. getDepthMaxZ(activeCamera: Camera): number;
  9384. /**
  9385. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9386. * @param matrix The materix to updated with the projection information
  9387. * @param viewMatrix The transform matrix of the light
  9388. * @param renderList The list of mesh to render in the map
  9389. * @returns The current light
  9390. */
  9391. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9392. }
  9393. }
  9394. declare module "babylonjs/Materials/materialHelper" {
  9395. import { Nullable } from "babylonjs/types";
  9396. import { Scene } from "babylonjs/scene";
  9397. import { Engine } from "babylonjs/Engines/engine";
  9398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9399. import { Light } from "babylonjs/Lights/light";
  9400. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9401. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9403. /**
  9404. * "Static Class" containing the most commonly used helper while dealing with material for
  9405. * rendering purpose.
  9406. *
  9407. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9408. *
  9409. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9410. */
  9411. export class MaterialHelper {
  9412. /**
  9413. * Bind the current view position to an effect.
  9414. * @param effect The effect to be bound
  9415. * @param scene The scene the eyes position is used from
  9416. */
  9417. static BindEyePosition(effect: Effect, scene: Scene): void;
  9418. /**
  9419. * Helps preparing the defines values about the UVs in used in the effect.
  9420. * UVs are shared as much as we can accross channels in the shaders.
  9421. * @param texture The texture we are preparing the UVs for
  9422. * @param defines The defines to update
  9423. * @param key The channel key "diffuse", "specular"... used in the shader
  9424. */
  9425. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9426. /**
  9427. * Binds a texture matrix value to its corrsponding uniform
  9428. * @param texture The texture to bind the matrix for
  9429. * @param uniformBuffer The uniform buffer receivin the data
  9430. * @param key The channel key "diffuse", "specular"... used in the shader
  9431. */
  9432. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9433. /**
  9434. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9435. * @param mesh defines the current mesh
  9436. * @param scene defines the current scene
  9437. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9438. * @param pointsCloud defines if point cloud rendering has to be turned on
  9439. * @param fogEnabled defines if fog has to be turned on
  9440. * @param alphaTest defines if alpha testing has to be turned on
  9441. * @param defines defines the current list of defines
  9442. */
  9443. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9444. /**
  9445. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9446. * @param scene defines the current scene
  9447. * @param engine defines the current engine
  9448. * @param defines specifies the list of active defines
  9449. * @param useInstances defines if instances have to be turned on
  9450. * @param useClipPlane defines if clip plane have to be turned on
  9451. */
  9452. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9453. /**
  9454. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9455. * @param mesh The mesh containing the geometry data we will draw
  9456. * @param defines The defines to update
  9457. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9458. * @param useBones Precise whether bones should be used or not (override mesh info)
  9459. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9460. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9461. * @returns false if defines are considered not dirty and have not been checked
  9462. */
  9463. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9464. /**
  9465. * Prepares the defines related to multiview
  9466. * @param scene The scene we are intending to draw
  9467. * @param defines The defines to update
  9468. */
  9469. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9470. /**
  9471. * Prepares the defines related to the light information passed in parameter
  9472. * @param scene The scene we are intending to draw
  9473. * @param mesh The mesh the effect is compiling for
  9474. * @param defines The defines to update
  9475. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9476. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9477. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9478. * @returns true if normals will be required for the rest of the effect
  9479. */
  9480. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9481. /**
  9482. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9483. * that won t be acctive due to defines being turned off.
  9484. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9485. * @param samplersList The samplers list
  9486. * @param defines The defines helping in the list generation
  9487. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9488. */
  9489. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9490. /**
  9491. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9492. * @param defines The defines to update while falling back
  9493. * @param fallbacks The authorized effect fallbacks
  9494. * @param maxSimultaneousLights The maximum number of lights allowed
  9495. * @param rank the current rank of the Effect
  9496. * @returns The newly affected rank
  9497. */
  9498. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9499. /**
  9500. * Prepares the list of attributes required for morph targets according to the effect defines.
  9501. * @param attribs The current list of supported attribs
  9502. * @param mesh The mesh to prepare the morph targets attributes for
  9503. * @param defines The current Defines of the effect
  9504. */
  9505. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9506. /**
  9507. * Prepares the list of attributes required for bones according to the effect defines.
  9508. * @param attribs The current list of supported attribs
  9509. * @param mesh The mesh to prepare the bones attributes for
  9510. * @param defines The current Defines of the effect
  9511. * @param fallbacks The current efffect fallback strategy
  9512. */
  9513. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9514. /**
  9515. * Prepares the list of attributes required for instances according to the effect defines.
  9516. * @param attribs The current list of supported attribs
  9517. * @param defines The current Defines of the effect
  9518. */
  9519. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9520. /**
  9521. * Binds the light shadow information to the effect for the given mesh.
  9522. * @param light The light containing the generator
  9523. * @param scene The scene the lights belongs to
  9524. * @param mesh The mesh we are binding the information to render
  9525. * @param lightIndex The light index in the effect used to render the mesh
  9526. * @param effect The effect we are binding the data to
  9527. */
  9528. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9529. /**
  9530. * Binds the light information to the effect.
  9531. * @param light The light containing the generator
  9532. * @param effect The effect we are binding the data to
  9533. * @param lightIndex The light index in the effect used to render
  9534. */
  9535. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9536. /**
  9537. * Binds the lights information from the scene to the effect for the given mesh.
  9538. * @param scene The scene the lights belongs to
  9539. * @param mesh The mesh we are binding the information to render
  9540. * @param effect The effect we are binding the data to
  9541. * @param defines The generated defines for the effect
  9542. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9543. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9544. */
  9545. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9546. private static _tempFogColor;
  9547. /**
  9548. * Binds the fog information from the scene to the effect for the given mesh.
  9549. * @param scene The scene the lights belongs to
  9550. * @param mesh The mesh we are binding the information to render
  9551. * @param effect The effect we are binding the data to
  9552. * @param linearSpace Defines if the fog effect is applied in linear space
  9553. */
  9554. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9555. /**
  9556. * Binds the bones information from the mesh to the effect.
  9557. * @param mesh The mesh we are binding the information to render
  9558. * @param effect The effect we are binding the data to
  9559. */
  9560. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9561. /**
  9562. * Binds the morph targets information from the mesh to the effect.
  9563. * @param abstractMesh The mesh we are binding the information to render
  9564. * @param effect The effect we are binding the data to
  9565. */
  9566. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9567. /**
  9568. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9569. * @param defines The generated defines used in the effect
  9570. * @param effect The effect we are binding the data to
  9571. * @param scene The scene we are willing to render with logarithmic scale for
  9572. */
  9573. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9574. /**
  9575. * Binds the clip plane information from the scene to the effect.
  9576. * @param scene The scene the clip plane information are extracted from
  9577. * @param effect The effect we are binding the data to
  9578. */
  9579. static BindClipPlane(effect: Effect, scene: Scene): void;
  9580. }
  9581. }
  9582. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9583. /** @hidden */
  9584. export var kernelBlurVaryingDeclaration: {
  9585. name: string;
  9586. shader: string;
  9587. };
  9588. }
  9589. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9590. /** @hidden */
  9591. export var kernelBlurFragment: {
  9592. name: string;
  9593. shader: string;
  9594. };
  9595. }
  9596. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9597. /** @hidden */
  9598. export var kernelBlurFragment2: {
  9599. name: string;
  9600. shader: string;
  9601. };
  9602. }
  9603. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9604. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9605. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9606. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9607. /** @hidden */
  9608. export var kernelBlurPixelShader: {
  9609. name: string;
  9610. shader: string;
  9611. };
  9612. }
  9613. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9614. /** @hidden */
  9615. export var kernelBlurVertex: {
  9616. name: string;
  9617. shader: string;
  9618. };
  9619. }
  9620. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9621. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9622. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9623. /** @hidden */
  9624. export var kernelBlurVertexShader: {
  9625. name: string;
  9626. shader: string;
  9627. };
  9628. }
  9629. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9630. import { Vector2 } from "babylonjs/Maths/math";
  9631. import { Nullable } from "babylonjs/types";
  9632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9633. import { Camera } from "babylonjs/Cameras/camera";
  9634. import { Effect } from "babylonjs/Materials/effect";
  9635. import { Engine } from "babylonjs/Engines/engine";
  9636. import "babylonjs/Shaders/kernelBlur.fragment";
  9637. import "babylonjs/Shaders/kernelBlur.vertex";
  9638. /**
  9639. * The Blur Post Process which blurs an image based on a kernel and direction.
  9640. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9641. */
  9642. export class BlurPostProcess extends PostProcess {
  9643. /** The direction in which to blur the image. */
  9644. direction: Vector2;
  9645. private blockCompilation;
  9646. protected _kernel: number;
  9647. protected _idealKernel: number;
  9648. protected _packedFloat: boolean;
  9649. private _staticDefines;
  9650. /**
  9651. * Sets the length in pixels of the blur sample region
  9652. */
  9653. /**
  9654. * Gets the length in pixels of the blur sample region
  9655. */
  9656. kernel: number;
  9657. /**
  9658. * Sets wether or not the blur needs to unpack/repack floats
  9659. */
  9660. /**
  9661. * Gets wether or not the blur is unpacking/repacking floats
  9662. */
  9663. packedFloat: boolean;
  9664. /**
  9665. * Creates a new instance BlurPostProcess
  9666. * @param name The name of the effect.
  9667. * @param direction The direction in which to blur the image.
  9668. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  9669. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9670. * @param camera The camera to apply the render pass to.
  9671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9672. * @param engine The engine which the post process will be applied. (default: current engine)
  9673. * @param reusable If the post process can be reused on the same frame. (default: false)
  9674. * @param textureType Type of textures used when performing the post process. (default: 0)
  9675. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  9676. */
  9677. constructor(name: string,
  9678. /** The direction in which to blur the image. */
  9679. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9680. /**
  9681. * Updates the effect with the current post process compile time values and recompiles the shader.
  9682. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9683. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9684. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9685. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  9686. * @param onCompiled Called when the shader has been compiled.
  9687. * @param onError Called if there is an error when compiling a shader.
  9688. */
  9689. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9690. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9691. /**
  9692. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9693. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9694. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9695. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9696. * The gaps between physical kernels are compensated for in the weighting of the samples
  9697. * @param idealKernel Ideal blur kernel.
  9698. * @return Nearest best kernel.
  9699. */
  9700. protected _nearestBestKernel(idealKernel: number): number;
  9701. /**
  9702. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9703. * @param x The point on the Gaussian distribution to sample.
  9704. * @return the value of the Gaussian function at x.
  9705. */
  9706. protected _gaussianWeight(x: number): number;
  9707. /**
  9708. * Generates a string that can be used as a floating point number in GLSL.
  9709. * @param x Value to print.
  9710. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9711. * @return GLSL float string.
  9712. */
  9713. protected _glslFloat(x: number, decimalFigures?: number): string;
  9714. }
  9715. }
  9716. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9717. /** @hidden */
  9718. export var shadowMapPixelShader: {
  9719. name: string;
  9720. shader: string;
  9721. };
  9722. }
  9723. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9724. /** @hidden */
  9725. export var bonesDeclaration: {
  9726. name: string;
  9727. shader: string;
  9728. };
  9729. }
  9730. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9731. /** @hidden */
  9732. export var morphTargetsVertexGlobalDeclaration: {
  9733. name: string;
  9734. shader: string;
  9735. };
  9736. }
  9737. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9738. /** @hidden */
  9739. export var morphTargetsVertexDeclaration: {
  9740. name: string;
  9741. shader: string;
  9742. };
  9743. }
  9744. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9745. /** @hidden */
  9746. export var instancesDeclaration: {
  9747. name: string;
  9748. shader: string;
  9749. };
  9750. }
  9751. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9752. /** @hidden */
  9753. export var helperFunctions: {
  9754. name: string;
  9755. shader: string;
  9756. };
  9757. }
  9758. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9759. /** @hidden */
  9760. export var morphTargetsVertex: {
  9761. name: string;
  9762. shader: string;
  9763. };
  9764. }
  9765. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9766. /** @hidden */
  9767. export var instancesVertex: {
  9768. name: string;
  9769. shader: string;
  9770. };
  9771. }
  9772. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9773. /** @hidden */
  9774. export var bonesVertex: {
  9775. name: string;
  9776. shader: string;
  9777. };
  9778. }
  9779. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9780. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9781. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9782. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9783. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9784. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9785. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9786. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9787. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9788. /** @hidden */
  9789. export var shadowMapVertexShader: {
  9790. name: string;
  9791. shader: string;
  9792. };
  9793. }
  9794. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9795. /** @hidden */
  9796. export var depthBoxBlurPixelShader: {
  9797. name: string;
  9798. shader: string;
  9799. };
  9800. }
  9801. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9802. import { Nullable } from "babylonjs/types";
  9803. import { Scene } from "babylonjs/scene";
  9804. import { Matrix } from "babylonjs/Maths/math";
  9805. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9807. import { Mesh } from "babylonjs/Meshes/mesh";
  9808. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9809. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9810. import { Effect } from "babylonjs/Materials/effect";
  9811. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9812. import "babylonjs/Shaders/shadowMap.fragment";
  9813. import "babylonjs/Shaders/shadowMap.vertex";
  9814. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9815. import { Observable } from "babylonjs/Misc/observable";
  9816. /**
  9817. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9818. */
  9819. export interface ICustomShaderOptions {
  9820. /**
  9821. * Gets or sets the custom shader name to use
  9822. */
  9823. shaderName: string;
  9824. /**
  9825. * The list of attribute names used in the shader
  9826. */
  9827. attributes?: string[];
  9828. /**
  9829. * The list of unifrom names used in the shader
  9830. */
  9831. uniforms?: string[];
  9832. /**
  9833. * The list of sampler names used in the shader
  9834. */
  9835. samplers?: string[];
  9836. /**
  9837. * The list of defines used in the shader
  9838. */
  9839. defines?: string[];
  9840. }
  9841. /**
  9842. * Interface to implement to create a shadow generator compatible with BJS.
  9843. */
  9844. export interface IShadowGenerator {
  9845. /**
  9846. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9847. * @returns The render target texture if present otherwise, null
  9848. */
  9849. getShadowMap(): Nullable<RenderTargetTexture>;
  9850. /**
  9851. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9852. * @returns The render target texture if the shadow map is present otherwise, null
  9853. */
  9854. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9855. /**
  9856. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9857. * @param subMesh The submesh we want to render in the shadow map
  9858. * @param useInstances Defines wether will draw in the map using instances
  9859. * @returns true if ready otherwise, false
  9860. */
  9861. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9862. /**
  9863. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9864. * @param defines Defines of the material we want to update
  9865. * @param lightIndex Index of the light in the enabled light list of the material
  9866. */
  9867. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9868. /**
  9869. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9870. * defined in the generator but impacting the effect).
  9871. * It implies the unifroms available on the materials are the standard BJS ones.
  9872. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9873. * @param effect The effect we are binfing the information for
  9874. */
  9875. bindShadowLight(lightIndex: string, effect: Effect): void;
  9876. /**
  9877. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9878. * (eq to shadow prjection matrix * light transform matrix)
  9879. * @returns The transform matrix used to create the shadow map
  9880. */
  9881. getTransformMatrix(): Matrix;
  9882. /**
  9883. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9884. * Cube and 2D textures for instance.
  9885. */
  9886. recreateShadowMap(): void;
  9887. /**
  9888. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9889. * @param onCompiled Callback triggered at the and of the effects compilation
  9890. * @param options Sets of optional options forcing the compilation with different modes
  9891. */
  9892. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9893. useInstances: boolean;
  9894. }>): void;
  9895. /**
  9896. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9897. * @param options Sets of optional options forcing the compilation with different modes
  9898. * @returns A promise that resolves when the compilation completes
  9899. */
  9900. forceCompilationAsync(options?: Partial<{
  9901. useInstances: boolean;
  9902. }>): Promise<void>;
  9903. /**
  9904. * Serializes the shadow generator setup to a json object.
  9905. * @returns The serialized JSON object
  9906. */
  9907. serialize(): any;
  9908. /**
  9909. * Disposes the Shadow map and related Textures and effects.
  9910. */
  9911. dispose(): void;
  9912. }
  9913. /**
  9914. * Default implementation IShadowGenerator.
  9915. * This is the main object responsible of generating shadows in the framework.
  9916. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9917. */
  9918. export class ShadowGenerator implements IShadowGenerator {
  9919. /**
  9920. * Shadow generator mode None: no filtering applied.
  9921. */
  9922. static readonly FILTER_NONE: number;
  9923. /**
  9924. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9925. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9926. */
  9927. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9928. /**
  9929. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9930. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9931. */
  9932. static readonly FILTER_POISSONSAMPLING: number;
  9933. /**
  9934. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9935. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9936. */
  9937. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9938. /**
  9939. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9940. * edge artifacts on steep falloff.
  9941. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9942. */
  9943. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9944. /**
  9945. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9946. * edge artifacts on steep falloff.
  9947. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9948. */
  9949. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9950. /**
  9951. * Shadow generator mode PCF: Percentage Closer Filtering
  9952. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9953. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9954. */
  9955. static readonly FILTER_PCF: number;
  9956. /**
  9957. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9958. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9959. * Contact Hardening
  9960. */
  9961. static readonly FILTER_PCSS: number;
  9962. /**
  9963. * Reserved for PCF and PCSS
  9964. * Highest Quality.
  9965. *
  9966. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9967. *
  9968. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9969. */
  9970. static readonly QUALITY_HIGH: number;
  9971. /**
  9972. * Reserved for PCF and PCSS
  9973. * Good tradeoff for quality/perf cross devices
  9974. *
  9975. * Execute PCF on a 3*3 kernel.
  9976. *
  9977. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9978. */
  9979. static readonly QUALITY_MEDIUM: number;
  9980. /**
  9981. * Reserved for PCF and PCSS
  9982. * The lowest quality but the fastest.
  9983. *
  9984. * Execute PCF on a 1*1 kernel.
  9985. *
  9986. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9987. */
  9988. static readonly QUALITY_LOW: number;
  9989. /** Gets or sets the custom shader name to use */
  9990. customShaderOptions: ICustomShaderOptions;
  9991. /**
  9992. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9993. */
  9994. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9995. /**
  9996. * Observable triggered before a mesh is rendered in the shadow map.
  9997. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9998. */
  9999. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10000. private _bias;
  10001. /**
  10002. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10003. */
  10004. /**
  10005. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10006. */
  10007. bias: number;
  10008. private _normalBias;
  10009. /**
  10010. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10011. */
  10012. /**
  10013. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10014. */
  10015. normalBias: number;
  10016. private _blurBoxOffset;
  10017. /**
  10018. * Gets the blur box offset: offset applied during the blur pass.
  10019. * Only useful if useKernelBlur = false
  10020. */
  10021. /**
  10022. * Sets the blur box offset: offset applied during the blur pass.
  10023. * Only useful if useKernelBlur = false
  10024. */
  10025. blurBoxOffset: number;
  10026. private _blurScale;
  10027. /**
  10028. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10029. * 2 means half of the size.
  10030. */
  10031. /**
  10032. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10033. * 2 means half of the size.
  10034. */
  10035. blurScale: number;
  10036. private _blurKernel;
  10037. /**
  10038. * Gets the blur kernel: kernel size of the blur pass.
  10039. * Only useful if useKernelBlur = true
  10040. */
  10041. /**
  10042. * Sets the blur kernel: kernel size of the blur pass.
  10043. * Only useful if useKernelBlur = true
  10044. */
  10045. blurKernel: number;
  10046. private _useKernelBlur;
  10047. /**
  10048. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10049. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10050. */
  10051. /**
  10052. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10053. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10054. */
  10055. useKernelBlur: boolean;
  10056. private _depthScale;
  10057. /**
  10058. * Gets the depth scale used in ESM mode.
  10059. */
  10060. /**
  10061. * Sets the depth scale used in ESM mode.
  10062. * This can override the scale stored on the light.
  10063. */
  10064. depthScale: number;
  10065. private _filter;
  10066. /**
  10067. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10068. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10069. */
  10070. /**
  10071. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10072. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10073. */
  10074. filter: number;
  10075. /**
  10076. * Gets if the current filter is set to Poisson Sampling.
  10077. */
  10078. /**
  10079. * Sets the current filter to Poisson Sampling.
  10080. */
  10081. usePoissonSampling: boolean;
  10082. /**
  10083. * Gets if the current filter is set to ESM.
  10084. */
  10085. /**
  10086. * Sets the current filter is to ESM.
  10087. */
  10088. useExponentialShadowMap: boolean;
  10089. /**
  10090. * Gets if the current filter is set to filtered ESM.
  10091. */
  10092. /**
  10093. * Gets if the current filter is set to filtered ESM.
  10094. */
  10095. useBlurExponentialShadowMap: boolean;
  10096. /**
  10097. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10098. * exponential to prevent steep falloff artifacts).
  10099. */
  10100. /**
  10101. * Sets the current filter to "close ESM" (using the inverse of the
  10102. * exponential to prevent steep falloff artifacts).
  10103. */
  10104. useCloseExponentialShadowMap: boolean;
  10105. /**
  10106. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10107. * exponential to prevent steep falloff artifacts).
  10108. */
  10109. /**
  10110. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10111. * exponential to prevent steep falloff artifacts).
  10112. */
  10113. useBlurCloseExponentialShadowMap: boolean;
  10114. /**
  10115. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10116. */
  10117. /**
  10118. * Sets the current filter to "PCF" (percentage closer filtering).
  10119. */
  10120. usePercentageCloserFiltering: boolean;
  10121. private _filteringQuality;
  10122. /**
  10123. * Gets the PCF or PCSS Quality.
  10124. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10125. */
  10126. /**
  10127. * Sets the PCF or PCSS Quality.
  10128. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10129. */
  10130. filteringQuality: number;
  10131. /**
  10132. * Gets if the current filter is set to "PCSS" (contact hardening).
  10133. */
  10134. /**
  10135. * Sets the current filter to "PCSS" (contact hardening).
  10136. */
  10137. useContactHardeningShadow: boolean;
  10138. private _contactHardeningLightSizeUVRatio;
  10139. /**
  10140. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10141. * Using a ratio helps keeping shape stability independently of the map size.
  10142. *
  10143. * It does not account for the light projection as it was having too much
  10144. * instability during the light setup or during light position changes.
  10145. *
  10146. * Only valid if useContactHardeningShadow is true.
  10147. */
  10148. /**
  10149. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10150. * Using a ratio helps keeping shape stability independently of the map size.
  10151. *
  10152. * It does not account for the light projection as it was having too much
  10153. * instability during the light setup or during light position changes.
  10154. *
  10155. * Only valid if useContactHardeningShadow is true.
  10156. */
  10157. contactHardeningLightSizeUVRatio: number;
  10158. private _darkness;
  10159. /**
  10160. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10161. * 0 means strongest and 1 would means no shadow.
  10162. * @returns the darkness.
  10163. */
  10164. getDarkness(): number;
  10165. /**
  10166. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10167. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10168. * @returns the shadow generator allowing fluent coding.
  10169. */
  10170. setDarkness(darkness: number): ShadowGenerator;
  10171. private _transparencyShadow;
  10172. /**
  10173. * Sets the ability to have transparent shadow (boolean).
  10174. * @param transparent True if transparent else False
  10175. * @returns the shadow generator allowing fluent coding
  10176. */
  10177. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10178. private _shadowMap;
  10179. private _shadowMap2;
  10180. /**
  10181. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10182. * @returns The render target texture if present otherwise, null
  10183. */
  10184. getShadowMap(): Nullable<RenderTargetTexture>;
  10185. /**
  10186. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10187. * @returns The render target texture if the shadow map is present otherwise, null
  10188. */
  10189. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10190. /**
  10191. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10192. * @param mesh Mesh to add
  10193. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10194. * @returns the Shadow Generator itself
  10195. */
  10196. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10197. /**
  10198. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10199. * @param mesh Mesh to remove
  10200. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10201. * @returns the Shadow Generator itself
  10202. */
  10203. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10204. /**
  10205. * Controls the extent to which the shadows fade out at the edge of the frustum
  10206. * Used only by directionals and spots
  10207. */
  10208. frustumEdgeFalloff: number;
  10209. private _light;
  10210. /**
  10211. * Returns the associated light object.
  10212. * @returns the light generating the shadow
  10213. */
  10214. getLight(): IShadowLight;
  10215. /**
  10216. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10217. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10218. * It might on the other hand introduce peter panning.
  10219. */
  10220. forceBackFacesOnly: boolean;
  10221. private _scene;
  10222. private _lightDirection;
  10223. private _effect;
  10224. private _viewMatrix;
  10225. private _projectionMatrix;
  10226. private _transformMatrix;
  10227. private _cachedPosition;
  10228. private _cachedDirection;
  10229. private _cachedDefines;
  10230. private _currentRenderID;
  10231. private _boxBlurPostprocess;
  10232. private _kernelBlurXPostprocess;
  10233. private _kernelBlurYPostprocess;
  10234. private _blurPostProcesses;
  10235. private _mapSize;
  10236. private _currentFaceIndex;
  10237. private _currentFaceIndexCache;
  10238. private _textureType;
  10239. private _defaultTextureMatrix;
  10240. /** @hidden */
  10241. static _SceneComponentInitialization: (scene: Scene) => void;
  10242. /**
  10243. * Creates a ShadowGenerator object.
  10244. * A ShadowGenerator is the required tool to use the shadows.
  10245. * Each light casting shadows needs to use its own ShadowGenerator.
  10246. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10247. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10248. * @param light The light object generating the shadows.
  10249. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  10250. */
  10251. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10252. private _initializeGenerator;
  10253. private _initializeShadowMap;
  10254. private _initializeBlurRTTAndPostProcesses;
  10255. private _renderForShadowMap;
  10256. private _renderSubMeshForShadowMap;
  10257. private _applyFilterValues;
  10258. /**
  10259. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10260. * @param onCompiled Callback triggered at the and of the effects compilation
  10261. * @param options Sets of optional options forcing the compilation with different modes
  10262. */
  10263. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10264. useInstances: boolean;
  10265. }>): void;
  10266. /**
  10267. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10268. * @param options Sets of optional options forcing the compilation with different modes
  10269. * @returns A promise that resolves when the compilation completes
  10270. */
  10271. forceCompilationAsync(options?: Partial<{
  10272. useInstances: boolean;
  10273. }>): Promise<void>;
  10274. /**
  10275. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10276. * @param subMesh The submesh we want to render in the shadow map
  10277. * @param useInstances Defines wether will draw in the map using instances
  10278. * @returns true if ready otherwise, false
  10279. */
  10280. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10281. /**
  10282. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10283. * @param defines Defines of the material we want to update
  10284. * @param lightIndex Index of the light in the enabled light list of the material
  10285. */
  10286. prepareDefines(defines: any, lightIndex: number): void;
  10287. /**
  10288. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10289. * defined in the generator but impacting the effect).
  10290. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10291. * @param effect The effect we are binfing the information for
  10292. */
  10293. bindShadowLight(lightIndex: string, effect: Effect): void;
  10294. /**
  10295. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10296. * (eq to shadow prjection matrix * light transform matrix)
  10297. * @returns The transform matrix used to create the shadow map
  10298. */
  10299. getTransformMatrix(): Matrix;
  10300. /**
  10301. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10302. * Cube and 2D textures for instance.
  10303. */
  10304. recreateShadowMap(): void;
  10305. private _disposeBlurPostProcesses;
  10306. private _disposeRTTandPostProcesses;
  10307. /**
  10308. * Disposes the ShadowGenerator.
  10309. * Returns nothing.
  10310. */
  10311. dispose(): void;
  10312. /**
  10313. * Serializes the shadow generator setup to a json object.
  10314. * @returns The serialized JSON object
  10315. */
  10316. serialize(): any;
  10317. /**
  10318. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10319. * @param parsedShadowGenerator The JSON object to parse
  10320. * @param scene The scene to create the shadow map for
  10321. * @returns The parsed shadow generator
  10322. */
  10323. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10324. }
  10325. }
  10326. declare module "babylonjs/Lights/light" {
  10327. import { Nullable } from "babylonjs/types";
  10328. import { Scene } from "babylonjs/scene";
  10329. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10330. import { Node } from "babylonjs/node";
  10331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10332. import { Effect } from "babylonjs/Materials/effect";
  10333. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10334. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10335. /**
  10336. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10337. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10338. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  10339. */
  10340. export abstract class Light extends Node {
  10341. /**
  10342. * Falloff Default: light is falling off following the material specification:
  10343. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10344. */
  10345. static readonly FALLOFF_DEFAULT: number;
  10346. /**
  10347. * Falloff Physical: light is falling off following the inverse squared distance law.
  10348. */
  10349. static readonly FALLOFF_PHYSICAL: number;
  10350. /**
  10351. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10352. * to enhance interoperability with other engines.
  10353. */
  10354. static readonly FALLOFF_GLTF: number;
  10355. /**
  10356. * Falloff Standard: light is falling off like in the standard material
  10357. * to enhance interoperability with other materials.
  10358. */
  10359. static readonly FALLOFF_STANDARD: number;
  10360. /**
  10361. * If every light affecting the material is in this lightmapMode,
  10362. * material.lightmapTexture adds or multiplies
  10363. * (depends on material.useLightmapAsShadowmap)
  10364. * after every other light calculations.
  10365. */
  10366. static readonly LIGHTMAP_DEFAULT: number;
  10367. /**
  10368. * material.lightmapTexture as only diffuse lighting from this light
  10369. * adds only specular lighting from this light
  10370. * adds dynamic shadows
  10371. */
  10372. static readonly LIGHTMAP_SPECULAR: number;
  10373. /**
  10374. * material.lightmapTexture as only lighting
  10375. * no light calculation from this light
  10376. * only adds dynamic shadows from this light
  10377. */
  10378. static readonly LIGHTMAP_SHADOWSONLY: number;
  10379. /**
  10380. * Each light type uses the default quantity according to its type:
  10381. * point/spot lights use luminous intensity
  10382. * directional lights use illuminance
  10383. */
  10384. static readonly INTENSITYMODE_AUTOMATIC: number;
  10385. /**
  10386. * lumen (lm)
  10387. */
  10388. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10389. /**
  10390. * candela (lm/sr)
  10391. */
  10392. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10393. /**
  10394. * lux (lm/m^2)
  10395. */
  10396. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10397. /**
  10398. * nit (cd/m^2)
  10399. */
  10400. static readonly INTENSITYMODE_LUMINANCE: number;
  10401. /**
  10402. * Light type const id of the point light.
  10403. */
  10404. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10405. /**
  10406. * Light type const id of the directional light.
  10407. */
  10408. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10409. /**
  10410. * Light type const id of the spot light.
  10411. */
  10412. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10413. /**
  10414. * Light type const id of the hemispheric light.
  10415. */
  10416. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10417. /**
  10418. * Diffuse gives the basic color to an object.
  10419. */
  10420. diffuse: Color3;
  10421. /**
  10422. * Specular produces a highlight color on an object.
  10423. * Note: This is note affecting PBR materials.
  10424. */
  10425. specular: Color3;
  10426. /**
  10427. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10428. * falling off base on range or angle.
  10429. * This can be set to any values in Light.FALLOFF_x.
  10430. *
  10431. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10432. * other types of materials.
  10433. */
  10434. falloffType: number;
  10435. /**
  10436. * Strength of the light.
  10437. * Note: By default it is define in the framework own unit.
  10438. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10439. */
  10440. intensity: number;
  10441. private _range;
  10442. protected _inverseSquaredRange: number;
  10443. /**
  10444. * Defines how far from the source the light is impacting in scene units.
  10445. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10446. */
  10447. /**
  10448. * Defines how far from the source the light is impacting in scene units.
  10449. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10450. */
  10451. range: number;
  10452. /**
  10453. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10454. * of light.
  10455. */
  10456. private _photometricScale;
  10457. private _intensityMode;
  10458. /**
  10459. * Gets the photometric scale used to interpret the intensity.
  10460. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10461. */
  10462. /**
  10463. * Sets the photometric scale used to interpret the intensity.
  10464. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10465. */
  10466. intensityMode: number;
  10467. private _radius;
  10468. /**
  10469. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10470. */
  10471. /**
  10472. * sets the light radius used by PBR Materials to simulate soft area lights.
  10473. */
  10474. radius: number;
  10475. private _renderPriority;
  10476. /**
  10477. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10478. * exceeding the number allowed of the materials.
  10479. */
  10480. renderPriority: number;
  10481. private _shadowEnabled;
  10482. /**
  10483. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10484. * the current shadow generator.
  10485. */
  10486. /**
  10487. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10488. * the current shadow generator.
  10489. */
  10490. shadowEnabled: boolean;
  10491. private _includedOnlyMeshes;
  10492. /**
  10493. * Gets the only meshes impacted by this light.
  10494. */
  10495. /**
  10496. * Sets the only meshes impacted by this light.
  10497. */
  10498. includedOnlyMeshes: AbstractMesh[];
  10499. private _excludedMeshes;
  10500. /**
  10501. * Gets the meshes not impacted by this light.
  10502. */
  10503. /**
  10504. * Sets the meshes not impacted by this light.
  10505. */
  10506. excludedMeshes: AbstractMesh[];
  10507. private _excludeWithLayerMask;
  10508. /**
  10509. * Gets the layer id use to find what meshes are not impacted by the light.
  10510. * Inactive if 0
  10511. */
  10512. /**
  10513. * Sets the layer id use to find what meshes are not impacted by the light.
  10514. * Inactive if 0
  10515. */
  10516. excludeWithLayerMask: number;
  10517. private _includeOnlyWithLayerMask;
  10518. /**
  10519. * Gets the layer id use to find what meshes are impacted by the light.
  10520. * Inactive if 0
  10521. */
  10522. /**
  10523. * Sets the layer id use to find what meshes are impacted by the light.
  10524. * Inactive if 0
  10525. */
  10526. includeOnlyWithLayerMask: number;
  10527. private _lightmapMode;
  10528. /**
  10529. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10530. */
  10531. /**
  10532. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10533. */
  10534. lightmapMode: number;
  10535. /**
  10536. * Shadow generator associted to the light.
  10537. * @hidden Internal use only.
  10538. */
  10539. _shadowGenerator: Nullable<IShadowGenerator>;
  10540. /**
  10541. * @hidden Internal use only.
  10542. */
  10543. _excludedMeshesIds: string[];
  10544. /**
  10545. * @hidden Internal use only.
  10546. */
  10547. _includedOnlyMeshesIds: string[];
  10548. /**
  10549. * The current light unifom buffer.
  10550. * @hidden Internal use only.
  10551. */
  10552. _uniformBuffer: UniformBuffer;
  10553. /**
  10554. * Creates a Light object in the scene.
  10555. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10556. * @param name The firendly name of the light
  10557. * @param scene The scene the light belongs too
  10558. */
  10559. constructor(name: string, scene: Scene);
  10560. protected abstract _buildUniformLayout(): void;
  10561. /**
  10562. * Sets the passed Effect "effect" with the Light information.
  10563. * @param effect The effect to update
  10564. * @param lightIndex The index of the light in the effect to update
  10565. * @returns The light
  10566. */
  10567. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10568. /**
  10569. * Returns the string "Light".
  10570. * @returns the class name
  10571. */
  10572. getClassName(): string;
  10573. /** @hidden */
  10574. readonly _isLight: boolean;
  10575. /**
  10576. * Converts the light information to a readable string for debug purpose.
  10577. * @param fullDetails Supports for multiple levels of logging within scene loading
  10578. * @returns the human readable light info
  10579. */
  10580. toString(fullDetails?: boolean): string;
  10581. /** @hidden */
  10582. protected _syncParentEnabledState(): void;
  10583. /**
  10584. * Set the enabled state of this node.
  10585. * @param value - the new enabled state
  10586. */
  10587. setEnabled(value: boolean): void;
  10588. /**
  10589. * Returns the Light associated shadow generator if any.
  10590. * @return the associated shadow generator.
  10591. */
  10592. getShadowGenerator(): Nullable<IShadowGenerator>;
  10593. /**
  10594. * Returns a Vector3, the absolute light position in the World.
  10595. * @returns the world space position of the light
  10596. */
  10597. getAbsolutePosition(): Vector3;
  10598. /**
  10599. * Specifies if the light will affect the passed mesh.
  10600. * @param mesh The mesh to test against the light
  10601. * @return true the mesh is affected otherwise, false.
  10602. */
  10603. canAffectMesh(mesh: AbstractMesh): boolean;
  10604. /**
  10605. * Sort function to order lights for rendering.
  10606. * @param a First Light object to compare to second.
  10607. * @param b Second Light object to compare first.
  10608. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10609. */
  10610. static CompareLightsPriority(a: Light, b: Light): number;
  10611. /**
  10612. * Releases resources associated with this node.
  10613. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10614. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10615. */
  10616. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10617. /**
  10618. * Returns the light type ID (integer).
  10619. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10620. */
  10621. getTypeID(): number;
  10622. /**
  10623. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10624. * @returns the scaled intensity in intensity mode unit
  10625. */
  10626. getScaledIntensity(): number;
  10627. /**
  10628. * Returns a new Light object, named "name", from the current one.
  10629. * @param name The name of the cloned light
  10630. * @returns the new created light
  10631. */
  10632. clone(name: string): Nullable<Light>;
  10633. /**
  10634. * Serializes the current light into a Serialization object.
  10635. * @returns the serialized object.
  10636. */
  10637. serialize(): any;
  10638. /**
  10639. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10640. * This new light is named "name" and added to the passed scene.
  10641. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10642. * @param name The friendly name of the light
  10643. * @param scene The scene the new light will belong to
  10644. * @returns the constructor function
  10645. */
  10646. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10647. /**
  10648. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10649. * @param parsedLight The JSON representation of the light
  10650. * @param scene The scene to create the parsed light in
  10651. * @returns the created light after parsing
  10652. */
  10653. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10654. private _hookArrayForExcluded;
  10655. private _hookArrayForIncludedOnly;
  10656. private _resyncMeshes;
  10657. /**
  10658. * Forces the meshes to update their light related information in their rendering used effects
  10659. * @hidden Internal Use Only
  10660. */
  10661. _markMeshesAsLightDirty(): void;
  10662. /**
  10663. * Recomputes the cached photometric scale if needed.
  10664. */
  10665. private _computePhotometricScale;
  10666. /**
  10667. * Returns the Photometric Scale according to the light type and intensity mode.
  10668. */
  10669. private _getPhotometricScale;
  10670. /**
  10671. * Reorder the light in the scene according to their defined priority.
  10672. * @hidden Internal Use Only
  10673. */
  10674. _reorderLightsInScene(): void;
  10675. /**
  10676. * Prepares the list of defines specific to the light type.
  10677. * @param defines the list of defines
  10678. * @param lightIndex defines the index of the light for the effect
  10679. */
  10680. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10681. }
  10682. }
  10683. declare module "babylonjs/Actions/action" {
  10684. import { Observable } from "babylonjs/Misc/observable";
  10685. import { Condition } from "babylonjs/Actions/condition";
  10686. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10687. import { ActionManager } from "babylonjs/Actions/actionManager";
  10688. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10689. /**
  10690. * Interface used to define Action
  10691. */
  10692. export interface IAction {
  10693. /**
  10694. * Trigger for the action
  10695. */
  10696. trigger: number;
  10697. /** Options of the trigger */
  10698. triggerOptions: any;
  10699. /**
  10700. * Gets the trigger parameters
  10701. * @returns the trigger parameters
  10702. */
  10703. getTriggerParameter(): any;
  10704. /**
  10705. * Internal only - executes current action event
  10706. * @hidden
  10707. */
  10708. _executeCurrent(evt?: ActionEvent): void;
  10709. /**
  10710. * Serialize placeholder for child classes
  10711. * @param parent of child
  10712. * @returns the serialized object
  10713. */
  10714. serialize(parent: any): any;
  10715. /**
  10716. * Internal only
  10717. * @hidden
  10718. */
  10719. _prepare(): void;
  10720. /**
  10721. * Internal only - manager for action
  10722. * @hidden
  10723. */
  10724. _actionManager: AbstractActionManager;
  10725. }
  10726. /**
  10727. * The action to be carried out following a trigger
  10728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10729. */
  10730. export class Action implements IAction {
  10731. /** the trigger, with or without parameters, for the action */
  10732. triggerOptions: any;
  10733. /**
  10734. * Trigger for the action
  10735. */
  10736. trigger: number;
  10737. /**
  10738. * Internal only - manager for action
  10739. * @hidden
  10740. */
  10741. _actionManager: ActionManager;
  10742. private _nextActiveAction;
  10743. private _child;
  10744. private _condition?;
  10745. private _triggerParameter;
  10746. /**
  10747. * An event triggered prior to action being executed.
  10748. */
  10749. onBeforeExecuteObservable: Observable<Action>;
  10750. /**
  10751. * Creates a new Action
  10752. * @param triggerOptions the trigger, with or without parameters, for the action
  10753. * @param condition an optional determinant of action
  10754. */
  10755. constructor(
  10756. /** the trigger, with or without parameters, for the action */
  10757. triggerOptions: any, condition?: Condition);
  10758. /**
  10759. * Internal only
  10760. * @hidden
  10761. */
  10762. _prepare(): void;
  10763. /**
  10764. * Gets the trigger parameters
  10765. * @returns the trigger parameters
  10766. */
  10767. getTriggerParameter(): any;
  10768. /**
  10769. * Internal only - executes current action event
  10770. * @hidden
  10771. */
  10772. _executeCurrent(evt?: ActionEvent): void;
  10773. /**
  10774. * Execute placeholder for child classes
  10775. * @param evt optional action event
  10776. */
  10777. execute(evt?: ActionEvent): void;
  10778. /**
  10779. * Skips to next active action
  10780. */
  10781. skipToNextActiveAction(): void;
  10782. /**
  10783. * Adds action to chain of actions, may be a DoNothingAction
  10784. * @param action defines the next action to execute
  10785. * @returns The action passed in
  10786. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10787. */
  10788. then(action: Action): Action;
  10789. /**
  10790. * Internal only
  10791. * @hidden
  10792. */
  10793. _getProperty(propertyPath: string): string;
  10794. /**
  10795. * Internal only
  10796. * @hidden
  10797. */
  10798. _getEffectiveTarget(target: any, propertyPath: string): any;
  10799. /**
  10800. * Serialize placeholder for child classes
  10801. * @param parent of child
  10802. * @returns the serialized object
  10803. */
  10804. serialize(parent: any): any;
  10805. /**
  10806. * Internal only called by serialize
  10807. * @hidden
  10808. */
  10809. protected _serialize(serializedAction: any, parent?: any): any;
  10810. /**
  10811. * Internal only
  10812. * @hidden
  10813. */
  10814. static _SerializeValueAsString: (value: any) => string;
  10815. /**
  10816. * Internal only
  10817. * @hidden
  10818. */
  10819. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10820. name: string;
  10821. targetType: string;
  10822. value: string;
  10823. };
  10824. }
  10825. }
  10826. declare module "babylonjs/Actions/condition" {
  10827. import { ActionManager } from "babylonjs/Actions/actionManager";
  10828. /**
  10829. * A Condition applied to an Action
  10830. */
  10831. export class Condition {
  10832. /**
  10833. * Internal only - manager for action
  10834. * @hidden
  10835. */
  10836. _actionManager: ActionManager;
  10837. /**
  10838. * Internal only
  10839. * @hidden
  10840. */
  10841. _evaluationId: number;
  10842. /**
  10843. * Internal only
  10844. * @hidden
  10845. */
  10846. _currentResult: boolean;
  10847. /**
  10848. * Creates a new Condition
  10849. * @param actionManager the manager of the action the condition is applied to
  10850. */
  10851. constructor(actionManager: ActionManager);
  10852. /**
  10853. * Check if the current condition is valid
  10854. * @returns a boolean
  10855. */
  10856. isValid(): boolean;
  10857. /**
  10858. * Internal only
  10859. * @hidden
  10860. */
  10861. _getProperty(propertyPath: string): string;
  10862. /**
  10863. * Internal only
  10864. * @hidden
  10865. */
  10866. _getEffectiveTarget(target: any, propertyPath: string): any;
  10867. /**
  10868. * Serialize placeholder for child classes
  10869. * @returns the serialized object
  10870. */
  10871. serialize(): any;
  10872. /**
  10873. * Internal only
  10874. * @hidden
  10875. */
  10876. protected _serialize(serializedCondition: any): any;
  10877. }
  10878. /**
  10879. * Defines specific conditional operators as extensions of Condition
  10880. */
  10881. export class ValueCondition extends Condition {
  10882. /** path to specify the property of the target the conditional operator uses */
  10883. propertyPath: string;
  10884. /** the value compared by the conditional operator against the current value of the property */
  10885. value: any;
  10886. /** the conditional operator, default ValueCondition.IsEqual */
  10887. operator: number;
  10888. /**
  10889. * Internal only
  10890. * @hidden
  10891. */
  10892. private static _IsEqual;
  10893. /**
  10894. * Internal only
  10895. * @hidden
  10896. */
  10897. private static _IsDifferent;
  10898. /**
  10899. * Internal only
  10900. * @hidden
  10901. */
  10902. private static _IsGreater;
  10903. /**
  10904. * Internal only
  10905. * @hidden
  10906. */
  10907. private static _IsLesser;
  10908. /**
  10909. * returns the number for IsEqual
  10910. */
  10911. static readonly IsEqual: number;
  10912. /**
  10913. * Returns the number for IsDifferent
  10914. */
  10915. static readonly IsDifferent: number;
  10916. /**
  10917. * Returns the number for IsGreater
  10918. */
  10919. static readonly IsGreater: number;
  10920. /**
  10921. * Returns the number for IsLesser
  10922. */
  10923. static readonly IsLesser: number;
  10924. /**
  10925. * Internal only The action manager for the condition
  10926. * @hidden
  10927. */
  10928. _actionManager: ActionManager;
  10929. /**
  10930. * Internal only
  10931. * @hidden
  10932. */
  10933. private _target;
  10934. /**
  10935. * Internal only
  10936. * @hidden
  10937. */
  10938. private _effectiveTarget;
  10939. /**
  10940. * Internal only
  10941. * @hidden
  10942. */
  10943. private _property;
  10944. /**
  10945. * Creates a new ValueCondition
  10946. * @param actionManager manager for the action the condition applies to
  10947. * @param target for the action
  10948. * @param propertyPath path to specify the property of the target the conditional operator uses
  10949. * @param value the value compared by the conditional operator against the current value of the property
  10950. * @param operator the conditional operator, default ValueCondition.IsEqual
  10951. */
  10952. constructor(actionManager: ActionManager, target: any,
  10953. /** path to specify the property of the target the conditional operator uses */
  10954. propertyPath: string,
  10955. /** the value compared by the conditional operator against the current value of the property */
  10956. value: any,
  10957. /** the conditional operator, default ValueCondition.IsEqual */
  10958. operator?: number);
  10959. /**
  10960. * Compares the given value with the property value for the specified conditional operator
  10961. * @returns the result of the comparison
  10962. */
  10963. isValid(): boolean;
  10964. /**
  10965. * Serialize the ValueCondition into a JSON compatible object
  10966. * @returns serialization object
  10967. */
  10968. serialize(): any;
  10969. /**
  10970. * Gets the name of the conditional operator for the ValueCondition
  10971. * @param operator the conditional operator
  10972. * @returns the name
  10973. */
  10974. static GetOperatorName(operator: number): string;
  10975. }
  10976. /**
  10977. * Defines a predicate condition as an extension of Condition
  10978. */
  10979. export class PredicateCondition extends Condition {
  10980. /** defines the predicate function used to validate the condition */
  10981. predicate: () => boolean;
  10982. /**
  10983. * Internal only - manager for action
  10984. * @hidden
  10985. */
  10986. _actionManager: ActionManager;
  10987. /**
  10988. * Creates a new PredicateCondition
  10989. * @param actionManager manager for the action the condition applies to
  10990. * @param predicate defines the predicate function used to validate the condition
  10991. */
  10992. constructor(actionManager: ActionManager,
  10993. /** defines the predicate function used to validate the condition */
  10994. predicate: () => boolean);
  10995. /**
  10996. * @returns the validity of the predicate condition
  10997. */
  10998. isValid(): boolean;
  10999. }
  11000. /**
  11001. * Defines a state condition as an extension of Condition
  11002. */
  11003. export class StateCondition extends Condition {
  11004. /** Value to compare with target state */
  11005. value: string;
  11006. /**
  11007. * Internal only - manager for action
  11008. * @hidden
  11009. */
  11010. _actionManager: ActionManager;
  11011. /**
  11012. * Internal only
  11013. * @hidden
  11014. */
  11015. private _target;
  11016. /**
  11017. * Creates a new StateCondition
  11018. * @param actionManager manager for the action the condition applies to
  11019. * @param target of the condition
  11020. * @param value to compare with target state
  11021. */
  11022. constructor(actionManager: ActionManager, target: any,
  11023. /** Value to compare with target state */
  11024. value: string);
  11025. /**
  11026. * Gets a boolean indicating if the current condition is met
  11027. * @returns the validity of the state
  11028. */
  11029. isValid(): boolean;
  11030. /**
  11031. * Serialize the StateCondition into a JSON compatible object
  11032. * @returns serialization object
  11033. */
  11034. serialize(): any;
  11035. }
  11036. }
  11037. declare module "babylonjs/Actions/directActions" {
  11038. import { Action } from "babylonjs/Actions/action";
  11039. import { Condition } from "babylonjs/Actions/condition";
  11040. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11041. /**
  11042. * This defines an action responsible to toggle a boolean once triggered.
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11044. */
  11045. export class SwitchBooleanAction extends Action {
  11046. /**
  11047. * The path to the boolean property in the target object
  11048. */
  11049. propertyPath: string;
  11050. private _target;
  11051. private _effectiveTarget;
  11052. private _property;
  11053. /**
  11054. * Instantiate the action
  11055. * @param triggerOptions defines the trigger options
  11056. * @param target defines the object containing the boolean
  11057. * @param propertyPath defines the path to the boolean property in the target object
  11058. * @param condition defines the trigger related conditions
  11059. */
  11060. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11061. /** @hidden */
  11062. _prepare(): void;
  11063. /**
  11064. * Execute the action toggle the boolean value.
  11065. */
  11066. execute(): void;
  11067. /**
  11068. * Serializes the actions and its related information.
  11069. * @param parent defines the object to serialize in
  11070. * @returns the serialized object
  11071. */
  11072. serialize(parent: any): any;
  11073. }
  11074. /**
  11075. * This defines an action responsible to set a the state field of the target
  11076. * to a desired value once triggered.
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11078. */
  11079. export class SetStateAction extends Action {
  11080. /**
  11081. * The value to store in the state field.
  11082. */
  11083. value: string;
  11084. private _target;
  11085. /**
  11086. * Instantiate the action
  11087. * @param triggerOptions defines the trigger options
  11088. * @param target defines the object containing the state property
  11089. * @param value defines the value to store in the state field
  11090. * @param condition defines the trigger related conditions
  11091. */
  11092. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11093. /**
  11094. * Execute the action and store the value on the target state property.
  11095. */
  11096. execute(): void;
  11097. /**
  11098. * Serializes the actions and its related information.
  11099. * @param parent defines the object to serialize in
  11100. * @returns the serialized object
  11101. */
  11102. serialize(parent: any): any;
  11103. }
  11104. /**
  11105. * This defines an action responsible to set a property of the target
  11106. * to a desired value once triggered.
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11108. */
  11109. export class SetValueAction extends Action {
  11110. /**
  11111. * The path of the property to set in the target.
  11112. */
  11113. propertyPath: string;
  11114. /**
  11115. * The value to set in the property
  11116. */
  11117. value: any;
  11118. private _target;
  11119. private _effectiveTarget;
  11120. private _property;
  11121. /**
  11122. * Instantiate the action
  11123. * @param triggerOptions defines the trigger options
  11124. * @param target defines the object containing the property
  11125. * @param propertyPath defines the path of the property to set in the target
  11126. * @param value defines the value to set in the property
  11127. * @param condition defines the trigger related conditions
  11128. */
  11129. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11130. /** @hidden */
  11131. _prepare(): void;
  11132. /**
  11133. * Execute the action and set the targetted property to the desired value.
  11134. */
  11135. execute(): void;
  11136. /**
  11137. * Serializes the actions and its related information.
  11138. * @param parent defines the object to serialize in
  11139. * @returns the serialized object
  11140. */
  11141. serialize(parent: any): any;
  11142. }
  11143. /**
  11144. * This defines an action responsible to increment the target value
  11145. * to a desired value once triggered.
  11146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11147. */
  11148. export class IncrementValueAction extends Action {
  11149. /**
  11150. * The path of the property to increment in the target.
  11151. */
  11152. propertyPath: string;
  11153. /**
  11154. * The value we should increment the property by.
  11155. */
  11156. value: any;
  11157. private _target;
  11158. private _effectiveTarget;
  11159. private _property;
  11160. /**
  11161. * Instantiate the action
  11162. * @param triggerOptions defines the trigger options
  11163. * @param target defines the object containing the property
  11164. * @param propertyPath defines the path of the property to increment in the target
  11165. * @param value defines the value value we should increment the property by
  11166. * @param condition defines the trigger related conditions
  11167. */
  11168. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11169. /** @hidden */
  11170. _prepare(): void;
  11171. /**
  11172. * Execute the action and increment the target of the value amount.
  11173. */
  11174. execute(): void;
  11175. /**
  11176. * Serializes the actions and its related information.
  11177. * @param parent defines the object to serialize in
  11178. * @returns the serialized object
  11179. */
  11180. serialize(parent: any): any;
  11181. }
  11182. /**
  11183. * This defines an action responsible to start an animation once triggered.
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11185. */
  11186. export class PlayAnimationAction extends Action {
  11187. /**
  11188. * Where the animation should start (animation frame)
  11189. */
  11190. from: number;
  11191. /**
  11192. * Where the animation should stop (animation frame)
  11193. */
  11194. to: number;
  11195. /**
  11196. * Define if the animation should loop or stop after the first play.
  11197. */
  11198. loop?: boolean;
  11199. private _target;
  11200. /**
  11201. * Instantiate the action
  11202. * @param triggerOptions defines the trigger options
  11203. * @param target defines the target animation or animation name
  11204. * @param from defines from where the animation should start (animation frame)
  11205. * @param end defines where the animation should stop (animation frame)
  11206. * @param loop defines if the animation should loop or stop after the first play
  11207. * @param condition defines the trigger related conditions
  11208. */
  11209. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11210. /** @hidden */
  11211. _prepare(): void;
  11212. /**
  11213. * Execute the action and play the animation.
  11214. */
  11215. execute(): void;
  11216. /**
  11217. * Serializes the actions and its related information.
  11218. * @param parent defines the object to serialize in
  11219. * @returns the serialized object
  11220. */
  11221. serialize(parent: any): any;
  11222. }
  11223. /**
  11224. * This defines an action responsible to stop an animation once triggered.
  11225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11226. */
  11227. export class StopAnimationAction extends Action {
  11228. private _target;
  11229. /**
  11230. * Instantiate the action
  11231. * @param triggerOptions defines the trigger options
  11232. * @param target defines the target animation or animation name
  11233. * @param condition defines the trigger related conditions
  11234. */
  11235. constructor(triggerOptions: any, target: any, condition?: Condition);
  11236. /** @hidden */
  11237. _prepare(): void;
  11238. /**
  11239. * Execute the action and stop the animation.
  11240. */
  11241. execute(): void;
  11242. /**
  11243. * Serializes the actions and its related information.
  11244. * @param parent defines the object to serialize in
  11245. * @returns the serialized object
  11246. */
  11247. serialize(parent: any): any;
  11248. }
  11249. /**
  11250. * This defines an action responsible that does nothing once triggered.
  11251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11252. */
  11253. export class DoNothingAction extends Action {
  11254. /**
  11255. * Instantiate the action
  11256. * @param triggerOptions defines the trigger options
  11257. * @param condition defines the trigger related conditions
  11258. */
  11259. constructor(triggerOptions?: any, condition?: Condition);
  11260. /**
  11261. * Execute the action and do nothing.
  11262. */
  11263. execute(): void;
  11264. /**
  11265. * Serializes the actions and its related information.
  11266. * @param parent defines the object to serialize in
  11267. * @returns the serialized object
  11268. */
  11269. serialize(parent: any): any;
  11270. }
  11271. /**
  11272. * This defines an action responsible to trigger several actions once triggered.
  11273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11274. */
  11275. export class CombineAction extends Action {
  11276. /**
  11277. * The list of aggregated animations to run.
  11278. */
  11279. children: Action[];
  11280. /**
  11281. * Instantiate the action
  11282. * @param triggerOptions defines the trigger options
  11283. * @param children defines the list of aggregated animations to run
  11284. * @param condition defines the trigger related conditions
  11285. */
  11286. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11287. /** @hidden */
  11288. _prepare(): void;
  11289. /**
  11290. * Execute the action and executes all the aggregated actions.
  11291. */
  11292. execute(evt: ActionEvent): void;
  11293. /**
  11294. * Serializes the actions and its related information.
  11295. * @param parent defines the object to serialize in
  11296. * @returns the serialized object
  11297. */
  11298. serialize(parent: any): any;
  11299. }
  11300. /**
  11301. * This defines an action responsible to run code (external event) once triggered.
  11302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11303. */
  11304. export class ExecuteCodeAction extends Action {
  11305. /**
  11306. * The callback function to run.
  11307. */
  11308. func: (evt: ActionEvent) => void;
  11309. /**
  11310. * Instantiate the action
  11311. * @param triggerOptions defines the trigger options
  11312. * @param func defines the callback function to run
  11313. * @param condition defines the trigger related conditions
  11314. */
  11315. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11316. /**
  11317. * Execute the action and run the attached code.
  11318. */
  11319. execute(evt: ActionEvent): void;
  11320. }
  11321. /**
  11322. * This defines an action responsible to set the parent property of the target once triggered.
  11323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11324. */
  11325. export class SetParentAction extends Action {
  11326. private _parent;
  11327. private _target;
  11328. /**
  11329. * Instantiate the action
  11330. * @param triggerOptions defines the trigger options
  11331. * @param target defines the target containing the parent property
  11332. * @param parent defines from where the animation should start (animation frame)
  11333. * @param condition defines the trigger related conditions
  11334. */
  11335. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11336. /** @hidden */
  11337. _prepare(): void;
  11338. /**
  11339. * Execute the action and set the parent property.
  11340. */
  11341. execute(): void;
  11342. /**
  11343. * Serializes the actions and its related information.
  11344. * @param parent defines the object to serialize in
  11345. * @returns the serialized object
  11346. */
  11347. serialize(parent: any): any;
  11348. }
  11349. }
  11350. declare module "babylonjs/Actions/actionManager" {
  11351. import { Nullable } from "babylonjs/types";
  11352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11353. import { Scene } from "babylonjs/scene";
  11354. import { IAction } from "babylonjs/Actions/action";
  11355. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11356. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11357. /**
  11358. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11359. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11361. */
  11362. export class ActionManager extends AbstractActionManager {
  11363. /**
  11364. * Nothing
  11365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11366. */
  11367. static readonly NothingTrigger: number;
  11368. /**
  11369. * On pick
  11370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11371. */
  11372. static readonly OnPickTrigger: number;
  11373. /**
  11374. * On left pick
  11375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11376. */
  11377. static readonly OnLeftPickTrigger: number;
  11378. /**
  11379. * On right pick
  11380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11381. */
  11382. static readonly OnRightPickTrigger: number;
  11383. /**
  11384. * On center pick
  11385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11386. */
  11387. static readonly OnCenterPickTrigger: number;
  11388. /**
  11389. * On pick down
  11390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11391. */
  11392. static readonly OnPickDownTrigger: number;
  11393. /**
  11394. * On double pick
  11395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11396. */
  11397. static readonly OnDoublePickTrigger: number;
  11398. /**
  11399. * On pick up
  11400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11401. */
  11402. static readonly OnPickUpTrigger: number;
  11403. /**
  11404. * On pick out.
  11405. * This trigger will only be raised if you also declared a OnPickDown
  11406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11407. */
  11408. static readonly OnPickOutTrigger: number;
  11409. /**
  11410. * On long press
  11411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11412. */
  11413. static readonly OnLongPressTrigger: number;
  11414. /**
  11415. * On pointer over
  11416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11417. */
  11418. static readonly OnPointerOverTrigger: number;
  11419. /**
  11420. * On pointer out
  11421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11422. */
  11423. static readonly OnPointerOutTrigger: number;
  11424. /**
  11425. * On every frame
  11426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11427. */
  11428. static readonly OnEveryFrameTrigger: number;
  11429. /**
  11430. * On intersection enter
  11431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11432. */
  11433. static readonly OnIntersectionEnterTrigger: number;
  11434. /**
  11435. * On intersection exit
  11436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11437. */
  11438. static readonly OnIntersectionExitTrigger: number;
  11439. /**
  11440. * On key down
  11441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11442. */
  11443. static readonly OnKeyDownTrigger: number;
  11444. /**
  11445. * On key up
  11446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11447. */
  11448. static readonly OnKeyUpTrigger: number;
  11449. private _scene;
  11450. /**
  11451. * Creates a new action manager
  11452. * @param scene defines the hosting scene
  11453. */
  11454. constructor(scene: Scene);
  11455. /**
  11456. * Releases all associated resources
  11457. */
  11458. dispose(): void;
  11459. /**
  11460. * Gets hosting scene
  11461. * @returns the hosting scene
  11462. */
  11463. getScene(): Scene;
  11464. /**
  11465. * Does this action manager handles actions of any of the given triggers
  11466. * @param triggers defines the triggers to be tested
  11467. * @return a boolean indicating whether one (or more) of the triggers is handled
  11468. */
  11469. hasSpecificTriggers(triggers: number[]): boolean;
  11470. /**
  11471. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11472. * speed.
  11473. * @param triggerA defines the trigger to be tested
  11474. * @param triggerB defines the trigger to be tested
  11475. * @return a boolean indicating whether one (or more) of the triggers is handled
  11476. */
  11477. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11478. /**
  11479. * Does this action manager handles actions of a given trigger
  11480. * @param trigger defines the trigger to be tested
  11481. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11482. * @return whether the trigger is handled
  11483. */
  11484. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11485. /**
  11486. * Does this action manager has pointer triggers
  11487. */
  11488. readonly hasPointerTriggers: boolean;
  11489. /**
  11490. * Does this action manager has pick triggers
  11491. */
  11492. readonly hasPickTriggers: boolean;
  11493. /**
  11494. * Registers an action to this action manager
  11495. * @param action defines the action to be registered
  11496. * @return the action amended (prepared) after registration
  11497. */
  11498. registerAction(action: IAction): Nullable<IAction>;
  11499. /**
  11500. * Unregisters an action to this action manager
  11501. * @param action defines the action to be unregistered
  11502. * @return a boolean indicating whether the action has been unregistered
  11503. */
  11504. unregisterAction(action: IAction): Boolean;
  11505. /**
  11506. * Process a specific trigger
  11507. * @param trigger defines the trigger to process
  11508. * @param evt defines the event details to be processed
  11509. */
  11510. processTrigger(trigger: number, evt?: IActionEvent): void;
  11511. /** @hidden */
  11512. _getEffectiveTarget(target: any, propertyPath: string): any;
  11513. /** @hidden */
  11514. _getProperty(propertyPath: string): string;
  11515. /**
  11516. * Serialize this manager to a JSON object
  11517. * @param name defines the property name to store this manager
  11518. * @returns a JSON representation of this manager
  11519. */
  11520. serialize(name: string): any;
  11521. /**
  11522. * Creates a new ActionManager from a JSON data
  11523. * @param parsedActions defines the JSON data to read from
  11524. * @param object defines the hosting mesh
  11525. * @param scene defines the hosting scene
  11526. */
  11527. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11528. /**
  11529. * Get a trigger name by index
  11530. * @param trigger defines the trigger index
  11531. * @returns a trigger name
  11532. */
  11533. static GetTriggerName(trigger: number): string;
  11534. }
  11535. }
  11536. declare module "babylonjs/Culling/ray" {
  11537. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11538. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11540. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11541. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11542. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11543. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11544. /**
  11545. * Class representing a ray with position and direction
  11546. */
  11547. export class Ray {
  11548. /** origin point */
  11549. origin: Vector3;
  11550. /** direction */
  11551. direction: Vector3;
  11552. /** length of the ray */
  11553. length: number;
  11554. private static readonly TmpVector3;
  11555. private _tmpRay;
  11556. /**
  11557. * Creates a new ray
  11558. * @param origin origin point
  11559. * @param direction direction
  11560. * @param length length of the ray
  11561. */
  11562. constructor(
  11563. /** origin point */
  11564. origin: Vector3,
  11565. /** direction */
  11566. direction: Vector3,
  11567. /** length of the ray */
  11568. length?: number);
  11569. /**
  11570. * Checks if the ray intersects a box
  11571. * @param minimum bound of the box
  11572. * @param maximum bound of the box
  11573. * @param intersectionTreshold extra extend to be added to the box in all direction
  11574. * @returns if the box was hit
  11575. */
  11576. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11577. /**
  11578. * Checks if the ray intersects a box
  11579. * @param box the bounding box to check
  11580. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11581. * @returns if the box was hit
  11582. */
  11583. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11584. /**
  11585. * If the ray hits a sphere
  11586. * @param sphere the bounding sphere to check
  11587. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11588. * @returns true if it hits the sphere
  11589. */
  11590. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11591. /**
  11592. * If the ray hits a triange
  11593. * @param vertex0 triangle vertex
  11594. * @param vertex1 triangle vertex
  11595. * @param vertex2 triangle vertex
  11596. * @returns intersection information if hit
  11597. */
  11598. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11599. /**
  11600. * Checks if ray intersects a plane
  11601. * @param plane the plane to check
  11602. * @returns the distance away it was hit
  11603. */
  11604. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11605. /**
  11606. * Checks if ray intersects a mesh
  11607. * @param mesh the mesh to check
  11608. * @param fastCheck if only the bounding box should checked
  11609. * @returns picking info of the intersecton
  11610. */
  11611. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11612. /**
  11613. * Checks if ray intersects a mesh
  11614. * @param meshes the meshes to check
  11615. * @param fastCheck if only the bounding box should checked
  11616. * @param results array to store result in
  11617. * @returns Array of picking infos
  11618. */
  11619. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11620. private _comparePickingInfo;
  11621. private static smallnum;
  11622. private static rayl;
  11623. /**
  11624. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11625. * @param sega the first point of the segment to test the intersection against
  11626. * @param segb the second point of the segment to test the intersection against
  11627. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11628. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11629. */
  11630. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11631. /**
  11632. * Update the ray from viewport position
  11633. * @param x position
  11634. * @param y y position
  11635. * @param viewportWidth viewport width
  11636. * @param viewportHeight viewport height
  11637. * @param world world matrix
  11638. * @param view view matrix
  11639. * @param projection projection matrix
  11640. * @returns this ray updated
  11641. */
  11642. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11643. /**
  11644. * Creates a ray with origin and direction of 0,0,0
  11645. * @returns the new ray
  11646. */
  11647. static Zero(): Ray;
  11648. /**
  11649. * Creates a new ray from screen space and viewport
  11650. * @param x position
  11651. * @param y y position
  11652. * @param viewportWidth viewport width
  11653. * @param viewportHeight viewport height
  11654. * @param world world matrix
  11655. * @param view view matrix
  11656. * @param projection projection matrix
  11657. * @returns new ray
  11658. */
  11659. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11660. /**
  11661. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11662. * transformed to the given world matrix.
  11663. * @param origin The origin point
  11664. * @param end The end point
  11665. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11666. * @returns the new ray
  11667. */
  11668. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11669. /**
  11670. * Transforms a ray by a matrix
  11671. * @param ray ray to transform
  11672. * @param matrix matrix to apply
  11673. * @returns the resulting new ray
  11674. */
  11675. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11676. /**
  11677. * Transforms a ray by a matrix
  11678. * @param ray ray to transform
  11679. * @param matrix matrix to apply
  11680. * @param result ray to store result in
  11681. */
  11682. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11683. /**
  11684. * Unproject a ray from screen space to object space
  11685. * @param sourceX defines the screen space x coordinate to use
  11686. * @param sourceY defines the screen space y coordinate to use
  11687. * @param viewportWidth defines the current width of the viewport
  11688. * @param viewportHeight defines the current height of the viewport
  11689. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11690. * @param view defines the view matrix to use
  11691. * @param projection defines the projection matrix to use
  11692. */
  11693. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11694. }
  11695. /**
  11696. * Type used to define predicate used to select faces when a mesh intersection is detected
  11697. */
  11698. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11699. module "babylonjs/scene" {
  11700. interface Scene {
  11701. /** @hidden */
  11702. _tempPickingRay: Nullable<Ray>;
  11703. /** @hidden */
  11704. _cachedRayForTransform: Ray;
  11705. /** @hidden */
  11706. _pickWithRayInverseMatrix: Matrix;
  11707. /** @hidden */
  11708. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11709. /** @hidden */
  11710. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11711. }
  11712. }
  11713. }
  11714. declare module "babylonjs/sceneComponent" {
  11715. import { Scene } from "babylonjs/scene";
  11716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11717. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11718. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11719. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11720. import { Nullable } from "babylonjs/types";
  11721. import { Camera } from "babylonjs/Cameras/camera";
  11722. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11723. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11724. import { AbstractScene } from "babylonjs/abstractScene";
  11725. /**
  11726. * Groups all the scene component constants in one place to ease maintenance.
  11727. * @hidden
  11728. */
  11729. export class SceneComponentConstants {
  11730. static readonly NAME_EFFECTLAYER: string;
  11731. static readonly NAME_LAYER: string;
  11732. static readonly NAME_LENSFLARESYSTEM: string;
  11733. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11734. static readonly NAME_PARTICLESYSTEM: string;
  11735. static readonly NAME_GAMEPAD: string;
  11736. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11737. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11738. static readonly NAME_DEPTHRENDERER: string;
  11739. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11740. static readonly NAME_SPRITE: string;
  11741. static readonly NAME_OUTLINERENDERER: string;
  11742. static readonly NAME_PROCEDURALTEXTURE: string;
  11743. static readonly NAME_SHADOWGENERATOR: string;
  11744. static readonly NAME_OCTREE: string;
  11745. static readonly NAME_PHYSICSENGINE: string;
  11746. static readonly NAME_AUDIO: string;
  11747. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11748. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11749. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11750. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11751. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11752. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11753. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11754. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11755. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11756. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11757. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11758. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11759. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11760. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11761. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11762. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11763. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11764. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11765. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11766. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11767. static readonly STEP_AFTERRENDER_AUDIO: number;
  11768. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11769. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11770. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11771. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11772. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11773. static readonly STEP_POINTERMOVE_SPRITE: number;
  11774. static readonly STEP_POINTERDOWN_SPRITE: number;
  11775. static readonly STEP_POINTERUP_SPRITE: number;
  11776. }
  11777. /**
  11778. * This represents a scene component.
  11779. *
  11780. * This is used to decouple the dependency the scene is having on the different workloads like
  11781. * layers, post processes...
  11782. */
  11783. export interface ISceneComponent {
  11784. /**
  11785. * The name of the component. Each component must have a unique name.
  11786. */
  11787. name: string;
  11788. /**
  11789. * The scene the component belongs to.
  11790. */
  11791. scene: Scene;
  11792. /**
  11793. * Register the component to one instance of a scene.
  11794. */
  11795. register(): void;
  11796. /**
  11797. * Rebuilds the elements related to this component in case of
  11798. * context lost for instance.
  11799. */
  11800. rebuild(): void;
  11801. /**
  11802. * Disposes the component and the associated ressources.
  11803. */
  11804. dispose(): void;
  11805. }
  11806. /**
  11807. * This represents a SERIALIZABLE scene component.
  11808. *
  11809. * This extends Scene Component to add Serialization methods on top.
  11810. */
  11811. export interface ISceneSerializableComponent extends ISceneComponent {
  11812. /**
  11813. * Adds all the element from the container to the scene
  11814. * @param container the container holding the elements
  11815. */
  11816. addFromContainer(container: AbstractScene): void;
  11817. /**
  11818. * Removes all the elements in the container from the scene
  11819. * @param container contains the elements to remove
  11820. * @param dispose if the removed element should be disposed (default: false)
  11821. */
  11822. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11823. /**
  11824. * Serializes the component data to the specified json object
  11825. * @param serializationObject The object to serialize to
  11826. */
  11827. serialize(serializationObject: any): void;
  11828. }
  11829. /**
  11830. * Strong typing of a Mesh related stage step action
  11831. */
  11832. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11833. /**
  11834. * Strong typing of a Evaluate Sub Mesh related stage step action
  11835. */
  11836. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11837. /**
  11838. * Strong typing of a Active Mesh related stage step action
  11839. */
  11840. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11841. /**
  11842. * Strong typing of a Camera related stage step action
  11843. */
  11844. export type CameraStageAction = (camera: Camera) => void;
  11845. /**
  11846. * Strong typing of a Camera Frame buffer related stage step action
  11847. */
  11848. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11849. /**
  11850. * Strong typing of a Render Target related stage step action
  11851. */
  11852. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11853. /**
  11854. * Strong typing of a RenderingGroup related stage step action
  11855. */
  11856. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11857. /**
  11858. * Strong typing of a Mesh Render related stage step action
  11859. */
  11860. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11861. /**
  11862. * Strong typing of a simple stage step action
  11863. */
  11864. export type SimpleStageAction = () => void;
  11865. /**
  11866. * Strong typing of a render target action.
  11867. */
  11868. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11869. /**
  11870. * Strong typing of a pointer move action.
  11871. */
  11872. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11873. /**
  11874. * Strong typing of a pointer up/down action.
  11875. */
  11876. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11877. /**
  11878. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11879. * @hidden
  11880. */
  11881. export class Stage<T extends Function> extends Array<{
  11882. index: number;
  11883. component: ISceneComponent;
  11884. action: T;
  11885. }> {
  11886. /**
  11887. * Hide ctor from the rest of the world.
  11888. * @param items The items to add.
  11889. */
  11890. private constructor();
  11891. /**
  11892. * Creates a new Stage.
  11893. * @returns A new instance of a Stage
  11894. */
  11895. static Create<T extends Function>(): Stage<T>;
  11896. /**
  11897. * Registers a step in an ordered way in the targeted stage.
  11898. * @param index Defines the position to register the step in
  11899. * @param component Defines the component attached to the step
  11900. * @param action Defines the action to launch during the step
  11901. */
  11902. registerStep(index: number, component: ISceneComponent, action: T): void;
  11903. /**
  11904. * Clears all the steps from the stage.
  11905. */
  11906. clear(): void;
  11907. }
  11908. }
  11909. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11910. import { Nullable } from "babylonjs/types";
  11911. import { Observable } from "babylonjs/Misc/observable";
  11912. import { Scene } from "babylonjs/scene";
  11913. import { Sprite } from "babylonjs/Sprites/sprite";
  11914. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11915. import { Ray } from "babylonjs/Culling/ray";
  11916. import { Camera } from "babylonjs/Cameras/camera";
  11917. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11918. import { ISceneComponent } from "babylonjs/sceneComponent";
  11919. module "babylonjs/scene" {
  11920. interface Scene {
  11921. /** @hidden */
  11922. _pointerOverSprite: Nullable<Sprite>;
  11923. /** @hidden */
  11924. _pickedDownSprite: Nullable<Sprite>;
  11925. /** @hidden */
  11926. _tempSpritePickingRay: Nullable<Ray>;
  11927. /**
  11928. * All of the sprite managers added to this scene
  11929. * @see http://doc.babylonjs.com/babylon101/sprites
  11930. */
  11931. spriteManagers: Array<ISpriteManager>;
  11932. /**
  11933. * An event triggered when sprites rendering is about to start
  11934. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11935. */
  11936. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11937. /**
  11938. * An event triggered when sprites rendering is done
  11939. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11940. */
  11941. onAfterSpritesRenderingObservable: Observable<Scene>;
  11942. /** @hidden */
  11943. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11944. /** Launch a ray to try to pick a sprite in the scene
  11945. * @param x position on screen
  11946. * @param y position on screen
  11947. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11948. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11949. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11950. * @returns a PickingInfo
  11951. */
  11952. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11953. /** Use the given ray to pick a sprite in the scene
  11954. * @param ray The ray (in world space) to use to pick meshes
  11955. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11956. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11957. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11958. * @returns a PickingInfo
  11959. */
  11960. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11961. /**
  11962. * Force the sprite under the pointer
  11963. * @param sprite defines the sprite to use
  11964. */
  11965. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11966. /**
  11967. * Gets the sprite under the pointer
  11968. * @returns a Sprite or null if no sprite is under the pointer
  11969. */
  11970. getPointerOverSprite(): Nullable<Sprite>;
  11971. }
  11972. }
  11973. /**
  11974. * Defines the sprite scene component responsible to manage sprites
  11975. * in a given scene.
  11976. */
  11977. export class SpriteSceneComponent implements ISceneComponent {
  11978. /**
  11979. * The component name helpfull to identify the component in the list of scene components.
  11980. */
  11981. readonly name: string;
  11982. /**
  11983. * The scene the component belongs to.
  11984. */
  11985. scene: Scene;
  11986. /** @hidden */
  11987. private _spritePredicate;
  11988. /**
  11989. * Creates a new instance of the component for the given scene
  11990. * @param scene Defines the scene to register the component in
  11991. */
  11992. constructor(scene: Scene);
  11993. /**
  11994. * Registers the component in a given scene
  11995. */
  11996. register(): void;
  11997. /**
  11998. * Rebuilds the elements related to this component in case of
  11999. * context lost for instance.
  12000. */
  12001. rebuild(): void;
  12002. /**
  12003. * Disposes the component and the associated ressources.
  12004. */
  12005. dispose(): void;
  12006. private _pickSpriteButKeepRay;
  12007. private _pointerMove;
  12008. private _pointerDown;
  12009. private _pointerUp;
  12010. }
  12011. }
  12012. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12013. /** @hidden */
  12014. export var fogFragmentDeclaration: {
  12015. name: string;
  12016. shader: string;
  12017. };
  12018. }
  12019. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12020. /** @hidden */
  12021. export var fogFragment: {
  12022. name: string;
  12023. shader: string;
  12024. };
  12025. }
  12026. declare module "babylonjs/Shaders/sprites.fragment" {
  12027. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12028. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12029. /** @hidden */
  12030. export var spritesPixelShader: {
  12031. name: string;
  12032. shader: string;
  12033. };
  12034. }
  12035. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12036. /** @hidden */
  12037. export var fogVertexDeclaration: {
  12038. name: string;
  12039. shader: string;
  12040. };
  12041. }
  12042. declare module "babylonjs/Shaders/sprites.vertex" {
  12043. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12044. /** @hidden */
  12045. export var spritesVertexShader: {
  12046. name: string;
  12047. shader: string;
  12048. };
  12049. }
  12050. declare module "babylonjs/Sprites/spriteManager" {
  12051. import { IDisposable, Scene } from "babylonjs/scene";
  12052. import { Nullable } from "babylonjs/types";
  12053. import { Observable } from "babylonjs/Misc/observable";
  12054. import { Sprite } from "babylonjs/Sprites/sprite";
  12055. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12056. import { Camera } from "babylonjs/Cameras/camera";
  12057. import { Texture } from "babylonjs/Materials/Textures/texture";
  12058. import "babylonjs/Shaders/sprites.fragment";
  12059. import "babylonjs/Shaders/sprites.vertex";
  12060. import { Ray } from "babylonjs/Culling/ray";
  12061. /**
  12062. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12063. */
  12064. export interface ISpriteManager extends IDisposable {
  12065. /**
  12066. * Restricts the camera to viewing objects with the same layerMask.
  12067. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12068. */
  12069. layerMask: number;
  12070. /**
  12071. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12072. */
  12073. isPickable: boolean;
  12074. /**
  12075. * Specifies the rendering group id for this mesh (0 by default)
  12076. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12077. */
  12078. renderingGroupId: number;
  12079. /**
  12080. * Defines the list of sprites managed by the manager.
  12081. */
  12082. sprites: Array<Sprite>;
  12083. /**
  12084. * Tests the intersection of a sprite with a specific ray.
  12085. * @param ray The ray we are sending to test the collision
  12086. * @param camera The camera space we are sending rays in
  12087. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12088. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12089. * @returns picking info or null.
  12090. */
  12091. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12092. /**
  12093. * Renders the list of sprites on screen.
  12094. */
  12095. render(): void;
  12096. }
  12097. /**
  12098. * Class used to manage multiple sprites on the same spritesheet
  12099. * @see http://doc.babylonjs.com/babylon101/sprites
  12100. */
  12101. export class SpriteManager implements ISpriteManager {
  12102. /** defines the manager's name */
  12103. name: string;
  12104. /** Gets the list of sprites */
  12105. sprites: Sprite[];
  12106. /** Gets or sets the rendering group id (0 by default) */
  12107. renderingGroupId: number;
  12108. /** Gets or sets camera layer mask */
  12109. layerMask: number;
  12110. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12111. fogEnabled: boolean;
  12112. /** Gets or sets a boolean indicating if the sprites are pickable */
  12113. isPickable: boolean;
  12114. /** Defines the default width of a cell in the spritesheet */
  12115. cellWidth: number;
  12116. /** Defines the default height of a cell in the spritesheet */
  12117. cellHeight: number;
  12118. /**
  12119. * An event triggered when the manager is disposed.
  12120. */
  12121. onDisposeObservable: Observable<SpriteManager>;
  12122. private _onDisposeObserver;
  12123. /**
  12124. * Callback called when the manager is disposed
  12125. */
  12126. onDispose: () => void;
  12127. private _capacity;
  12128. private _spriteTexture;
  12129. private _epsilon;
  12130. private _scene;
  12131. private _vertexData;
  12132. private _buffer;
  12133. private _vertexBuffers;
  12134. private _indexBuffer;
  12135. private _effectBase;
  12136. private _effectFog;
  12137. /**
  12138. * Gets or sets the spritesheet texture
  12139. */
  12140. texture: Texture;
  12141. /**
  12142. * Creates a new sprite manager
  12143. * @param name defines the manager's name
  12144. * @param imgUrl defines the sprite sheet url
  12145. * @param capacity defines the maximum allowed number of sprites
  12146. * @param cellSize defines the size of a sprite cell
  12147. * @param scene defines the hosting scene
  12148. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12149. * @param samplingMode defines the smapling mode to use with spritesheet
  12150. */
  12151. constructor(
  12152. /** defines the manager's name */
  12153. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12154. private _appendSpriteVertex;
  12155. /**
  12156. * Intersects the sprites with a ray
  12157. * @param ray defines the ray to intersect with
  12158. * @param camera defines the current active camera
  12159. * @param predicate defines a predicate used to select candidate sprites
  12160. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12161. * @returns null if no hit or a PickingInfo
  12162. */
  12163. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12164. /**
  12165. * Render all child sprites
  12166. */
  12167. render(): void;
  12168. /**
  12169. * Release associated resources
  12170. */
  12171. dispose(): void;
  12172. }
  12173. }
  12174. declare module "babylonjs/Sprites/sprite" {
  12175. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12176. import { Nullable } from "babylonjs/types";
  12177. import { ActionManager } from "babylonjs/Actions/actionManager";
  12178. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12179. /**
  12180. * Class used to represent a sprite
  12181. * @see http://doc.babylonjs.com/babylon101/sprites
  12182. */
  12183. export class Sprite {
  12184. /** defines the name */
  12185. name: string;
  12186. /** Gets or sets the current world position */
  12187. position: Vector3;
  12188. /** Gets or sets the main color */
  12189. color: Color4;
  12190. /** Gets or sets the width */
  12191. width: number;
  12192. /** Gets or sets the height */
  12193. height: number;
  12194. /** Gets or sets rotation angle */
  12195. angle: number;
  12196. /** Gets or sets the cell index in the sprite sheet */
  12197. cellIndex: number;
  12198. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12199. invertU: number;
  12200. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12201. invertV: number;
  12202. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12203. disposeWhenFinishedAnimating: boolean;
  12204. /** Gets the list of attached animations */
  12205. animations: Animation[];
  12206. /** Gets or sets a boolean indicating if the sprite can be picked */
  12207. isPickable: boolean;
  12208. /**
  12209. * Gets or sets the associated action manager
  12210. */
  12211. actionManager: Nullable<ActionManager>;
  12212. private _animationStarted;
  12213. private _loopAnimation;
  12214. private _fromIndex;
  12215. private _toIndex;
  12216. private _delay;
  12217. private _direction;
  12218. private _manager;
  12219. private _time;
  12220. private _onAnimationEnd;
  12221. /**
  12222. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12223. */
  12224. isVisible: boolean;
  12225. /**
  12226. * Gets or sets the sprite size
  12227. */
  12228. size: number;
  12229. /**
  12230. * Creates a new Sprite
  12231. * @param name defines the name
  12232. * @param manager defines the manager
  12233. */
  12234. constructor(
  12235. /** defines the name */
  12236. name: string, manager: ISpriteManager);
  12237. /**
  12238. * Starts an animation
  12239. * @param from defines the initial key
  12240. * @param to defines the end key
  12241. * @param loop defines if the animation must loop
  12242. * @param delay defines the start delay (in ms)
  12243. * @param onAnimationEnd defines a callback to call when animation ends
  12244. */
  12245. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12246. /** Stops current animation (if any) */
  12247. stopAnimation(): void;
  12248. /** @hidden */
  12249. _animate(deltaTime: number): void;
  12250. /** Release associated resources */
  12251. dispose(): void;
  12252. }
  12253. }
  12254. declare module "babylonjs/Collisions/pickingInfo" {
  12255. import { Nullable } from "babylonjs/types";
  12256. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12258. import { Sprite } from "babylonjs/Sprites/sprite";
  12259. import { Ray } from "babylonjs/Culling/ray";
  12260. /**
  12261. * Information about the result of picking within a scene
  12262. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12263. */
  12264. export class PickingInfo {
  12265. /** @hidden */
  12266. _pickingUnavailable: boolean;
  12267. /**
  12268. * If the pick collided with an object
  12269. */
  12270. hit: boolean;
  12271. /**
  12272. * Distance away where the pick collided
  12273. */
  12274. distance: number;
  12275. /**
  12276. * The location of pick collision
  12277. */
  12278. pickedPoint: Nullable<Vector3>;
  12279. /**
  12280. * The mesh corresponding the the pick collision
  12281. */
  12282. pickedMesh: Nullable<AbstractMesh>;
  12283. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12284. bu: number;
  12285. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12286. bv: number;
  12287. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12288. faceId: number;
  12289. /** Id of the the submesh that was picked */
  12290. subMeshId: number;
  12291. /** If a sprite was picked, this will be the sprite the pick collided with */
  12292. pickedSprite: Nullable<Sprite>;
  12293. /**
  12294. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12295. */
  12296. originMesh: Nullable<AbstractMesh>;
  12297. /**
  12298. * The ray that was used to perform the picking.
  12299. */
  12300. ray: Nullable<Ray>;
  12301. /**
  12302. * Gets the normal correspodning to the face the pick collided with
  12303. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12304. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12305. * @returns The normal correspodning to the face the pick collided with
  12306. */
  12307. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12308. /**
  12309. * Gets the texture coordinates of where the pick occured
  12310. * @returns the vector containing the coordnates of the texture
  12311. */
  12312. getTextureCoordinates(): Nullable<Vector2>;
  12313. }
  12314. }
  12315. declare module "babylonjs/Events/pointerEvents" {
  12316. import { Nullable } from "babylonjs/types";
  12317. import { Vector2 } from "babylonjs/Maths/math";
  12318. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12319. import { Ray } from "babylonjs/Culling/ray";
  12320. /**
  12321. * Gather the list of pointer event types as constants.
  12322. */
  12323. export class PointerEventTypes {
  12324. /**
  12325. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  12326. */
  12327. static readonly POINTERDOWN: number;
  12328. /**
  12329. * The pointerup event is fired when a pointer is no longer active.
  12330. */
  12331. static readonly POINTERUP: number;
  12332. /**
  12333. * The pointermove event is fired when a pointer changes coordinates.
  12334. */
  12335. static readonly POINTERMOVE: number;
  12336. /**
  12337. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12338. */
  12339. static readonly POINTERWHEEL: number;
  12340. /**
  12341. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12342. */
  12343. static readonly POINTERPICK: number;
  12344. /**
  12345. * The pointertap event is fired when a the object has been touched and released without drag.
  12346. */
  12347. static readonly POINTERTAP: number;
  12348. /**
  12349. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12350. */
  12351. static readonly POINTERDOUBLETAP: number;
  12352. }
  12353. /**
  12354. * Base class of pointer info types.
  12355. */
  12356. export class PointerInfoBase {
  12357. /**
  12358. * Defines the type of event (PointerEventTypes)
  12359. */
  12360. type: number;
  12361. /**
  12362. * Defines the related dom event
  12363. */
  12364. event: PointerEvent | MouseWheelEvent;
  12365. /**
  12366. * Instantiates the base class of pointers info.
  12367. * @param type Defines the type of event (PointerEventTypes)
  12368. * @param event Defines the related dom event
  12369. */
  12370. constructor(
  12371. /**
  12372. * Defines the type of event (PointerEventTypes)
  12373. */
  12374. type: number,
  12375. /**
  12376. * Defines the related dom event
  12377. */
  12378. event: PointerEvent | MouseWheelEvent);
  12379. }
  12380. /**
  12381. * This class is used to store pointer related info for the onPrePointerObservable event.
  12382. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12383. */
  12384. export class PointerInfoPre extends PointerInfoBase {
  12385. /**
  12386. * Ray from a pointer if availible (eg. 6dof controller)
  12387. */
  12388. ray: Nullable<Ray>;
  12389. /**
  12390. * Defines the local position of the pointer on the canvas.
  12391. */
  12392. localPosition: Vector2;
  12393. /**
  12394. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12395. */
  12396. skipOnPointerObservable: boolean;
  12397. /**
  12398. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12399. * @param type Defines the type of event (PointerEventTypes)
  12400. * @param event Defines the related dom event
  12401. * @param localX Defines the local x coordinates of the pointer when the event occured
  12402. * @param localY Defines the local y coordinates of the pointer when the event occured
  12403. */
  12404. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12405. }
  12406. /**
  12407. * This type contains all the data related to a pointer event in Babylon.js.
  12408. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12409. */
  12410. export class PointerInfo extends PointerInfoBase {
  12411. /**
  12412. * Defines the picking info associated to the info (if any)\
  12413. */
  12414. pickInfo: Nullable<PickingInfo>;
  12415. /**
  12416. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12417. * @param type Defines the type of event (PointerEventTypes)
  12418. * @param event Defines the related dom event
  12419. * @param pickInfo Defines the picking info associated to the info (if any)\
  12420. */
  12421. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12422. /**
  12423. * Defines the picking info associated to the info (if any)\
  12424. */
  12425. pickInfo: Nullable<PickingInfo>);
  12426. }
  12427. /**
  12428. * Data relating to a touch event on the screen.
  12429. */
  12430. export interface PointerTouch {
  12431. /**
  12432. * X coordinate of touch.
  12433. */
  12434. x: number;
  12435. /**
  12436. * Y coordinate of touch.
  12437. */
  12438. y: number;
  12439. /**
  12440. * Id of touch. Unique for each finger.
  12441. */
  12442. pointerId: number;
  12443. /**
  12444. * Event type passed from DOM.
  12445. */
  12446. type: any;
  12447. }
  12448. }
  12449. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12450. import { Observable } from "babylonjs/Misc/observable";
  12451. import { Nullable } from "babylonjs/types";
  12452. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12453. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12454. /**
  12455. * Manage the mouse inputs to control the movement of a free camera.
  12456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12457. */
  12458. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12459. /**
  12460. * Define if touch is enabled in the mouse input
  12461. */
  12462. touchEnabled: boolean;
  12463. /**
  12464. * Defines the camera the input is attached to.
  12465. */
  12466. camera: FreeCamera;
  12467. /**
  12468. * Defines the buttons associated with the input to handle camera move.
  12469. */
  12470. buttons: number[];
  12471. /**
  12472. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12473. */
  12474. angularSensibility: number;
  12475. private _pointerInput;
  12476. private _onMouseMove;
  12477. private _observer;
  12478. private previousPosition;
  12479. /**
  12480. * Observable for when a pointer move event occurs containing the move offset
  12481. */
  12482. onPointerMovedObservable: Observable<{
  12483. offsetX: number;
  12484. offsetY: number;
  12485. }>;
  12486. /**
  12487. * @hidden
  12488. * If the camera should be rotated automatically based on pointer movement
  12489. */
  12490. _allowCameraRotation: boolean;
  12491. /**
  12492. * Manage the mouse inputs to control the movement of a free camera.
  12493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12494. * @param touchEnabled Defines if touch is enabled or not
  12495. */
  12496. constructor(
  12497. /**
  12498. * Define if touch is enabled in the mouse input
  12499. */
  12500. touchEnabled?: boolean);
  12501. /**
  12502. * Attach the input controls to a specific dom element to get the input from.
  12503. * @param element Defines the element the controls should be listened from
  12504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12505. */
  12506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12507. /**
  12508. * Called on JS contextmenu event.
  12509. * Override this method to provide functionality.
  12510. */
  12511. protected onContextMenu(evt: PointerEvent): void;
  12512. /**
  12513. * Detach the current controls from the specified dom element.
  12514. * @param element Defines the element to stop listening the inputs from
  12515. */
  12516. detachControl(element: Nullable<HTMLElement>): void;
  12517. /**
  12518. * Gets the class name of the current intput.
  12519. * @returns the class name
  12520. */
  12521. getClassName(): string;
  12522. /**
  12523. * Get the friendly name associated with the input class.
  12524. * @returns the input friendly name
  12525. */
  12526. getSimpleName(): string;
  12527. }
  12528. }
  12529. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12530. import { Nullable } from "babylonjs/types";
  12531. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12532. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12533. /**
  12534. * Manage the touch inputs to control the movement of a free camera.
  12535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12536. */
  12537. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12538. /**
  12539. * Defines the camera the input is attached to.
  12540. */
  12541. camera: FreeCamera;
  12542. /**
  12543. * Defines the touch sensibility for rotation.
  12544. * The higher the faster.
  12545. */
  12546. touchAngularSensibility: number;
  12547. /**
  12548. * Defines the touch sensibility for move.
  12549. * The higher the faster.
  12550. */
  12551. touchMoveSensibility: number;
  12552. private _offsetX;
  12553. private _offsetY;
  12554. private _pointerPressed;
  12555. private _pointerInput;
  12556. private _observer;
  12557. private _onLostFocus;
  12558. /**
  12559. * Attach the input controls to a specific dom element to get the input from.
  12560. * @param element Defines the element the controls should be listened from
  12561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12562. */
  12563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12564. /**
  12565. * Detach the current controls from the specified dom element.
  12566. * @param element Defines the element to stop listening the inputs from
  12567. */
  12568. detachControl(element: Nullable<HTMLElement>): void;
  12569. /**
  12570. * Update the current camera state depending on the inputs that have been used this frame.
  12571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12572. */
  12573. checkInputs(): void;
  12574. /**
  12575. * Gets the class name of the current intput.
  12576. * @returns the class name
  12577. */
  12578. getClassName(): string;
  12579. /**
  12580. * Get the friendly name associated with the input class.
  12581. * @returns the input friendly name
  12582. */
  12583. getSimpleName(): string;
  12584. }
  12585. }
  12586. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12588. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12589. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12590. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12591. import { Nullable } from "babylonjs/types";
  12592. /**
  12593. * Default Inputs manager for the FreeCamera.
  12594. * It groups all the default supported inputs for ease of use.
  12595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12596. */
  12597. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12598. /**
  12599. * @hidden
  12600. */
  12601. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12602. /**
  12603. * @hidden
  12604. */
  12605. _mouseInput: Nullable<FreeCameraMouseInput>;
  12606. /**
  12607. * Instantiates a new FreeCameraInputsManager.
  12608. * @param camera Defines the camera the inputs belong to
  12609. */
  12610. constructor(camera: FreeCamera);
  12611. /**
  12612. * Add keyboard input support to the input manager.
  12613. * @returns the current input manager
  12614. */
  12615. addKeyboard(): FreeCameraInputsManager;
  12616. /**
  12617. * Add mouse input support to the input manager.
  12618. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12619. * @returns the current input manager
  12620. */
  12621. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12622. /**
  12623. * Removes the mouse input support from the manager
  12624. * @returns the current input manager
  12625. */
  12626. removeMouse(): FreeCameraInputsManager;
  12627. /**
  12628. * Add touch input support to the input manager.
  12629. * @returns the current input manager
  12630. */
  12631. addTouch(): FreeCameraInputsManager;
  12632. }
  12633. }
  12634. declare module "babylonjs/Cameras/freeCamera" {
  12635. import { Vector3 } from "babylonjs/Maths/math";
  12636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12637. import { Scene } from "babylonjs/scene";
  12638. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12639. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12640. /**
  12641. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12642. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12643. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12644. */
  12645. export class FreeCamera extends TargetCamera {
  12646. /**
  12647. * Define the collision ellipsoid of the camera.
  12648. * This is helpful to simulate a camera body like the player body around the camera
  12649. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12650. */
  12651. ellipsoid: Vector3;
  12652. /**
  12653. * Define an offset for the position of the ellipsoid around the camera.
  12654. * This can be helpful to determine the center of the body near the gravity center of the body
  12655. * instead of its head.
  12656. */
  12657. ellipsoidOffset: Vector3;
  12658. /**
  12659. * Enable or disable collisions of the camera with the rest of the scene objects.
  12660. */
  12661. checkCollisions: boolean;
  12662. /**
  12663. * Enable or disable gravity on the camera.
  12664. */
  12665. applyGravity: boolean;
  12666. /**
  12667. * Define the input manager associated to the camera.
  12668. */
  12669. inputs: FreeCameraInputsManager;
  12670. /**
  12671. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12672. * Higher values reduce sensitivity.
  12673. */
  12674. /**
  12675. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12676. * Higher values reduce sensitivity.
  12677. */
  12678. angularSensibility: number;
  12679. /**
  12680. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12681. */
  12682. keysUp: number[];
  12683. /**
  12684. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12685. */
  12686. keysDown: number[];
  12687. /**
  12688. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12689. */
  12690. keysLeft: number[];
  12691. /**
  12692. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12693. */
  12694. keysRight: number[];
  12695. /**
  12696. * Event raised when the camera collide with a mesh in the scene.
  12697. */
  12698. onCollide: (collidedMesh: AbstractMesh) => void;
  12699. private _collider;
  12700. private _needMoveForGravity;
  12701. private _oldPosition;
  12702. private _diffPosition;
  12703. private _newPosition;
  12704. /** @hidden */
  12705. _localDirection: Vector3;
  12706. /** @hidden */
  12707. _transformedDirection: Vector3;
  12708. /**
  12709. * Instantiates a Free Camera.
  12710. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12711. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12712. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12713. * @param name Define the name of the camera in the scene
  12714. * @param position Define the start position of the camera in the scene
  12715. * @param scene Define the scene the camera belongs to
  12716. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12717. */
  12718. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12719. /**
  12720. * Attached controls to the current camera.
  12721. * @param element Defines the element the controls should be listened from
  12722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12723. */
  12724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12725. /**
  12726. * Detach the current controls from the camera.
  12727. * The camera will stop reacting to inputs.
  12728. * @param element Defines the element to stop listening the inputs from
  12729. */
  12730. detachControl(element: HTMLElement): void;
  12731. private _collisionMask;
  12732. /**
  12733. * Define a collision mask to limit the list of object the camera can collide with
  12734. */
  12735. collisionMask: number;
  12736. /** @hidden */
  12737. _collideWithWorld(displacement: Vector3): void;
  12738. private _onCollisionPositionChange;
  12739. /** @hidden */
  12740. _checkInputs(): void;
  12741. /** @hidden */
  12742. _decideIfNeedsToMove(): boolean;
  12743. /** @hidden */
  12744. _updatePosition(): void;
  12745. /**
  12746. * Destroy the camera and release the current resources hold by it.
  12747. */
  12748. dispose(): void;
  12749. /**
  12750. * Gets the current object class name.
  12751. * @return the class name
  12752. */
  12753. getClassName(): string;
  12754. }
  12755. }
  12756. declare module "babylonjs/Gamepads/gamepad" {
  12757. import { Observable } from "babylonjs/Misc/observable";
  12758. /**
  12759. * Represents a gamepad control stick position
  12760. */
  12761. export class StickValues {
  12762. /**
  12763. * The x component of the control stick
  12764. */
  12765. x: number;
  12766. /**
  12767. * The y component of the control stick
  12768. */
  12769. y: number;
  12770. /**
  12771. * Initializes the gamepad x and y control stick values
  12772. * @param x The x component of the gamepad control stick value
  12773. * @param y The y component of the gamepad control stick value
  12774. */
  12775. constructor(
  12776. /**
  12777. * The x component of the control stick
  12778. */
  12779. x: number,
  12780. /**
  12781. * The y component of the control stick
  12782. */
  12783. y: number);
  12784. }
  12785. /**
  12786. * An interface which manages callbacks for gamepad button changes
  12787. */
  12788. export interface GamepadButtonChanges {
  12789. /**
  12790. * Called when a gamepad has been changed
  12791. */
  12792. changed: boolean;
  12793. /**
  12794. * Called when a gamepad press event has been triggered
  12795. */
  12796. pressChanged: boolean;
  12797. /**
  12798. * Called when a touch event has been triggered
  12799. */
  12800. touchChanged: boolean;
  12801. /**
  12802. * Called when a value has changed
  12803. */
  12804. valueChanged: boolean;
  12805. }
  12806. /**
  12807. * Represents a gamepad
  12808. */
  12809. export class Gamepad {
  12810. /**
  12811. * The id of the gamepad
  12812. */
  12813. id: string;
  12814. /**
  12815. * The index of the gamepad
  12816. */
  12817. index: number;
  12818. /**
  12819. * The browser gamepad
  12820. */
  12821. browserGamepad: any;
  12822. /**
  12823. * Specifies what type of gamepad this represents
  12824. */
  12825. type: number;
  12826. private _leftStick;
  12827. private _rightStick;
  12828. /** @hidden */
  12829. _isConnected: boolean;
  12830. private _leftStickAxisX;
  12831. private _leftStickAxisY;
  12832. private _rightStickAxisX;
  12833. private _rightStickAxisY;
  12834. /**
  12835. * Triggered when the left control stick has been changed
  12836. */
  12837. private _onleftstickchanged;
  12838. /**
  12839. * Triggered when the right control stick has been changed
  12840. */
  12841. private _onrightstickchanged;
  12842. /**
  12843. * Represents a gamepad controller
  12844. */
  12845. static GAMEPAD: number;
  12846. /**
  12847. * Represents a generic controller
  12848. */
  12849. static GENERIC: number;
  12850. /**
  12851. * Represents an XBox controller
  12852. */
  12853. static XBOX: number;
  12854. /**
  12855. * Represents a pose-enabled controller
  12856. */
  12857. static POSE_ENABLED: number;
  12858. /**
  12859. * Specifies whether the left control stick should be Y-inverted
  12860. */
  12861. protected _invertLeftStickY: boolean;
  12862. /**
  12863. * Specifies if the gamepad has been connected
  12864. */
  12865. readonly isConnected: boolean;
  12866. /**
  12867. * Initializes the gamepad
  12868. * @param id The id of the gamepad
  12869. * @param index The index of the gamepad
  12870. * @param browserGamepad The browser gamepad
  12871. * @param leftStickX The x component of the left joystick
  12872. * @param leftStickY The y component of the left joystick
  12873. * @param rightStickX The x component of the right joystick
  12874. * @param rightStickY The y component of the right joystick
  12875. */
  12876. constructor(
  12877. /**
  12878. * The id of the gamepad
  12879. */
  12880. id: string,
  12881. /**
  12882. * The index of the gamepad
  12883. */
  12884. index: number,
  12885. /**
  12886. * The browser gamepad
  12887. */
  12888. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12889. /**
  12890. * Callback triggered when the left joystick has changed
  12891. * @param callback
  12892. */
  12893. onleftstickchanged(callback: (values: StickValues) => void): void;
  12894. /**
  12895. * Callback triggered when the right joystick has changed
  12896. * @param callback
  12897. */
  12898. onrightstickchanged(callback: (values: StickValues) => void): void;
  12899. /**
  12900. * Gets the left joystick
  12901. */
  12902. /**
  12903. * Sets the left joystick values
  12904. */
  12905. leftStick: StickValues;
  12906. /**
  12907. * Gets the right joystick
  12908. */
  12909. /**
  12910. * Sets the right joystick value
  12911. */
  12912. rightStick: StickValues;
  12913. /**
  12914. * Updates the gamepad joystick positions
  12915. */
  12916. update(): void;
  12917. /**
  12918. * Disposes the gamepad
  12919. */
  12920. dispose(): void;
  12921. }
  12922. /**
  12923. * Represents a generic gamepad
  12924. */
  12925. export class GenericPad extends Gamepad {
  12926. private _buttons;
  12927. private _onbuttondown;
  12928. private _onbuttonup;
  12929. /**
  12930. * Observable triggered when a button has been pressed
  12931. */
  12932. onButtonDownObservable: Observable<number>;
  12933. /**
  12934. * Observable triggered when a button has been released
  12935. */
  12936. onButtonUpObservable: Observable<number>;
  12937. /**
  12938. * Callback triggered when a button has been pressed
  12939. * @param callback Called when a button has been pressed
  12940. */
  12941. onbuttondown(callback: (buttonPressed: number) => void): void;
  12942. /**
  12943. * Callback triggered when a button has been released
  12944. * @param callback Called when a button has been released
  12945. */
  12946. onbuttonup(callback: (buttonReleased: number) => void): void;
  12947. /**
  12948. * Initializes the generic gamepad
  12949. * @param id The id of the generic gamepad
  12950. * @param index The index of the generic gamepad
  12951. * @param browserGamepad The browser gamepad
  12952. */
  12953. constructor(id: string, index: number, browserGamepad: any);
  12954. private _setButtonValue;
  12955. /**
  12956. * Updates the generic gamepad
  12957. */
  12958. update(): void;
  12959. /**
  12960. * Disposes the generic gamepad
  12961. */
  12962. dispose(): void;
  12963. }
  12964. }
  12965. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12966. import { Observable } from "babylonjs/Misc/observable";
  12967. import { Nullable } from "babylonjs/types";
  12968. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12971. import { Ray } from "babylonjs/Culling/ray";
  12972. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12973. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12974. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12975. /**
  12976. * Defines the types of pose enabled controllers that are supported
  12977. */
  12978. export enum PoseEnabledControllerType {
  12979. /**
  12980. * HTC Vive
  12981. */
  12982. VIVE = 0,
  12983. /**
  12984. * Oculus Rift
  12985. */
  12986. OCULUS = 1,
  12987. /**
  12988. * Windows mixed reality
  12989. */
  12990. WINDOWS = 2,
  12991. /**
  12992. * Samsung gear VR
  12993. */
  12994. GEAR_VR = 3,
  12995. /**
  12996. * Google Daydream
  12997. */
  12998. DAYDREAM = 4,
  12999. /**
  13000. * Generic
  13001. */
  13002. GENERIC = 5
  13003. }
  13004. /**
  13005. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13006. */
  13007. export interface MutableGamepadButton {
  13008. /**
  13009. * Value of the button/trigger
  13010. */
  13011. value: number;
  13012. /**
  13013. * If the button/trigger is currently touched
  13014. */
  13015. touched: boolean;
  13016. /**
  13017. * If the button/trigger is currently pressed
  13018. */
  13019. pressed: boolean;
  13020. }
  13021. /**
  13022. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13023. * @hidden
  13024. */
  13025. export interface ExtendedGamepadButton extends GamepadButton {
  13026. /**
  13027. * If the button/trigger is currently pressed
  13028. */
  13029. readonly pressed: boolean;
  13030. /**
  13031. * If the button/trigger is currently touched
  13032. */
  13033. readonly touched: boolean;
  13034. /**
  13035. * Value of the button/trigger
  13036. */
  13037. readonly value: number;
  13038. }
  13039. /** @hidden */
  13040. export interface _GamePadFactory {
  13041. /**
  13042. * Returns wether or not the current gamepad can be created for this type of controller.
  13043. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13044. * @returns true if it can be created, otherwise false
  13045. */
  13046. canCreate(gamepadInfo: any): boolean;
  13047. /**
  13048. * Creates a new instance of the Gamepad.
  13049. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13050. * @returns the new gamepad instance
  13051. */
  13052. create(gamepadInfo: any): Gamepad;
  13053. }
  13054. /**
  13055. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13056. */
  13057. export class PoseEnabledControllerHelper {
  13058. /** @hidden */
  13059. static _ControllerFactories: _GamePadFactory[];
  13060. /** @hidden */
  13061. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13062. /**
  13063. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13064. * @param vrGamepad the gamepad to initialized
  13065. * @returns a vr controller of the type the gamepad identified as
  13066. */
  13067. static InitiateController(vrGamepad: any): Gamepad;
  13068. }
  13069. /**
  13070. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13071. */
  13072. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13073. private _deviceRoomPosition;
  13074. private _deviceRoomRotationQuaternion;
  13075. /**
  13076. * The device position in babylon space
  13077. */
  13078. devicePosition: Vector3;
  13079. /**
  13080. * The device rotation in babylon space
  13081. */
  13082. deviceRotationQuaternion: Quaternion;
  13083. /**
  13084. * The scale factor of the device in babylon space
  13085. */
  13086. deviceScaleFactor: number;
  13087. /**
  13088. * (Likely devicePosition should be used instead) The device position in its room space
  13089. */
  13090. position: Vector3;
  13091. /**
  13092. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13093. */
  13094. rotationQuaternion: Quaternion;
  13095. /**
  13096. * The type of controller (Eg. Windows mixed reality)
  13097. */
  13098. controllerType: PoseEnabledControllerType;
  13099. protected _calculatedPosition: Vector3;
  13100. private _calculatedRotation;
  13101. /**
  13102. * The raw pose from the device
  13103. */
  13104. rawPose: DevicePose;
  13105. private _trackPosition;
  13106. private _maxRotationDistFromHeadset;
  13107. private _draggedRoomRotation;
  13108. /**
  13109. * @hidden
  13110. */
  13111. _disableTrackPosition(fixedPosition: Vector3): void;
  13112. /**
  13113. * Internal, the mesh attached to the controller
  13114. * @hidden
  13115. */
  13116. _mesh: Nullable<AbstractMesh>;
  13117. private _poseControlledCamera;
  13118. private _leftHandSystemQuaternion;
  13119. /**
  13120. * Internal, matrix used to convert room space to babylon space
  13121. * @hidden
  13122. */
  13123. _deviceToWorld: Matrix;
  13124. /**
  13125. * Node to be used when casting a ray from the controller
  13126. * @hidden
  13127. */
  13128. _pointingPoseNode: Nullable<TransformNode>;
  13129. /**
  13130. * Name of the child mesh that can be used to cast a ray from the controller
  13131. */
  13132. static readonly POINTING_POSE: string;
  13133. /**
  13134. * Creates a new PoseEnabledController from a gamepad
  13135. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13136. */
  13137. constructor(browserGamepad: any);
  13138. private _workingMatrix;
  13139. /**
  13140. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13141. */
  13142. update(): void;
  13143. /**
  13144. * Updates only the pose device and mesh without doing any button event checking
  13145. */
  13146. protected _updatePoseAndMesh(): void;
  13147. /**
  13148. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13149. * @param poseData raw pose fromthe device
  13150. */
  13151. updateFromDevice(poseData: DevicePose): void;
  13152. /**
  13153. * @hidden
  13154. */
  13155. _meshAttachedObservable: Observable<AbstractMesh>;
  13156. /**
  13157. * Attaches a mesh to the controller
  13158. * @param mesh the mesh to be attached
  13159. */
  13160. attachToMesh(mesh: AbstractMesh): void;
  13161. /**
  13162. * Attaches the controllers mesh to a camera
  13163. * @param camera the camera the mesh should be attached to
  13164. */
  13165. attachToPoseControlledCamera(camera: TargetCamera): void;
  13166. /**
  13167. * Disposes of the controller
  13168. */
  13169. dispose(): void;
  13170. /**
  13171. * The mesh that is attached to the controller
  13172. */
  13173. readonly mesh: Nullable<AbstractMesh>;
  13174. /**
  13175. * Gets the ray of the controller in the direction the controller is pointing
  13176. * @param length the length the resulting ray should be
  13177. * @returns a ray in the direction the controller is pointing
  13178. */
  13179. getForwardRay(length?: number): Ray;
  13180. }
  13181. }
  13182. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13183. import { Observable } from "babylonjs/Misc/observable";
  13184. import { Scene } from "babylonjs/scene";
  13185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13186. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13187. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13188. /**
  13189. * Defines the WebVRController object that represents controllers tracked in 3D space
  13190. */
  13191. export abstract class WebVRController extends PoseEnabledController {
  13192. /**
  13193. * Internal, the default controller model for the controller
  13194. */
  13195. protected _defaultModel: AbstractMesh;
  13196. /**
  13197. * Fired when the trigger state has changed
  13198. */
  13199. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13200. /**
  13201. * Fired when the main button state has changed
  13202. */
  13203. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13204. /**
  13205. * Fired when the secondary button state has changed
  13206. */
  13207. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13208. /**
  13209. * Fired when the pad state has changed
  13210. */
  13211. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13212. /**
  13213. * Fired when controllers stick values have changed
  13214. */
  13215. onPadValuesChangedObservable: Observable<StickValues>;
  13216. /**
  13217. * Array of button availible on the controller
  13218. */
  13219. protected _buttons: Array<MutableGamepadButton>;
  13220. private _onButtonStateChange;
  13221. /**
  13222. * Fired when a controller button's state has changed
  13223. * @param callback the callback containing the button that was modified
  13224. */
  13225. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13226. /**
  13227. * X and Y axis corrisponding to the controllers joystick
  13228. */
  13229. pad: StickValues;
  13230. /**
  13231. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13232. */
  13233. hand: string;
  13234. /**
  13235. * The default controller model for the controller
  13236. */
  13237. readonly defaultModel: AbstractMesh;
  13238. /**
  13239. * Creates a new WebVRController from a gamepad
  13240. * @param vrGamepad the gamepad that the WebVRController should be created from
  13241. */
  13242. constructor(vrGamepad: any);
  13243. /**
  13244. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13245. */
  13246. update(): void;
  13247. /**
  13248. * Function to be called when a button is modified
  13249. */
  13250. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13251. /**
  13252. * Loads a mesh and attaches it to the controller
  13253. * @param scene the scene the mesh should be added to
  13254. * @param meshLoaded callback for when the mesh has been loaded
  13255. */
  13256. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13257. private _setButtonValue;
  13258. private _changes;
  13259. private _checkChanges;
  13260. /**
  13261. * Disposes of th webVRCOntroller
  13262. */
  13263. dispose(): void;
  13264. }
  13265. }
  13266. declare module "babylonjs/Lights/hemisphericLight" {
  13267. import { Nullable } from "babylonjs/types";
  13268. import { Scene } from "babylonjs/scene";
  13269. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13270. import { Effect } from "babylonjs/Materials/effect";
  13271. import { Light } from "babylonjs/Lights/light";
  13272. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13273. /**
  13274. * The HemisphericLight simulates the ambient environment light,
  13275. * so the passed direction is the light reflection direction, not the incoming direction.
  13276. */
  13277. export class HemisphericLight extends Light {
  13278. /**
  13279. * The groundColor is the light in the opposite direction to the one specified during creation.
  13280. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  13281. */
  13282. groundColor: Color3;
  13283. /**
  13284. * The light reflection direction, not the incoming direction.
  13285. */
  13286. direction: Vector3;
  13287. /**
  13288. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13289. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13290. * The HemisphericLight can't cast shadows.
  13291. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13292. * @param name The friendly name of the light
  13293. * @param direction The direction of the light reflection
  13294. * @param scene The scene the light belongs to
  13295. */
  13296. constructor(name: string, direction: Vector3, scene: Scene);
  13297. protected _buildUniformLayout(): void;
  13298. /**
  13299. * Returns the string "HemisphericLight".
  13300. * @return The class name
  13301. */
  13302. getClassName(): string;
  13303. /**
  13304. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13305. * Returns the updated direction.
  13306. * @param target The target the direction should point to
  13307. * @return The computed direction
  13308. */
  13309. setDirectionToTarget(target: Vector3): Vector3;
  13310. /**
  13311. * Returns the shadow generator associated to the light.
  13312. * @returns Always null for hemispheric lights because it does not support shadows.
  13313. */
  13314. getShadowGenerator(): Nullable<IShadowGenerator>;
  13315. /**
  13316. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13317. * @param effect The effect to update
  13318. * @param lightIndex The index of the light in the effect to update
  13319. * @returns The hemispheric light
  13320. */
  13321. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13322. /**
  13323. * Computes the world matrix of the node
  13324. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13325. * @param useWasUpdatedFlag defines a reserved property
  13326. * @returns the world matrix
  13327. */
  13328. computeWorldMatrix(): Matrix;
  13329. /**
  13330. * Returns the integer 3.
  13331. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13332. */
  13333. getTypeID(): number;
  13334. /**
  13335. * Prepares the list of defines specific to the light type.
  13336. * @param defines the list of defines
  13337. * @param lightIndex defines the index of the light for the effect
  13338. */
  13339. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13340. }
  13341. }
  13342. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13343. /** @hidden */
  13344. export var vrMultiviewToSingleviewPixelShader: {
  13345. name: string;
  13346. shader: string;
  13347. };
  13348. }
  13349. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13351. import { Scene } from "babylonjs/scene";
  13352. /**
  13353. * Renders to multiple views with a single draw call
  13354. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13355. */
  13356. export class MultiviewRenderTarget extends RenderTargetTexture {
  13357. /**
  13358. * Creates a multiview render target
  13359. * @param scene scene used with the render target
  13360. * @param size the size of the render target (used for each view)
  13361. */
  13362. constructor(scene: Scene, size?: number | {
  13363. width: number;
  13364. height: number;
  13365. } | {
  13366. ratio: number;
  13367. });
  13368. /**
  13369. * @hidden
  13370. * @param faceIndex the face index, if its a cube texture
  13371. */
  13372. _bindFrameBuffer(faceIndex?: number): void;
  13373. /**
  13374. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13375. * @returns the view count
  13376. */
  13377. getViewCount(): number;
  13378. }
  13379. }
  13380. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13381. import { Camera } from "babylonjs/Cameras/camera";
  13382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13383. import { Nullable } from "babylonjs/types";
  13384. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13385. import { Matrix } from "babylonjs/Maths/math";
  13386. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13387. module "babylonjs/Engines/engine" {
  13388. interface Engine {
  13389. /**
  13390. * Creates a new multiview render target
  13391. * @param width defines the width of the texture
  13392. * @param height defines the height of the texture
  13393. * @returns the created multiview texture
  13394. */
  13395. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13396. /**
  13397. * Binds a multiview framebuffer to be drawn to
  13398. * @param multiviewTexture texture to bind
  13399. */
  13400. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13401. }
  13402. }
  13403. module "babylonjs/Cameras/camera" {
  13404. interface Camera {
  13405. /**
  13406. * @hidden
  13407. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13408. */
  13409. _useMultiviewToSingleView: boolean;
  13410. /**
  13411. * @hidden
  13412. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13413. */
  13414. _multiviewTexture: Nullable<RenderTargetTexture>;
  13415. /**
  13416. * @hidden
  13417. * ensures the multiview texture of the camera exists and has the specified width/height
  13418. * @param width height to set on the multiview texture
  13419. * @param height width to set on the multiview texture
  13420. */
  13421. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13422. }
  13423. }
  13424. module "babylonjs/scene" {
  13425. interface Scene {
  13426. /** @hidden */
  13427. _transformMatrixR: Matrix;
  13428. /** @hidden */
  13429. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13430. /** @hidden */
  13431. _createMultiviewUbo(): void;
  13432. /** @hidden */
  13433. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13434. /** @hidden */
  13435. _renderMultiviewToSingleView(camera: Camera): void;
  13436. }
  13437. }
  13438. }
  13439. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13440. import { Camera } from "babylonjs/Cameras/camera";
  13441. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13442. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13443. import "babylonjs/Engines/Extensions/engine.multiview";
  13444. /**
  13445. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13446. * This will not be used for webXR as it supports displaying texture arrays directly
  13447. */
  13448. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13449. /**
  13450. * Initializes a VRMultiviewToSingleview
  13451. * @param name name of the post process
  13452. * @param camera camera to be applied to
  13453. * @param scaleFactor scaling factor to the size of the output texture
  13454. */
  13455. constructor(name: string, camera: Camera, scaleFactor: number);
  13456. }
  13457. }
  13458. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13459. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13460. import { Nullable } from "babylonjs/types";
  13461. import { Size } from "babylonjs/Maths/math";
  13462. import { Observable } from "babylonjs/Misc/observable";
  13463. module "babylonjs/Engines/engine" {
  13464. /**
  13465. * Defines the interface used by display changed events
  13466. */
  13467. interface IDisplayChangedEventArgs {
  13468. /** Gets the vrDisplay object (if any) */
  13469. vrDisplay: Nullable<any>;
  13470. /** Gets a boolean indicating if webVR is supported */
  13471. vrSupported: boolean;
  13472. }
  13473. interface Engine {
  13474. /** @hidden */
  13475. _vrDisplay: any;
  13476. /** @hidden */
  13477. _vrSupported: boolean;
  13478. /** @hidden */
  13479. _oldSize: Size;
  13480. /** @hidden */
  13481. _oldHardwareScaleFactor: number;
  13482. /** @hidden */
  13483. _vrExclusivePointerMode: boolean;
  13484. /** @hidden */
  13485. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13486. /** @hidden */
  13487. _onVRDisplayPointerRestricted: () => void;
  13488. /** @hidden */
  13489. _onVRDisplayPointerUnrestricted: () => void;
  13490. /** @hidden */
  13491. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13492. /** @hidden */
  13493. _onVrDisplayDisconnect: Nullable<() => void>;
  13494. /** @hidden */
  13495. _onVrDisplayPresentChange: Nullable<() => void>;
  13496. /**
  13497. * Observable signaled when VR display mode changes
  13498. */
  13499. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13500. /**
  13501. * Observable signaled when VR request present is complete
  13502. */
  13503. onVRRequestPresentComplete: Observable<boolean>;
  13504. /**
  13505. * Observable signaled when VR request present starts
  13506. */
  13507. onVRRequestPresentStart: Observable<Engine>;
  13508. /**
  13509. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13510. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13511. */
  13512. isInVRExclusivePointerMode: boolean;
  13513. /**
  13514. * Gets a boolean indicating if a webVR device was detected
  13515. * @returns true if a webVR device was detected
  13516. */
  13517. isVRDevicePresent(): boolean;
  13518. /**
  13519. * Gets the current webVR device
  13520. * @returns the current webVR device (or null)
  13521. */
  13522. getVRDevice(): any;
  13523. /**
  13524. * Initializes a webVR display and starts listening to display change events
  13525. * The onVRDisplayChangedObservable will be notified upon these changes
  13526. * @returns A promise containing a VRDisplay and if vr is supported
  13527. */
  13528. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13529. /** @hidden */
  13530. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13531. /**
  13532. * Call this function to switch to webVR mode
  13533. * Will do nothing if webVR is not supported or if there is no webVR device
  13534. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13535. */
  13536. enableVR(): void;
  13537. /** @hidden */
  13538. _onVRFullScreenTriggered(): void;
  13539. }
  13540. }
  13541. }
  13542. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13543. import { Nullable } from "babylonjs/types";
  13544. import { Observable } from "babylonjs/Misc/observable";
  13545. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13546. import { Scene } from "babylonjs/scene";
  13547. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13548. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13549. import { Node } from "babylonjs/node";
  13550. import { Ray } from "babylonjs/Culling/ray";
  13551. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13552. import "babylonjs/Engines/Extensions/engine.webVR";
  13553. /**
  13554. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13555. * IMPORTANT!! The data is right-hand data.
  13556. * @export
  13557. * @interface DevicePose
  13558. */
  13559. export interface DevicePose {
  13560. /**
  13561. * The position of the device, values in array are [x,y,z].
  13562. */
  13563. readonly position: Nullable<Float32Array>;
  13564. /**
  13565. * The linearVelocity of the device, values in array are [x,y,z].
  13566. */
  13567. readonly linearVelocity: Nullable<Float32Array>;
  13568. /**
  13569. * The linearAcceleration of the device, values in array are [x,y,z].
  13570. */
  13571. readonly linearAcceleration: Nullable<Float32Array>;
  13572. /**
  13573. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13574. */
  13575. readonly orientation: Nullable<Float32Array>;
  13576. /**
  13577. * The angularVelocity of the device, values in array are [x,y,z].
  13578. */
  13579. readonly angularVelocity: Nullable<Float32Array>;
  13580. /**
  13581. * The angularAcceleration of the device, values in array are [x,y,z].
  13582. */
  13583. readonly angularAcceleration: Nullable<Float32Array>;
  13584. }
  13585. /**
  13586. * Interface representing a pose controlled object in Babylon.
  13587. * A pose controlled object has both regular pose values as well as pose values
  13588. * from an external device such as a VR head mounted display
  13589. */
  13590. export interface PoseControlled {
  13591. /**
  13592. * The position of the object in babylon space.
  13593. */
  13594. position: Vector3;
  13595. /**
  13596. * The rotation quaternion of the object in babylon space.
  13597. */
  13598. rotationQuaternion: Quaternion;
  13599. /**
  13600. * The position of the device in babylon space.
  13601. */
  13602. devicePosition?: Vector3;
  13603. /**
  13604. * The rotation quaternion of the device in babylon space.
  13605. */
  13606. deviceRotationQuaternion: Quaternion;
  13607. /**
  13608. * The raw pose coming from the device.
  13609. */
  13610. rawPose: Nullable<DevicePose>;
  13611. /**
  13612. * The scale of the device to be used when translating from device space to babylon space.
  13613. */
  13614. deviceScaleFactor: number;
  13615. /**
  13616. * Updates the poseControlled values based on the input device pose.
  13617. * @param poseData the pose data to update the object with
  13618. */
  13619. updateFromDevice(poseData: DevicePose): void;
  13620. }
  13621. /**
  13622. * Set of options to customize the webVRCamera
  13623. */
  13624. export interface WebVROptions {
  13625. /**
  13626. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13627. */
  13628. trackPosition?: boolean;
  13629. /**
  13630. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13631. */
  13632. positionScale?: number;
  13633. /**
  13634. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13635. */
  13636. displayName?: string;
  13637. /**
  13638. * Should the native controller meshes be initialized. (default: true)
  13639. */
  13640. controllerMeshes?: boolean;
  13641. /**
  13642. * Creating a default HemiLight only on controllers. (default: true)
  13643. */
  13644. defaultLightingOnControllers?: boolean;
  13645. /**
  13646. * If you don't want to use the default VR button of the helper. (default: false)
  13647. */
  13648. useCustomVRButton?: boolean;
  13649. /**
  13650. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13651. */
  13652. customVRButton?: HTMLButtonElement;
  13653. /**
  13654. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13655. */
  13656. rayLength?: number;
  13657. /**
  13658. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13659. */
  13660. defaultHeight?: number;
  13661. /**
  13662. * If multiview should be used if availible (default: false)
  13663. */
  13664. useMultiview?: boolean;
  13665. }
  13666. /**
  13667. * This represents a WebVR camera.
  13668. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13669. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13670. */
  13671. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13672. private webVROptions;
  13673. /**
  13674. * @hidden
  13675. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13676. */
  13677. _vrDevice: any;
  13678. /**
  13679. * The rawPose of the vrDevice.
  13680. */
  13681. rawPose: Nullable<DevicePose>;
  13682. private _onVREnabled;
  13683. private _specsVersion;
  13684. private _attached;
  13685. private _frameData;
  13686. protected _descendants: Array<Node>;
  13687. private _deviceRoomPosition;
  13688. /** @hidden */
  13689. _deviceRoomRotationQuaternion: Quaternion;
  13690. private _standingMatrix;
  13691. /**
  13692. * Represents device position in babylon space.
  13693. */
  13694. devicePosition: Vector3;
  13695. /**
  13696. * Represents device rotation in babylon space.
  13697. */
  13698. deviceRotationQuaternion: Quaternion;
  13699. /**
  13700. * The scale of the device to be used when translating from device space to babylon space.
  13701. */
  13702. deviceScaleFactor: number;
  13703. private _deviceToWorld;
  13704. private _worldToDevice;
  13705. /**
  13706. * References to the webVR controllers for the vrDevice.
  13707. */
  13708. controllers: Array<WebVRController>;
  13709. /**
  13710. * Emits an event when a controller is attached.
  13711. */
  13712. onControllersAttachedObservable: Observable<WebVRController[]>;
  13713. /**
  13714. * Emits an event when a controller's mesh has been loaded;
  13715. */
  13716. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13717. /**
  13718. * Emits an event when the HMD's pose has been updated.
  13719. */
  13720. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13721. private _poseSet;
  13722. /**
  13723. * If the rig cameras be used as parent instead of this camera.
  13724. */
  13725. rigParenting: boolean;
  13726. private _lightOnControllers;
  13727. private _defaultHeight?;
  13728. /**
  13729. * Instantiates a WebVRFreeCamera.
  13730. * @param name The name of the WebVRFreeCamera
  13731. * @param position The starting anchor position for the camera
  13732. * @param scene The scene the camera belongs to
  13733. * @param webVROptions a set of customizable options for the webVRCamera
  13734. */
  13735. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13736. /**
  13737. * Gets the device distance from the ground in meters.
  13738. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  13739. */
  13740. deviceDistanceToRoomGround(): number;
  13741. /**
  13742. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13743. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13744. */
  13745. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13746. /**
  13747. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13748. * @returns A promise with a boolean set to if the standing matrix is supported.
  13749. */
  13750. useStandingMatrixAsync(): Promise<boolean>;
  13751. /**
  13752. * Disposes the camera
  13753. */
  13754. dispose(): void;
  13755. /**
  13756. * Gets a vrController by name.
  13757. * @param name The name of the controller to retreive
  13758. * @returns the controller matching the name specified or null if not found
  13759. */
  13760. getControllerByName(name: string): Nullable<WebVRController>;
  13761. private _leftController;
  13762. /**
  13763. * The controller corrisponding to the users left hand.
  13764. */
  13765. readonly leftController: Nullable<WebVRController>;
  13766. private _rightController;
  13767. /**
  13768. * The controller corrisponding to the users right hand.
  13769. */
  13770. readonly rightController: Nullable<WebVRController>;
  13771. /**
  13772. * Casts a ray forward from the vrCamera's gaze.
  13773. * @param length Length of the ray (default: 100)
  13774. * @returns the ray corrisponding to the gaze
  13775. */
  13776. getForwardRay(length?: number): Ray;
  13777. /**
  13778. * @hidden
  13779. * Updates the camera based on device's frame data
  13780. */
  13781. _checkInputs(): void;
  13782. /**
  13783. * Updates the poseControlled values based on the input device pose.
  13784. * @param poseData Pose coming from the device
  13785. */
  13786. updateFromDevice(poseData: DevicePose): void;
  13787. private _htmlElementAttached;
  13788. private _detachIfAttached;
  13789. /**
  13790. * WebVR's attach control will start broadcasting frames to the device.
  13791. * Note that in certain browsers (chrome for example) this function must be called
  13792. * within a user-interaction callback. Example:
  13793. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13794. *
  13795. * @param element html element to attach the vrDevice to
  13796. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13797. */
  13798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13799. /**
  13800. * Detaches the camera from the html element and disables VR
  13801. *
  13802. * @param element html element to detach from
  13803. */
  13804. detachControl(element: HTMLElement): void;
  13805. /**
  13806. * @returns the name of this class
  13807. */
  13808. getClassName(): string;
  13809. /**
  13810. * Calls resetPose on the vrDisplay
  13811. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13812. */
  13813. resetToCurrentRotation(): void;
  13814. /**
  13815. * @hidden
  13816. * Updates the rig cameras (left and right eye)
  13817. */
  13818. _updateRigCameras(): void;
  13819. private _workingVector;
  13820. private _oneVector;
  13821. private _workingMatrix;
  13822. private updateCacheCalled;
  13823. private _correctPositionIfNotTrackPosition;
  13824. /**
  13825. * @hidden
  13826. * Updates the cached values of the camera
  13827. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13828. */
  13829. _updateCache(ignoreParentClass?: boolean): void;
  13830. /**
  13831. * @hidden
  13832. * Get current device position in babylon world
  13833. */
  13834. _computeDevicePosition(): void;
  13835. /**
  13836. * Updates the current device position and rotation in the babylon world
  13837. */
  13838. update(): void;
  13839. /**
  13840. * @hidden
  13841. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13842. * @returns an identity matrix
  13843. */
  13844. _getViewMatrix(): Matrix;
  13845. private _tmpMatrix;
  13846. /**
  13847. * This function is called by the two RIG cameras.
  13848. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13849. * @hidden
  13850. */
  13851. _getWebVRViewMatrix(): Matrix;
  13852. /** @hidden */
  13853. _getWebVRProjectionMatrix(): Matrix;
  13854. private _onGamepadConnectedObserver;
  13855. private _onGamepadDisconnectedObserver;
  13856. private _updateCacheWhenTrackingDisabledObserver;
  13857. /**
  13858. * Initializes the controllers and their meshes
  13859. */
  13860. initControllers(): void;
  13861. }
  13862. }
  13863. declare module "babylonjs/PostProcesses/postProcess" {
  13864. import { Nullable } from "babylonjs/types";
  13865. import { SmartArray } from "babylonjs/Misc/smartArray";
  13866. import { Observable } from "babylonjs/Misc/observable";
  13867. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13868. import { Camera } from "babylonjs/Cameras/camera";
  13869. import { Effect } from "babylonjs/Materials/effect";
  13870. import "babylonjs/Shaders/postprocess.vertex";
  13871. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13872. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13873. import { Engine } from "babylonjs/Engines/engine";
  13874. /**
  13875. * Size options for a post process
  13876. */
  13877. export type PostProcessOptions = {
  13878. width: number;
  13879. height: number;
  13880. };
  13881. /**
  13882. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13883. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13884. */
  13885. export class PostProcess {
  13886. /** Name of the PostProcess. */
  13887. name: string;
  13888. /**
  13889. * Gets or sets the unique id of the post process
  13890. */
  13891. uniqueId: number;
  13892. /**
  13893. * Width of the texture to apply the post process on
  13894. */
  13895. width: number;
  13896. /**
  13897. * Height of the texture to apply the post process on
  13898. */
  13899. height: number;
  13900. /**
  13901. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13902. * @hidden
  13903. */
  13904. _outputTexture: Nullable<InternalTexture>;
  13905. /**
  13906. * Sampling mode used by the shader
  13907. * See https://doc.babylonjs.com/classes/3.1/texture
  13908. */
  13909. renderTargetSamplingMode: number;
  13910. /**
  13911. * Clear color to use when screen clearing
  13912. */
  13913. clearColor: Color4;
  13914. /**
  13915. * If the buffer needs to be cleared before applying the post process. (default: true)
  13916. * Should be set to false if shader will overwrite all previous pixels.
  13917. */
  13918. autoClear: boolean;
  13919. /**
  13920. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13921. */
  13922. alphaMode: number;
  13923. /**
  13924. * Sets the setAlphaBlendConstants of the babylon engine
  13925. */
  13926. alphaConstants: Color4;
  13927. /**
  13928. * Animations to be used for the post processing
  13929. */
  13930. animations: import("babylonjs/Animations/animation").Animation[];
  13931. /**
  13932. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13933. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13934. */
  13935. enablePixelPerfectMode: boolean;
  13936. /**
  13937. * Force the postprocess to be applied without taking in account viewport
  13938. */
  13939. forceFullscreenViewport: boolean;
  13940. /**
  13941. * List of inspectable custom properties (used by the Inspector)
  13942. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13943. */
  13944. inspectableCustomProperties: IInspectable[];
  13945. /**
  13946. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13947. *
  13948. * | Value | Type | Description |
  13949. * | ----- | ----------------------------------- | ----------- |
  13950. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13951. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13952. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13953. *
  13954. */
  13955. scaleMode: number;
  13956. /**
  13957. * Force textures to be a power of two (default: false)
  13958. */
  13959. alwaysForcePOT: boolean;
  13960. private _samples;
  13961. /**
  13962. * Number of sample textures (default: 1)
  13963. */
  13964. samples: number;
  13965. /**
  13966. * Modify the scale of the post process to be the same as the viewport (default: false)
  13967. */
  13968. adaptScaleToCurrentViewport: boolean;
  13969. private _camera;
  13970. private _scene;
  13971. private _engine;
  13972. private _options;
  13973. private _reusable;
  13974. private _textureType;
  13975. /**
  13976. * Smart array of input and output textures for the post process.
  13977. * @hidden
  13978. */
  13979. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13980. /**
  13981. * The index in _textures that corresponds to the output texture.
  13982. * @hidden
  13983. */
  13984. _currentRenderTextureInd: number;
  13985. private _effect;
  13986. private _samplers;
  13987. private _fragmentUrl;
  13988. private _vertexUrl;
  13989. private _parameters;
  13990. private _scaleRatio;
  13991. protected _indexParameters: any;
  13992. private _shareOutputWithPostProcess;
  13993. private _texelSize;
  13994. private _forcedOutputTexture;
  13995. /**
  13996. * Returns the fragment url or shader name used in the post process.
  13997. * @returns the fragment url or name in the shader store.
  13998. */
  13999. getEffectName(): string;
  14000. /**
  14001. * An event triggered when the postprocess is activated.
  14002. */
  14003. onActivateObservable: Observable<Camera>;
  14004. private _onActivateObserver;
  14005. /**
  14006. * A function that is added to the onActivateObservable
  14007. */
  14008. onActivate: Nullable<(camera: Camera) => void>;
  14009. /**
  14010. * An event triggered when the postprocess changes its size.
  14011. */
  14012. onSizeChangedObservable: Observable<PostProcess>;
  14013. private _onSizeChangedObserver;
  14014. /**
  14015. * A function that is added to the onSizeChangedObservable
  14016. */
  14017. onSizeChanged: (postProcess: PostProcess) => void;
  14018. /**
  14019. * An event triggered when the postprocess applies its effect.
  14020. */
  14021. onApplyObservable: Observable<Effect>;
  14022. private _onApplyObserver;
  14023. /**
  14024. * A function that is added to the onApplyObservable
  14025. */
  14026. onApply: (effect: Effect) => void;
  14027. /**
  14028. * An event triggered before rendering the postprocess
  14029. */
  14030. onBeforeRenderObservable: Observable<Effect>;
  14031. private _onBeforeRenderObserver;
  14032. /**
  14033. * A function that is added to the onBeforeRenderObservable
  14034. */
  14035. onBeforeRender: (effect: Effect) => void;
  14036. /**
  14037. * An event triggered after rendering the postprocess
  14038. */
  14039. onAfterRenderObservable: Observable<Effect>;
  14040. private _onAfterRenderObserver;
  14041. /**
  14042. * A function that is added to the onAfterRenderObservable
  14043. */
  14044. onAfterRender: (efect: Effect) => void;
  14045. /**
  14046. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  14047. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14048. */
  14049. inputTexture: InternalTexture;
  14050. /**
  14051. * Gets the camera which post process is applied to.
  14052. * @returns The camera the post process is applied to.
  14053. */
  14054. getCamera(): Camera;
  14055. /**
  14056. * Gets the texel size of the postprocess.
  14057. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14058. */
  14059. readonly texelSize: Vector2;
  14060. /**
  14061. * Creates a new instance PostProcess
  14062. * @param name The name of the PostProcess.
  14063. * @param fragmentUrl The url of the fragment shader to be used.
  14064. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14065. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14066. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14067. * @param camera The camera to apply the render pass to.
  14068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14069. * @param engine The engine which the post process will be applied. (default: current engine)
  14070. * @param reusable If the post process can be reused on the same frame. (default: false)
  14071. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14072. * @param textureType Type of textures used when performing the post process. (default: 0)
  14073. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14074. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  14075. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14076. */
  14077. constructor(
  14078. /** Name of the PostProcess. */
  14079. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  14080. /**
  14081. * Gets a string idenfifying the name of the class
  14082. * @returns "PostProcess" string
  14083. */
  14084. getClassName(): string;
  14085. /**
  14086. * Gets the engine which this post process belongs to.
  14087. * @returns The engine the post process was enabled with.
  14088. */
  14089. getEngine(): Engine;
  14090. /**
  14091. * The effect that is created when initializing the post process.
  14092. * @returns The created effect corrisponding the the postprocess.
  14093. */
  14094. getEffect(): Effect;
  14095. /**
  14096. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14097. * @param postProcess The post process to share the output with.
  14098. * @returns This post process.
  14099. */
  14100. shareOutputWith(postProcess: PostProcess): PostProcess;
  14101. /**
  14102. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14103. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14104. */
  14105. useOwnOutput(): void;
  14106. /**
  14107. * Updates the effect with the current post process compile time values and recompiles the shader.
  14108. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14109. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14110. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14111. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  14112. * @param onCompiled Called when the shader has been compiled.
  14113. * @param onError Called if there is an error when compiling a shader.
  14114. */
  14115. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14116. /**
  14117. * The post process is reusable if it can be used multiple times within one frame.
  14118. * @returns If the post process is reusable
  14119. */
  14120. isReusable(): boolean;
  14121. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14122. markTextureDirty(): void;
  14123. /**
  14124. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14125. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  14126. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14127. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14128. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14129. * @returns The target texture that was bound to be written to.
  14130. */
  14131. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14132. /**
  14133. * If the post process is supported.
  14134. */
  14135. readonly isSupported: boolean;
  14136. /**
  14137. * The aspect ratio of the output texture.
  14138. */
  14139. readonly aspectRatio: number;
  14140. /**
  14141. * Get a value indicating if the post-process is ready to be used
  14142. * @returns true if the post-process is ready (shader is compiled)
  14143. */
  14144. isReady(): boolean;
  14145. /**
  14146. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14147. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14148. */
  14149. apply(): Nullable<Effect>;
  14150. private _disposeTextures;
  14151. /**
  14152. * Disposes the post process.
  14153. * @param camera The camera to dispose the post process on.
  14154. */
  14155. dispose(camera?: Camera): void;
  14156. }
  14157. }
  14158. declare module "babylonjs/PostProcesses/postProcessManager" {
  14159. import { Nullable } from "babylonjs/types";
  14160. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14161. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14162. import { Scene } from "babylonjs/scene";
  14163. /**
  14164. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14165. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14166. */
  14167. export class PostProcessManager {
  14168. private _scene;
  14169. private _indexBuffer;
  14170. private _vertexBuffers;
  14171. /**
  14172. * Creates a new instance PostProcess
  14173. * @param scene The scene that the post process is associated with.
  14174. */
  14175. constructor(scene: Scene);
  14176. private _prepareBuffers;
  14177. private _buildIndexBuffer;
  14178. /**
  14179. * Rebuilds the vertex buffers of the manager.
  14180. * @hidden
  14181. */
  14182. _rebuild(): void;
  14183. /**
  14184. * Prepares a frame to be run through a post process.
  14185. * @param sourceTexture The input texture to the post procesess. (default: null)
  14186. * @param postProcesses An array of post processes to be run. (default: null)
  14187. * @returns True if the post processes were able to be run.
  14188. * @hidden
  14189. */
  14190. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14191. /**
  14192. * Manually render a set of post processes to a texture.
  14193. * @param postProcesses An array of post processes to be run.
  14194. * @param targetTexture The target texture to render to.
  14195. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14196. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14197. * @param lodLevel defines which lod of the texture to render to
  14198. */
  14199. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14200. /**
  14201. * Finalize the result of the output of the postprocesses.
  14202. * @param doNotPresent If true the result will not be displayed to the screen.
  14203. * @param targetTexture The target texture to render to.
  14204. * @param faceIndex The index of the face to bind the target texture to.
  14205. * @param postProcesses The array of post processes to render.
  14206. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14207. * @hidden
  14208. */
  14209. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14210. /**
  14211. * Disposes of the post process manager.
  14212. */
  14213. dispose(): void;
  14214. }
  14215. }
  14216. declare module "babylonjs/Layers/layerSceneComponent" {
  14217. import { Scene } from "babylonjs/scene";
  14218. import { ISceneComponent } from "babylonjs/sceneComponent";
  14219. import { Layer } from "babylonjs/Layers/layer";
  14220. module "babylonjs/abstractScene" {
  14221. interface AbstractScene {
  14222. /**
  14223. * The list of layers (background and foreground) of the scene
  14224. */
  14225. layers: Array<Layer>;
  14226. }
  14227. }
  14228. /**
  14229. * Defines the layer scene component responsible to manage any layers
  14230. * in a given scene.
  14231. */
  14232. export class LayerSceneComponent implements ISceneComponent {
  14233. /**
  14234. * The component name helpfull to identify the component in the list of scene components.
  14235. */
  14236. readonly name: string;
  14237. /**
  14238. * The scene the component belongs to.
  14239. */
  14240. scene: Scene;
  14241. private _engine;
  14242. /**
  14243. * Creates a new instance of the component for the given scene
  14244. * @param scene Defines the scene to register the component in
  14245. */
  14246. constructor(scene: Scene);
  14247. /**
  14248. * Registers the component in a given scene
  14249. */
  14250. register(): void;
  14251. /**
  14252. * Rebuilds the elements related to this component in case of
  14253. * context lost for instance.
  14254. */
  14255. rebuild(): void;
  14256. /**
  14257. * Disposes the component and the associated ressources.
  14258. */
  14259. dispose(): void;
  14260. private _draw;
  14261. private _drawCameraPredicate;
  14262. private _drawCameraBackground;
  14263. private _drawCameraForeground;
  14264. private _drawRenderTargetPredicate;
  14265. private _drawRenderTargetBackground;
  14266. private _drawRenderTargetForeground;
  14267. }
  14268. }
  14269. declare module "babylonjs/Shaders/layer.fragment" {
  14270. /** @hidden */
  14271. export var layerPixelShader: {
  14272. name: string;
  14273. shader: string;
  14274. };
  14275. }
  14276. declare module "babylonjs/Shaders/layer.vertex" {
  14277. /** @hidden */
  14278. export var layerVertexShader: {
  14279. name: string;
  14280. shader: string;
  14281. };
  14282. }
  14283. declare module "babylonjs/Layers/layer" {
  14284. import { Observable } from "babylonjs/Misc/observable";
  14285. import { Nullable } from "babylonjs/types";
  14286. import { Scene } from "babylonjs/scene";
  14287. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14288. import { Texture } from "babylonjs/Materials/Textures/texture";
  14289. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14290. import "babylonjs/Shaders/layer.fragment";
  14291. import "babylonjs/Shaders/layer.vertex";
  14292. /**
  14293. * This represents a full screen 2d layer.
  14294. * This can be useful to display a picture in the background of your scene for instance.
  14295. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14296. */
  14297. export class Layer {
  14298. /**
  14299. * Define the name of the layer.
  14300. */
  14301. name: string;
  14302. /**
  14303. * Define the texture the layer should display.
  14304. */
  14305. texture: Nullable<Texture>;
  14306. /**
  14307. * Is the layer in background or foreground.
  14308. */
  14309. isBackground: boolean;
  14310. /**
  14311. * Define the color of the layer (instead of texture).
  14312. */
  14313. color: Color4;
  14314. /**
  14315. * Define the scale of the layer in order to zoom in out of the texture.
  14316. */
  14317. scale: Vector2;
  14318. /**
  14319. * Define an offset for the layer in order to shift the texture.
  14320. */
  14321. offset: Vector2;
  14322. /**
  14323. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14324. */
  14325. alphaBlendingMode: number;
  14326. /**
  14327. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14328. * Alpha test will not mix with the background color in case of transparency.
  14329. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14330. */
  14331. alphaTest: boolean;
  14332. /**
  14333. * Define a mask to restrict the layer to only some of the scene cameras.
  14334. */
  14335. layerMask: number;
  14336. /**
  14337. * Define the list of render target the layer is visible into.
  14338. */
  14339. renderTargetTextures: RenderTargetTexture[];
  14340. /**
  14341. * Define if the layer is only used in renderTarget or if it also
  14342. * renders in the main frame buffer of the canvas.
  14343. */
  14344. renderOnlyInRenderTargetTextures: boolean;
  14345. private _scene;
  14346. private _vertexBuffers;
  14347. private _indexBuffer;
  14348. private _effect;
  14349. private _alphaTestEffect;
  14350. /**
  14351. * An event triggered when the layer is disposed.
  14352. */
  14353. onDisposeObservable: Observable<Layer>;
  14354. private _onDisposeObserver;
  14355. /**
  14356. * Back compatibility with callback before the onDisposeObservable existed.
  14357. * The set callback will be triggered when the layer has been disposed.
  14358. */
  14359. onDispose: () => void;
  14360. /**
  14361. * An event triggered before rendering the scene
  14362. */
  14363. onBeforeRenderObservable: Observable<Layer>;
  14364. private _onBeforeRenderObserver;
  14365. /**
  14366. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14367. * The set callback will be triggered just before rendering the layer.
  14368. */
  14369. onBeforeRender: () => void;
  14370. /**
  14371. * An event triggered after rendering the scene
  14372. */
  14373. onAfterRenderObservable: Observable<Layer>;
  14374. private _onAfterRenderObserver;
  14375. /**
  14376. * Back compatibility with callback before the onAfterRenderObservable existed.
  14377. * The set callback will be triggered just after rendering the layer.
  14378. */
  14379. onAfterRender: () => void;
  14380. /**
  14381. * Instantiates a new layer.
  14382. * This represents a full screen 2d layer.
  14383. * This can be useful to display a picture in the background of your scene for instance.
  14384. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14385. * @param name Define the name of the layer in the scene
  14386. * @param imgUrl Define the url of the texture to display in the layer
  14387. * @param scene Define the scene the layer belongs to
  14388. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14389. * @param color Defines a color for the layer
  14390. */
  14391. constructor(
  14392. /**
  14393. * Define the name of the layer.
  14394. */
  14395. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14396. private _createIndexBuffer;
  14397. /** @hidden */
  14398. _rebuild(): void;
  14399. /**
  14400. * Renders the layer in the scene.
  14401. */
  14402. render(): void;
  14403. /**
  14404. * Disposes and releases the associated ressources.
  14405. */
  14406. dispose(): void;
  14407. }
  14408. }
  14409. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14410. import { Scene } from "babylonjs/scene";
  14411. import { ISceneComponent } from "babylonjs/sceneComponent";
  14412. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14413. module "babylonjs/abstractScene" {
  14414. interface AbstractScene {
  14415. /**
  14416. * The list of procedural textures added to the scene
  14417. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14418. */
  14419. proceduralTextures: Array<ProceduralTexture>;
  14420. }
  14421. }
  14422. /**
  14423. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14424. * in a given scene.
  14425. */
  14426. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14427. /**
  14428. * The component name helpfull to identify the component in the list of scene components.
  14429. */
  14430. readonly name: string;
  14431. /**
  14432. * The scene the component belongs to.
  14433. */
  14434. scene: Scene;
  14435. /**
  14436. * Creates a new instance of the component for the given scene
  14437. * @param scene Defines the scene to register the component in
  14438. */
  14439. constructor(scene: Scene);
  14440. /**
  14441. * Registers the component in a given scene
  14442. */
  14443. register(): void;
  14444. /**
  14445. * Rebuilds the elements related to this component in case of
  14446. * context lost for instance.
  14447. */
  14448. rebuild(): void;
  14449. /**
  14450. * Disposes the component and the associated ressources.
  14451. */
  14452. dispose(): void;
  14453. private _beforeClear;
  14454. }
  14455. }
  14456. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14457. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14458. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14459. module "babylonjs/Engines/engine" {
  14460. interface Engine {
  14461. /**
  14462. * Creates a new render target cube texture
  14463. * @param size defines the size of the texture
  14464. * @param options defines the options used to create the texture
  14465. * @returns a new render target cube texture stored in an InternalTexture
  14466. */
  14467. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14468. }
  14469. }
  14470. }
  14471. declare module "babylonjs/Shaders/procedural.vertex" {
  14472. /** @hidden */
  14473. export var proceduralVertexShader: {
  14474. name: string;
  14475. shader: string;
  14476. };
  14477. }
  14478. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14479. import { Observable } from "babylonjs/Misc/observable";
  14480. import { Nullable } from "babylonjs/types";
  14481. import { Scene } from "babylonjs/scene";
  14482. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14483. import { Effect } from "babylonjs/Materials/effect";
  14484. import { Texture } from "babylonjs/Materials/Textures/texture";
  14485. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14486. import "babylonjs/Shaders/procedural.vertex";
  14487. /**
  14488. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  14489. * This is the base class of any Procedural texture and contains most of the shareable code.
  14490. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14491. */
  14492. export class ProceduralTexture extends Texture {
  14493. isCube: boolean;
  14494. /**
  14495. * Define if the texture is enabled or not (disabled texture will not render)
  14496. */
  14497. isEnabled: boolean;
  14498. /**
  14499. * Define if the texture must be cleared before rendering (default is true)
  14500. */
  14501. autoClear: boolean;
  14502. /**
  14503. * Callback called when the texture is generated
  14504. */
  14505. onGenerated: () => void;
  14506. /**
  14507. * Event raised when the texture is generated
  14508. */
  14509. onGeneratedObservable: Observable<ProceduralTexture>;
  14510. /** @hidden */
  14511. _generateMipMaps: boolean;
  14512. /** @hidden **/
  14513. _effect: Effect;
  14514. /** @hidden */
  14515. _textures: {
  14516. [key: string]: Texture;
  14517. };
  14518. private _size;
  14519. private _currentRefreshId;
  14520. private _refreshRate;
  14521. private _vertexBuffers;
  14522. private _indexBuffer;
  14523. private _uniforms;
  14524. private _samplers;
  14525. private _fragment;
  14526. private _floats;
  14527. private _ints;
  14528. private _floatsArrays;
  14529. private _colors3;
  14530. private _colors4;
  14531. private _vectors2;
  14532. private _vectors3;
  14533. private _matrices;
  14534. private _fallbackTexture;
  14535. private _fallbackTextureUsed;
  14536. private _engine;
  14537. private _cachedDefines;
  14538. private _contentUpdateId;
  14539. private _contentData;
  14540. /**
  14541. * Instantiates a new procedural texture.
  14542. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  14543. * This is the base class of any Procedural texture and contains most of the shareable code.
  14544. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14545. * @param name Define the name of the texture
  14546. * @param size Define the size of the texture to create
  14547. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14548. * @param scene Define the scene the texture belongs to
  14549. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14550. * @param generateMipMaps Define if the texture should creates mip maps or not
  14551. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14552. */
  14553. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14554. /**
  14555. * The effect that is created when initializing the post process.
  14556. * @returns The created effect corrisponding the the postprocess.
  14557. */
  14558. getEffect(): Effect;
  14559. /**
  14560. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14561. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14562. */
  14563. getContent(): Nullable<ArrayBufferView>;
  14564. private _createIndexBuffer;
  14565. /** @hidden */
  14566. _rebuild(): void;
  14567. /**
  14568. * Resets the texture in order to recreate its associated resources.
  14569. * This can be called in case of context loss
  14570. */
  14571. reset(): void;
  14572. protected _getDefines(): string;
  14573. /**
  14574. * Is the texture ready to be used ? (rendered at least once)
  14575. * @returns true if ready, otherwise, false.
  14576. */
  14577. isReady(): boolean;
  14578. /**
  14579. * Resets the refresh counter of the texture and start bak from scratch.
  14580. * Could be useful to regenerate the texture if it is setup to render only once.
  14581. */
  14582. resetRefreshCounter(): void;
  14583. /**
  14584. * Set the fragment shader to use in order to render the texture.
  14585. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14586. */
  14587. setFragment(fragment: any): void;
  14588. /**
  14589. * Define the refresh rate of the texture or the rendering frequency.
  14590. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14591. */
  14592. refreshRate: number;
  14593. /** @hidden */
  14594. _shouldRender(): boolean;
  14595. /**
  14596. * Get the size the texture is rendering at.
  14597. * @returns the size (texture is always squared)
  14598. */
  14599. getRenderSize(): number;
  14600. /**
  14601. * Resize the texture to new value.
  14602. * @param size Define the new size the texture should have
  14603. * @param generateMipMaps Define whether the new texture should create mip maps
  14604. */
  14605. resize(size: number, generateMipMaps: boolean): void;
  14606. private _checkUniform;
  14607. /**
  14608. * Set a texture in the shader program used to render.
  14609. * @param name Define the name of the uniform samplers as defined in the shader
  14610. * @param texture Define the texture to bind to this sampler
  14611. * @return the texture itself allowing "fluent" like uniform updates
  14612. */
  14613. setTexture(name: string, texture: Texture): ProceduralTexture;
  14614. /**
  14615. * Set a float in the shader.
  14616. * @param name Define the name of the uniform as defined in the shader
  14617. * @param value Define the value to give to the uniform
  14618. * @return the texture itself allowing "fluent" like uniform updates
  14619. */
  14620. setFloat(name: string, value: number): ProceduralTexture;
  14621. /**
  14622. * Set a int in the shader.
  14623. * @param name Define the name of the uniform as defined in the shader
  14624. * @param value Define the value to give to the uniform
  14625. * @return the texture itself allowing "fluent" like uniform updates
  14626. */
  14627. setInt(name: string, value: number): ProceduralTexture;
  14628. /**
  14629. * Set an array of floats in the shader.
  14630. * @param name Define the name of the uniform as defined in the shader
  14631. * @param value Define the value to give to the uniform
  14632. * @return the texture itself allowing "fluent" like uniform updates
  14633. */
  14634. setFloats(name: string, value: number[]): ProceduralTexture;
  14635. /**
  14636. * Set a vec3 in the shader from a Color3.
  14637. * @param name Define the name of the uniform as defined in the shader
  14638. * @param value Define the value to give to the uniform
  14639. * @return the texture itself allowing "fluent" like uniform updates
  14640. */
  14641. setColor3(name: string, value: Color3): ProceduralTexture;
  14642. /**
  14643. * Set a vec4 in the shader from a Color4.
  14644. * @param name Define the name of the uniform as defined in the shader
  14645. * @param value Define the value to give to the uniform
  14646. * @return the texture itself allowing "fluent" like uniform updates
  14647. */
  14648. setColor4(name: string, value: Color4): ProceduralTexture;
  14649. /**
  14650. * Set a vec2 in the shader from a Vector2.
  14651. * @param name Define the name of the uniform as defined in the shader
  14652. * @param value Define the value to give to the uniform
  14653. * @return the texture itself allowing "fluent" like uniform updates
  14654. */
  14655. setVector2(name: string, value: Vector2): ProceduralTexture;
  14656. /**
  14657. * Set a vec3 in the shader from a Vector3.
  14658. * @param name Define the name of the uniform as defined in the shader
  14659. * @param value Define the value to give to the uniform
  14660. * @return the texture itself allowing "fluent" like uniform updates
  14661. */
  14662. setVector3(name: string, value: Vector3): ProceduralTexture;
  14663. /**
  14664. * Set a mat4 in the shader from a MAtrix.
  14665. * @param name Define the name of the uniform as defined in the shader
  14666. * @param value Define the value to give to the uniform
  14667. * @return the texture itself allowing "fluent" like uniform updates
  14668. */
  14669. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14670. /**
  14671. * Render the texture to its associated render target.
  14672. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14673. */
  14674. render(useCameraPostProcess?: boolean): void;
  14675. /**
  14676. * Clone the texture.
  14677. * @returns the cloned texture
  14678. */
  14679. clone(): ProceduralTexture;
  14680. /**
  14681. * Dispose the texture and release its asoociated resources.
  14682. */
  14683. dispose(): void;
  14684. }
  14685. }
  14686. declare module "babylonjs/Particles/baseParticleSystem" {
  14687. import { Nullable } from "babylonjs/types";
  14688. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14690. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14691. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14692. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14693. import { Scene } from "babylonjs/scene";
  14694. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14695. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14696. import { Texture } from "babylonjs/Materials/Textures/texture";
  14697. import { Animation } from "babylonjs/Animations/animation";
  14698. /**
  14699. * This represents the base class for particle system in Babylon.
  14700. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14701. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14702. * @example https://doc.babylonjs.com/babylon101/particles
  14703. */
  14704. export class BaseParticleSystem {
  14705. /**
  14706. * Source color is added to the destination color without alpha affecting the result
  14707. */
  14708. static BLENDMODE_ONEONE: number;
  14709. /**
  14710. * Blend current color and particle color using particle’s alpha
  14711. */
  14712. static BLENDMODE_STANDARD: number;
  14713. /**
  14714. * Add current color and particle color multiplied by particle’s alpha
  14715. */
  14716. static BLENDMODE_ADD: number;
  14717. /**
  14718. * Multiply current color with particle color
  14719. */
  14720. static BLENDMODE_MULTIPLY: number;
  14721. /**
  14722. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14723. */
  14724. static BLENDMODE_MULTIPLYADD: number;
  14725. /**
  14726. * List of animations used by the particle system.
  14727. */
  14728. animations: Animation[];
  14729. /**
  14730. * The id of the Particle system.
  14731. */
  14732. id: string;
  14733. /**
  14734. * The friendly name of the Particle system.
  14735. */
  14736. name: string;
  14737. /**
  14738. * The rendering group used by the Particle system to chose when to render.
  14739. */
  14740. renderingGroupId: number;
  14741. /**
  14742. * The emitter represents the Mesh or position we are attaching the particle system to.
  14743. */
  14744. emitter: Nullable<AbstractMesh | Vector3>;
  14745. /**
  14746. * The maximum number of particles to emit per frame
  14747. */
  14748. emitRate: number;
  14749. /**
  14750. * If you want to launch only a few particles at once, that can be done, as well.
  14751. */
  14752. manualEmitCount: number;
  14753. /**
  14754. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14755. */
  14756. updateSpeed: number;
  14757. /**
  14758. * The amount of time the particle system is running (depends of the overall update speed).
  14759. */
  14760. targetStopDuration: number;
  14761. /**
  14762. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14763. */
  14764. disposeOnStop: boolean;
  14765. /**
  14766. * Minimum power of emitting particles.
  14767. */
  14768. minEmitPower: number;
  14769. /**
  14770. * Maximum power of emitting particles.
  14771. */
  14772. maxEmitPower: number;
  14773. /**
  14774. * Minimum life time of emitting particles.
  14775. */
  14776. minLifeTime: number;
  14777. /**
  14778. * Maximum life time of emitting particles.
  14779. */
  14780. maxLifeTime: number;
  14781. /**
  14782. * Minimum Size of emitting particles.
  14783. */
  14784. minSize: number;
  14785. /**
  14786. * Maximum Size of emitting particles.
  14787. */
  14788. maxSize: number;
  14789. /**
  14790. * Minimum scale of emitting particles on X axis.
  14791. */
  14792. minScaleX: number;
  14793. /**
  14794. * Maximum scale of emitting particles on X axis.
  14795. */
  14796. maxScaleX: number;
  14797. /**
  14798. * Minimum scale of emitting particles on Y axis.
  14799. */
  14800. minScaleY: number;
  14801. /**
  14802. * Maximum scale of emitting particles on Y axis.
  14803. */
  14804. maxScaleY: number;
  14805. /**
  14806. * Gets or sets the minimal initial rotation in radians.
  14807. */
  14808. minInitialRotation: number;
  14809. /**
  14810. * Gets or sets the maximal initial rotation in radians.
  14811. */
  14812. maxInitialRotation: number;
  14813. /**
  14814. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14815. */
  14816. minAngularSpeed: number;
  14817. /**
  14818. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14819. */
  14820. maxAngularSpeed: number;
  14821. /**
  14822. * The texture used to render each particle. (this can be a spritesheet)
  14823. */
  14824. particleTexture: Nullable<Texture>;
  14825. /**
  14826. * The layer mask we are rendering the particles through.
  14827. */
  14828. layerMask: number;
  14829. /**
  14830. * This can help using your own shader to render the particle system.
  14831. * The according effect will be created
  14832. */
  14833. customShader: any;
  14834. /**
  14835. * By default particle system starts as soon as they are created. This prevents the
  14836. * automatic start to happen and let you decide when to start emitting particles.
  14837. */
  14838. preventAutoStart: boolean;
  14839. private _noiseTexture;
  14840. /**
  14841. * Gets or sets a texture used to add random noise to particle positions
  14842. */
  14843. noiseTexture: Nullable<ProceduralTexture>;
  14844. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14845. noiseStrength: Vector3;
  14846. /**
  14847. * Callback triggered when the particle animation is ending.
  14848. */
  14849. onAnimationEnd: Nullable<() => void>;
  14850. /**
  14851. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14852. */
  14853. blendMode: number;
  14854. /**
  14855. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14856. * to override the particles.
  14857. */
  14858. forceDepthWrite: boolean;
  14859. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  14860. preWarmCycles: number;
  14861. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14862. preWarmStepOffset: number;
  14863. /**
  14864. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14865. */
  14866. spriteCellChangeSpeed: number;
  14867. /**
  14868. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14869. */
  14870. startSpriteCellID: number;
  14871. /**
  14872. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14873. */
  14874. endSpriteCellID: number;
  14875. /**
  14876. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14877. */
  14878. spriteCellWidth: number;
  14879. /**
  14880. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14881. */
  14882. spriteCellHeight: number;
  14883. /**
  14884. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14885. */
  14886. spriteRandomStartCell: boolean;
  14887. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14888. translationPivot: Vector2;
  14889. /** @hidden */
  14890. protected _isAnimationSheetEnabled: boolean;
  14891. /**
  14892. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14893. */
  14894. beginAnimationOnStart: boolean;
  14895. /**
  14896. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14897. */
  14898. beginAnimationFrom: number;
  14899. /**
  14900. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14901. */
  14902. beginAnimationTo: number;
  14903. /**
  14904. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14905. */
  14906. beginAnimationLoop: boolean;
  14907. /**
  14908. * Gets or sets a world offset applied to all particles
  14909. */
  14910. worldOffset: Vector3;
  14911. /**
  14912. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14913. */
  14914. isAnimationSheetEnabled: boolean;
  14915. /**
  14916. * Get hosting scene
  14917. * @returns the scene
  14918. */
  14919. getScene(): Scene;
  14920. /**
  14921. * You can use gravity if you want to give an orientation to your particles.
  14922. */
  14923. gravity: Vector3;
  14924. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14925. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14926. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14927. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14928. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14929. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14930. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14931. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14932. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14933. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14934. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14935. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14936. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14937. /**
  14938. * Defines the delay in milliseconds before starting the system (0 by default)
  14939. */
  14940. startDelay: number;
  14941. /**
  14942. * Gets the current list of drag gradients.
  14943. * You must use addDragGradient and removeDragGradient to udpate this list
  14944. * @returns the list of drag gradients
  14945. */
  14946. getDragGradients(): Nullable<Array<FactorGradient>>;
  14947. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14948. limitVelocityDamping: number;
  14949. /**
  14950. * Gets the current list of limit velocity gradients.
  14951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14952. * @returns the list of limit velocity gradients
  14953. */
  14954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14955. /**
  14956. * Gets the current list of color gradients.
  14957. * You must use addColorGradient and removeColorGradient to udpate this list
  14958. * @returns the list of color gradients
  14959. */
  14960. getColorGradients(): Nullable<Array<ColorGradient>>;
  14961. /**
  14962. * Gets the current list of size gradients.
  14963. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14964. * @returns the list of size gradients
  14965. */
  14966. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14967. /**
  14968. * Gets the current list of color remap gradients.
  14969. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14970. * @returns the list of color remap gradients
  14971. */
  14972. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14973. /**
  14974. * Gets the current list of alpha remap gradients.
  14975. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14976. * @returns the list of alpha remap gradients
  14977. */
  14978. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14979. /**
  14980. * Gets the current list of life time gradients.
  14981. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14982. * @returns the list of life time gradients
  14983. */
  14984. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14985. /**
  14986. * Gets the current list of angular speed gradients.
  14987. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14988. * @returns the list of angular speed gradients
  14989. */
  14990. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14991. /**
  14992. * Gets the current list of velocity gradients.
  14993. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14994. * @returns the list of velocity gradients
  14995. */
  14996. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14997. /**
  14998. * Gets the current list of start size gradients.
  14999. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15000. * @returns the list of start size gradients
  15001. */
  15002. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15003. /**
  15004. * Gets the current list of emit rate gradients.
  15005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15006. * @returns the list of emit rate gradients
  15007. */
  15008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15009. /**
  15010. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15011. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15012. */
  15013. direction1: Vector3;
  15014. /**
  15015. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15016. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15017. */
  15018. direction2: Vector3;
  15019. /**
  15020. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15021. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15022. */
  15023. minEmitBox: Vector3;
  15024. /**
  15025. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15026. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15027. */
  15028. maxEmitBox: Vector3;
  15029. /**
  15030. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15031. */
  15032. color1: Color4;
  15033. /**
  15034. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15035. */
  15036. color2: Color4;
  15037. /**
  15038. * Color the particle will have at the end of its lifetime
  15039. */
  15040. colorDead: Color4;
  15041. /**
  15042. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15043. */
  15044. textureMask: Color4;
  15045. /**
  15046. * The particle emitter type defines the emitter used by the particle system.
  15047. * It can be for example box, sphere, or cone...
  15048. */
  15049. particleEmitterType: IParticleEmitterType;
  15050. /** @hidden */
  15051. _isSubEmitter: boolean;
  15052. /**
  15053. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15054. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15055. */
  15056. billboardMode: number;
  15057. protected _isBillboardBased: boolean;
  15058. /**
  15059. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15060. */
  15061. isBillboardBased: boolean;
  15062. /**
  15063. * The scene the particle system belongs to.
  15064. */
  15065. protected _scene: Scene;
  15066. /**
  15067. * Local cache of defines for image processing.
  15068. */
  15069. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15070. /**
  15071. * Default configuration related to image processing available in the standard Material.
  15072. */
  15073. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15074. /**
  15075. * Gets the image processing configuration used either in this material.
  15076. */
  15077. /**
  15078. * Sets the Default image processing configuration used either in the this material.
  15079. *
  15080. * If sets to null, the scene one is in use.
  15081. */
  15082. imageProcessingConfiguration: ImageProcessingConfiguration;
  15083. /**
  15084. * Attaches a new image processing configuration to the Standard Material.
  15085. * @param configuration
  15086. */
  15087. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15088. /** @hidden */
  15089. protected _reset(): void;
  15090. /** @hidden */
  15091. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15092. /**
  15093. * Instantiates a particle system.
  15094. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  15095. * @param name The name of the particle system
  15096. */
  15097. constructor(name: string);
  15098. /**
  15099. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15100. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15101. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15102. * @returns the emitter
  15103. */
  15104. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15105. /**
  15106. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15107. * @param radius The radius of the hemisphere to emit from
  15108. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15109. * @returns the emitter
  15110. */
  15111. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15112. /**
  15113. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15114. * @param radius The radius of the sphere to emit from
  15115. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15116. * @returns the emitter
  15117. */
  15118. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15119. /**
  15120. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15121. * @param radius The radius of the sphere to emit from
  15122. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15123. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15124. * @returns the emitter
  15125. */
  15126. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15127. /**
  15128. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15129. * @param radius The radius of the emission cylinder
  15130. * @param height The height of the emission cylinder
  15131. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15132. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15133. * @returns the emitter
  15134. */
  15135. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15136. /**
  15137. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15138. * @param radius The radius of the cylinder to emit from
  15139. * @param height The height of the emission cylinder
  15140. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15143. * @returns the emitter
  15144. */
  15145. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15146. /**
  15147. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15148. * @param radius The radius of the cone to emit from
  15149. * @param angle The base angle of the cone
  15150. * @returns the emitter
  15151. */
  15152. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15153. /**
  15154. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15155. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15156. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15157. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15158. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15159. * @returns the emitter
  15160. */
  15161. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15162. }
  15163. }
  15164. declare module "babylonjs/Particles/subEmitter" {
  15165. import { Scene } from "babylonjs/scene";
  15166. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15167. /**
  15168. * Type of sub emitter
  15169. */
  15170. export enum SubEmitterType {
  15171. /**
  15172. * Attached to the particle over it's lifetime
  15173. */
  15174. ATTACHED = 0,
  15175. /**
  15176. * Created when the particle dies
  15177. */
  15178. END = 1
  15179. }
  15180. /**
  15181. * Sub emitter class used to emit particles from an existing particle
  15182. */
  15183. export class SubEmitter {
  15184. /**
  15185. * the particle system to be used by the sub emitter
  15186. */
  15187. particleSystem: ParticleSystem;
  15188. /**
  15189. * Type of the submitter (Default: END)
  15190. */
  15191. type: SubEmitterType;
  15192. /**
  15193. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  15194. * Note: This only is supported when using an emitter of type Mesh
  15195. */
  15196. inheritDirection: boolean;
  15197. /**
  15198. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15199. */
  15200. inheritedVelocityAmount: number;
  15201. /**
  15202. * Creates a sub emitter
  15203. * @param particleSystem the particle system to be used by the sub emitter
  15204. */
  15205. constructor(
  15206. /**
  15207. * the particle system to be used by the sub emitter
  15208. */
  15209. particleSystem: ParticleSystem);
  15210. /**
  15211. * Clones the sub emitter
  15212. * @returns the cloned sub emitter
  15213. */
  15214. clone(): SubEmitter;
  15215. /**
  15216. * Serialize current object to a JSON object
  15217. * @returns the serialized object
  15218. */
  15219. serialize(): any;
  15220. /** @hidden */
  15221. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15222. /**
  15223. * Creates a new SubEmitter from a serialized JSON version
  15224. * @param serializationObject defines the JSON object to read from
  15225. * @param scene defines the hosting scene
  15226. * @param rootUrl defines the rootUrl for data loading
  15227. * @returns a new SubEmitter
  15228. */
  15229. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15230. /** Release associated resources */
  15231. dispose(): void;
  15232. }
  15233. }
  15234. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15235. /** @hidden */
  15236. export var clipPlaneFragmentDeclaration: {
  15237. name: string;
  15238. shader: string;
  15239. };
  15240. }
  15241. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15242. /** @hidden */
  15243. export var imageProcessingDeclaration: {
  15244. name: string;
  15245. shader: string;
  15246. };
  15247. }
  15248. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15249. /** @hidden */
  15250. export var imageProcessingFunctions: {
  15251. name: string;
  15252. shader: string;
  15253. };
  15254. }
  15255. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15256. /** @hidden */
  15257. export var clipPlaneFragment: {
  15258. name: string;
  15259. shader: string;
  15260. };
  15261. }
  15262. declare module "babylonjs/Shaders/particles.fragment" {
  15263. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15264. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15265. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15266. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15267. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15268. /** @hidden */
  15269. export var particlesPixelShader: {
  15270. name: string;
  15271. shader: string;
  15272. };
  15273. }
  15274. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15275. /** @hidden */
  15276. export var clipPlaneVertexDeclaration: {
  15277. name: string;
  15278. shader: string;
  15279. };
  15280. }
  15281. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15282. /** @hidden */
  15283. export var clipPlaneVertex: {
  15284. name: string;
  15285. shader: string;
  15286. };
  15287. }
  15288. declare module "babylonjs/Shaders/particles.vertex" {
  15289. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15290. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15291. /** @hidden */
  15292. export var particlesVertexShader: {
  15293. name: string;
  15294. shader: string;
  15295. };
  15296. }
  15297. declare module "babylonjs/Particles/particleSystem" {
  15298. import { Nullable } from "babylonjs/types";
  15299. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15300. import { Observable } from "babylonjs/Misc/observable";
  15301. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15302. import { Effect } from "babylonjs/Materials/effect";
  15303. import { Scene, IDisposable } from "babylonjs/scene";
  15304. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15305. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15306. import { Particle } from "babylonjs/Particles/particle";
  15307. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15308. import "babylonjs/Shaders/particles.fragment";
  15309. import "babylonjs/Shaders/particles.vertex";
  15310. /**
  15311. * This represents a particle system in Babylon.
  15312. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  15313. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15314. * @example https://doc.babylonjs.com/babylon101/particles
  15315. */
  15316. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15317. /**
  15318. * Billboard mode will only apply to Y axis
  15319. */
  15320. static readonly BILLBOARDMODE_Y: number;
  15321. /**
  15322. * Billboard mode will apply to all axes
  15323. */
  15324. static readonly BILLBOARDMODE_ALL: number;
  15325. /**
  15326. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15327. */
  15328. static readonly BILLBOARDMODE_STRETCHED: number;
  15329. /**
  15330. * This function can be defined to provide custom update for active particles.
  15331. * This function will be called instead of regular update (age, position, color, etc.).
  15332. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15333. */
  15334. updateFunction: (particles: Particle[]) => void;
  15335. private _emitterWorldMatrix;
  15336. /**
  15337. * This function can be defined to specify initial direction for every new particle.
  15338. * It by default use the emitterType defined function
  15339. */
  15340. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15341. /**
  15342. * This function can be defined to specify initial position for every new particle.
  15343. * It by default use the emitterType defined function
  15344. */
  15345. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15346. /**
  15347. * @hidden
  15348. */
  15349. _inheritedVelocityOffset: Vector3;
  15350. /**
  15351. * An event triggered when the system is disposed
  15352. */
  15353. onDisposeObservable: Observable<ParticleSystem>;
  15354. private _onDisposeObserver;
  15355. /**
  15356. * Sets a callback that will be triggered when the system is disposed
  15357. */
  15358. onDispose: () => void;
  15359. private _particles;
  15360. private _epsilon;
  15361. private _capacity;
  15362. private _stockParticles;
  15363. private _newPartsExcess;
  15364. private _vertexData;
  15365. private _vertexBuffer;
  15366. private _vertexBuffers;
  15367. private _spriteBuffer;
  15368. private _indexBuffer;
  15369. private _effect;
  15370. private _customEffect;
  15371. private _cachedDefines;
  15372. private _scaledColorStep;
  15373. private _colorDiff;
  15374. private _scaledDirection;
  15375. private _scaledGravity;
  15376. private _currentRenderId;
  15377. private _alive;
  15378. private _useInstancing;
  15379. private _started;
  15380. private _stopped;
  15381. private _actualFrame;
  15382. private _scaledUpdateSpeed;
  15383. private _vertexBufferSize;
  15384. /** @hidden */
  15385. _currentEmitRateGradient: Nullable<FactorGradient>;
  15386. /** @hidden */
  15387. _currentEmitRate1: number;
  15388. /** @hidden */
  15389. _currentEmitRate2: number;
  15390. /** @hidden */
  15391. _currentStartSizeGradient: Nullable<FactorGradient>;
  15392. /** @hidden */
  15393. _currentStartSize1: number;
  15394. /** @hidden */
  15395. _currentStartSize2: number;
  15396. private readonly _rawTextureWidth;
  15397. private _rampGradientsTexture;
  15398. private _useRampGradients;
  15399. /** Gets or sets a boolean indicating that ramp gradients must be used
  15400. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15401. */
  15402. useRampGradients: boolean;
  15403. /**
  15404. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  15405. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  15406. */
  15407. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15408. private _subEmitters;
  15409. /**
  15410. * @hidden
  15411. * If the particle systems emitter should be disposed when the particle system is disposed
  15412. */
  15413. _disposeEmitterOnDispose: boolean;
  15414. /**
  15415. * The current active Sub-systems, this property is used by the root particle system only.
  15416. */
  15417. activeSubSystems: Array<ParticleSystem>;
  15418. private _rootParticleSystem;
  15419. /**
  15420. * Gets the current list of active particles
  15421. */
  15422. readonly particles: Particle[];
  15423. /**
  15424. * Returns the string "ParticleSystem"
  15425. * @returns a string containing the class name
  15426. */
  15427. getClassName(): string;
  15428. /**
  15429. * Instantiates a particle system.
  15430. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  15431. * @param name The name of the particle system
  15432. * @param capacity The max number of particles alive at the same time
  15433. * @param scene The scene the particle system belongs to
  15434. * @param customEffect a custom effect used to change the way particles are rendered by default
  15435. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15436. * @param epsilon Offset used to render the particles
  15437. */
  15438. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15439. private _addFactorGradient;
  15440. private _removeFactorGradient;
  15441. /**
  15442. * Adds a new life time gradient
  15443. * @param gradient defines the gradient to use (between 0 and 1)
  15444. * @param factor defines the life time factor to affect to the specified gradient
  15445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15446. * @returns the current particle system
  15447. */
  15448. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15449. /**
  15450. * Remove a specific life time gradient
  15451. * @param gradient defines the gradient to remove
  15452. * @returns the current particle system
  15453. */
  15454. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15455. /**
  15456. * Adds a new size gradient
  15457. * @param gradient defines the gradient to use (between 0 and 1)
  15458. * @param factor defines the size factor to affect to the specified gradient
  15459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15460. * @returns the current particle system
  15461. */
  15462. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15463. /**
  15464. * Remove a specific size gradient
  15465. * @param gradient defines the gradient to remove
  15466. * @returns the current particle system
  15467. */
  15468. removeSizeGradient(gradient: number): IParticleSystem;
  15469. /**
  15470. * Adds a new color remap gradient
  15471. * @param gradient defines the gradient to use (between 0 and 1)
  15472. * @param min defines the color remap minimal range
  15473. * @param max defines the color remap maximal range
  15474. * @returns the current particle system
  15475. */
  15476. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15477. /**
  15478. * Remove a specific color remap gradient
  15479. * @param gradient defines the gradient to remove
  15480. * @returns the current particle system
  15481. */
  15482. removeColorRemapGradient(gradient: number): IParticleSystem;
  15483. /**
  15484. * Adds a new alpha remap gradient
  15485. * @param gradient defines the gradient to use (between 0 and 1)
  15486. * @param min defines the alpha remap minimal range
  15487. * @param max defines the alpha remap maximal range
  15488. * @returns the current particle system
  15489. */
  15490. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15491. /**
  15492. * Remove a specific alpha remap gradient
  15493. * @param gradient defines the gradient to remove
  15494. * @returns the current particle system
  15495. */
  15496. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15497. /**
  15498. * Adds a new angular speed gradient
  15499. * @param gradient defines the gradient to use (between 0 and 1)
  15500. * @param factor defines the angular speed to affect to the specified gradient
  15501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15502. * @returns the current particle system
  15503. */
  15504. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15505. /**
  15506. * Remove a specific angular speed gradient
  15507. * @param gradient defines the gradient to remove
  15508. * @returns the current particle system
  15509. */
  15510. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15511. /**
  15512. * Adds a new velocity gradient
  15513. * @param gradient defines the gradient to use (between 0 and 1)
  15514. * @param factor defines the velocity to affect to the specified gradient
  15515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15516. * @returns the current particle system
  15517. */
  15518. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15519. /**
  15520. * Remove a specific velocity gradient
  15521. * @param gradient defines the gradient to remove
  15522. * @returns the current particle system
  15523. */
  15524. removeVelocityGradient(gradient: number): IParticleSystem;
  15525. /**
  15526. * Adds a new limit velocity gradient
  15527. * @param gradient defines the gradient to use (between 0 and 1)
  15528. * @param factor defines the limit velocity value to affect to the specified gradient
  15529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15530. * @returns the current particle system
  15531. */
  15532. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15533. /**
  15534. * Remove a specific limit velocity gradient
  15535. * @param gradient defines the gradient to remove
  15536. * @returns the current particle system
  15537. */
  15538. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15539. /**
  15540. * Adds a new drag gradient
  15541. * @param gradient defines the gradient to use (between 0 and 1)
  15542. * @param factor defines the drag value to affect to the specified gradient
  15543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15544. * @returns the current particle system
  15545. */
  15546. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15547. /**
  15548. * Remove a specific drag gradient
  15549. * @param gradient defines the gradient to remove
  15550. * @returns the current particle system
  15551. */
  15552. removeDragGradient(gradient: number): IParticleSystem;
  15553. /**
  15554. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15555. * @param gradient defines the gradient to use (between 0 and 1)
  15556. * @param factor defines the emit rate value to affect to the specified gradient
  15557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15558. * @returns the current particle system
  15559. */
  15560. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15561. /**
  15562. * Remove a specific emit rate gradient
  15563. * @param gradient defines the gradient to remove
  15564. * @returns the current particle system
  15565. */
  15566. removeEmitRateGradient(gradient: number): IParticleSystem;
  15567. /**
  15568. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15569. * @param gradient defines the gradient to use (between 0 and 1)
  15570. * @param factor defines the start size value to affect to the specified gradient
  15571. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15572. * @returns the current particle system
  15573. */
  15574. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15575. /**
  15576. * Remove a specific start size gradient
  15577. * @param gradient defines the gradient to remove
  15578. * @returns the current particle system
  15579. */
  15580. removeStartSizeGradient(gradient: number): IParticleSystem;
  15581. private _createRampGradientTexture;
  15582. /**
  15583. * Gets the current list of ramp gradients.
  15584. * You must use addRampGradient and removeRampGradient to udpate this list
  15585. * @returns the list of ramp gradients
  15586. */
  15587. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15588. /**
  15589. * Adds a new ramp gradient used to remap particle colors
  15590. * @param gradient defines the gradient to use (between 0 and 1)
  15591. * @param color defines the color to affect to the specified gradient
  15592. * @returns the current particle system
  15593. */
  15594. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15595. /**
  15596. * Remove a specific ramp gradient
  15597. * @param gradient defines the gradient to remove
  15598. * @returns the current particle system
  15599. */
  15600. removeRampGradient(gradient: number): ParticleSystem;
  15601. /**
  15602. * Adds a new color gradient
  15603. * @param gradient defines the gradient to use (between 0 and 1)
  15604. * @param color1 defines the color to affect to the specified gradient
  15605. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15606. * @returns this particle system
  15607. */
  15608. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15609. /**
  15610. * Remove a specific color gradient
  15611. * @param gradient defines the gradient to remove
  15612. * @returns this particle system
  15613. */
  15614. removeColorGradient(gradient: number): IParticleSystem;
  15615. private _fetchR;
  15616. protected _reset(): void;
  15617. private _resetEffect;
  15618. private _createVertexBuffers;
  15619. private _createIndexBuffer;
  15620. /**
  15621. * Gets the maximum number of particles active at the same time.
  15622. * @returns The max number of active particles.
  15623. */
  15624. getCapacity(): number;
  15625. /**
  15626. * Gets whether there are still active particles in the system.
  15627. * @returns True if it is alive, otherwise false.
  15628. */
  15629. isAlive(): boolean;
  15630. /**
  15631. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15632. * @returns True if it has been started, otherwise false.
  15633. */
  15634. isStarted(): boolean;
  15635. private _prepareSubEmitterInternalArray;
  15636. /**
  15637. * Starts the particle system and begins to emit
  15638. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15639. */
  15640. start(delay?: number): void;
  15641. /**
  15642. * Stops the particle system.
  15643. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  15644. */
  15645. stop(stopSubEmitters?: boolean): void;
  15646. /**
  15647. * Remove all active particles
  15648. */
  15649. reset(): void;
  15650. /**
  15651. * @hidden (for internal use only)
  15652. */
  15653. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15654. /**
  15655. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15656. * Its lifetime will start back at 0.
  15657. */
  15658. recycleParticle: (particle: Particle) => void;
  15659. private _stopSubEmitters;
  15660. private _createParticle;
  15661. private _removeFromRoot;
  15662. private _emitFromParticle;
  15663. private _update;
  15664. /** @hidden */
  15665. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15666. /** @hidden */
  15667. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15668. /** @hidden */
  15669. private _getEffect;
  15670. /**
  15671. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15672. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15673. */
  15674. animate(preWarmOnly?: boolean): void;
  15675. private _appendParticleVertices;
  15676. /**
  15677. * Rebuilds the particle system.
  15678. */
  15679. rebuild(): void;
  15680. /**
  15681. * Is this system ready to be used/rendered
  15682. * @return true if the system is ready
  15683. */
  15684. isReady(): boolean;
  15685. private _render;
  15686. /**
  15687. * Renders the particle system in its current state.
  15688. * @returns the current number of particles
  15689. */
  15690. render(): number;
  15691. /**
  15692. * Disposes the particle system and free the associated resources
  15693. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15694. */
  15695. dispose(disposeTexture?: boolean): void;
  15696. /**
  15697. * Clones the particle system.
  15698. * @param name The name of the cloned object
  15699. * @param newEmitter The new emitter to use
  15700. * @returns the cloned particle system
  15701. */
  15702. clone(name: string, newEmitter: any): ParticleSystem;
  15703. /**
  15704. * Serializes the particle system to a JSON object.
  15705. * @returns the JSON object
  15706. */
  15707. serialize(): any;
  15708. /** @hidden */
  15709. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15710. /** @hidden */
  15711. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15712. /**
  15713. * Parses a JSON object to create a particle system.
  15714. * @param parsedParticleSystem The JSON object to parse
  15715. * @param scene The scene to create the particle system in
  15716. * @param rootUrl The root url to use to load external dependencies like texture
  15717. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15718. * @returns the Parsed particle system
  15719. */
  15720. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15721. }
  15722. }
  15723. declare module "babylonjs/Particles/particle" {
  15724. import { Nullable } from "babylonjs/types";
  15725. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15726. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15727. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15728. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15729. /**
  15730. * A particle represents one of the element emitted by a particle system.
  15731. * This is mainly define by its coordinates, direction, velocity and age.
  15732. */
  15733. export class Particle {
  15734. /**
  15735. * The particle system the particle belongs to.
  15736. */
  15737. particleSystem: ParticleSystem;
  15738. private static _Count;
  15739. /**
  15740. * Unique ID of the particle
  15741. */
  15742. id: number;
  15743. /**
  15744. * The world position of the particle in the scene.
  15745. */
  15746. position: Vector3;
  15747. /**
  15748. * The world direction of the particle in the scene.
  15749. */
  15750. direction: Vector3;
  15751. /**
  15752. * The color of the particle.
  15753. */
  15754. color: Color4;
  15755. /**
  15756. * The color change of the particle per step.
  15757. */
  15758. colorStep: Color4;
  15759. /**
  15760. * Defines how long will the life of the particle be.
  15761. */
  15762. lifeTime: number;
  15763. /**
  15764. * The current age of the particle.
  15765. */
  15766. age: number;
  15767. /**
  15768. * The current size of the particle.
  15769. */
  15770. size: number;
  15771. /**
  15772. * The current scale of the particle.
  15773. */
  15774. scale: Vector2;
  15775. /**
  15776. * The current angle of the particle.
  15777. */
  15778. angle: number;
  15779. /**
  15780. * Defines how fast is the angle changing.
  15781. */
  15782. angularSpeed: number;
  15783. /**
  15784. * Defines the cell index used by the particle to be rendered from a sprite.
  15785. */
  15786. cellIndex: number;
  15787. /**
  15788. * The information required to support color remapping
  15789. */
  15790. remapData: Vector4;
  15791. /** @hidden */
  15792. _randomCellOffset?: number;
  15793. /** @hidden */
  15794. _initialDirection: Nullable<Vector3>;
  15795. /** @hidden */
  15796. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15797. /** @hidden */
  15798. _initialStartSpriteCellID: number;
  15799. /** @hidden */
  15800. _initialEndSpriteCellID: number;
  15801. /** @hidden */
  15802. _currentColorGradient: Nullable<ColorGradient>;
  15803. /** @hidden */
  15804. _currentColor1: Color4;
  15805. /** @hidden */
  15806. _currentColor2: Color4;
  15807. /** @hidden */
  15808. _currentSizeGradient: Nullable<FactorGradient>;
  15809. /** @hidden */
  15810. _currentSize1: number;
  15811. /** @hidden */
  15812. _currentSize2: number;
  15813. /** @hidden */
  15814. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15815. /** @hidden */
  15816. _currentAngularSpeed1: number;
  15817. /** @hidden */
  15818. _currentAngularSpeed2: number;
  15819. /** @hidden */
  15820. _currentVelocityGradient: Nullable<FactorGradient>;
  15821. /** @hidden */
  15822. _currentVelocity1: number;
  15823. /** @hidden */
  15824. _currentVelocity2: number;
  15825. /** @hidden */
  15826. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15827. /** @hidden */
  15828. _currentLimitVelocity1: number;
  15829. /** @hidden */
  15830. _currentLimitVelocity2: number;
  15831. /** @hidden */
  15832. _currentDragGradient: Nullable<FactorGradient>;
  15833. /** @hidden */
  15834. _currentDrag1: number;
  15835. /** @hidden */
  15836. _currentDrag2: number;
  15837. /** @hidden */
  15838. _randomNoiseCoordinates1: Vector3;
  15839. /** @hidden */
  15840. _randomNoiseCoordinates2: Vector3;
  15841. /**
  15842. * Creates a new instance Particle
  15843. * @param particleSystem the particle system the particle belongs to
  15844. */
  15845. constructor(
  15846. /**
  15847. * The particle system the particle belongs to.
  15848. */
  15849. particleSystem: ParticleSystem);
  15850. private updateCellInfoFromSystem;
  15851. /**
  15852. * Defines how the sprite cell index is updated for the particle
  15853. */
  15854. updateCellIndex(): void;
  15855. /** @hidden */
  15856. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15857. /** @hidden */
  15858. _inheritParticleInfoToSubEmitters(): void;
  15859. /** @hidden */
  15860. _reset(): void;
  15861. /**
  15862. * Copy the properties of particle to another one.
  15863. * @param other the particle to copy the information to.
  15864. */
  15865. copyTo(other: Particle): void;
  15866. }
  15867. }
  15868. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15869. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15870. import { Effect } from "babylonjs/Materials/effect";
  15871. import { Particle } from "babylonjs/Particles/particle";
  15872. /**
  15873. * Particle emitter represents a volume emitting particles.
  15874. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15875. */
  15876. export interface IParticleEmitterType {
  15877. /**
  15878. * Called by the particle System when the direction is computed for the created particle.
  15879. * @param worldMatrix is the world matrix of the particle system
  15880. * @param directionToUpdate is the direction vector to update with the result
  15881. * @param particle is the particle we are computed the direction for
  15882. */
  15883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15884. /**
  15885. * Called by the particle System when the position is computed for the created particle.
  15886. * @param worldMatrix is the world matrix of the particle system
  15887. * @param positionToUpdate is the position vector to update with the result
  15888. * @param particle is the particle we are computed the position for
  15889. */
  15890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15891. /**
  15892. * Clones the current emitter and returns a copy of it
  15893. * @returns the new emitter
  15894. */
  15895. clone(): IParticleEmitterType;
  15896. /**
  15897. * Called by the GPUParticleSystem to setup the update shader
  15898. * @param effect defines the update shader
  15899. */
  15900. applyToShader(effect: Effect): void;
  15901. /**
  15902. * Returns a string to use to update the GPU particles update shader
  15903. * @returns the effect defines string
  15904. */
  15905. getEffectDefines(): string;
  15906. /**
  15907. * Returns a string representing the class name
  15908. * @returns a string containing the class name
  15909. */
  15910. getClassName(): string;
  15911. /**
  15912. * Serializes the particle system to a JSON object.
  15913. * @returns the JSON object
  15914. */
  15915. serialize(): any;
  15916. /**
  15917. * Parse properties from a JSON object
  15918. * @param serializationObject defines the JSON object
  15919. */
  15920. parse(serializationObject: any): void;
  15921. }
  15922. }
  15923. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15924. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15925. import { Effect } from "babylonjs/Materials/effect";
  15926. import { Particle } from "babylonjs/Particles/particle";
  15927. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15928. /**
  15929. * Particle emitter emitting particles from the inside of a box.
  15930. * It emits the particles randomly between 2 given directions.
  15931. */
  15932. export class BoxParticleEmitter implements IParticleEmitterType {
  15933. /**
  15934. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15935. */
  15936. direction1: Vector3;
  15937. /**
  15938. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15939. */
  15940. direction2: Vector3;
  15941. /**
  15942. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15943. */
  15944. minEmitBox: Vector3;
  15945. /**
  15946. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15947. */
  15948. maxEmitBox: Vector3;
  15949. /**
  15950. * Creates a new instance BoxParticleEmitter
  15951. */
  15952. constructor();
  15953. /**
  15954. * Called by the particle System when the direction is computed for the created particle.
  15955. * @param worldMatrix is the world matrix of the particle system
  15956. * @param directionToUpdate is the direction vector to update with the result
  15957. * @param particle is the particle we are computed the direction for
  15958. */
  15959. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15960. /**
  15961. * Called by the particle System when the position is computed for the created particle.
  15962. * @param worldMatrix is the world matrix of the particle system
  15963. * @param positionToUpdate is the position vector to update with the result
  15964. * @param particle is the particle we are computed the position for
  15965. */
  15966. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15967. /**
  15968. * Clones the current emitter and returns a copy of it
  15969. * @returns the new emitter
  15970. */
  15971. clone(): BoxParticleEmitter;
  15972. /**
  15973. * Called by the GPUParticleSystem to setup the update shader
  15974. * @param effect defines the update shader
  15975. */
  15976. applyToShader(effect: Effect): void;
  15977. /**
  15978. * Returns a string to use to update the GPU particles update shader
  15979. * @returns a string containng the defines string
  15980. */
  15981. getEffectDefines(): string;
  15982. /**
  15983. * Returns the string "BoxParticleEmitter"
  15984. * @returns a string containing the class name
  15985. */
  15986. getClassName(): string;
  15987. /**
  15988. * Serializes the particle system to a JSON object.
  15989. * @returns the JSON object
  15990. */
  15991. serialize(): any;
  15992. /**
  15993. * Parse properties from a JSON object
  15994. * @param serializationObject defines the JSON object
  15995. */
  15996. parse(serializationObject: any): void;
  15997. }
  15998. }
  15999. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16000. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16001. import { Effect } from "babylonjs/Materials/effect";
  16002. import { Particle } from "babylonjs/Particles/particle";
  16003. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16004. /**
  16005. * Particle emitter emitting particles from the inside of a cone.
  16006. * It emits the particles alongside the cone volume from the base to the particle.
  16007. * The emission direction might be randomized.
  16008. */
  16009. export class ConeParticleEmitter implements IParticleEmitterType {
  16010. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16011. directionRandomizer: number;
  16012. private _radius;
  16013. private _angle;
  16014. private _height;
  16015. /**
  16016. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16017. */
  16018. radiusRange: number;
  16019. /**
  16020. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16021. */
  16022. heightRange: number;
  16023. /**
  16024. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16025. */
  16026. emitFromSpawnPointOnly: boolean;
  16027. /**
  16028. * Gets or sets the radius of the emission cone
  16029. */
  16030. radius: number;
  16031. /**
  16032. * Gets or sets the angle of the emission cone
  16033. */
  16034. angle: number;
  16035. private _buildHeight;
  16036. /**
  16037. * Creates a new instance ConeParticleEmitter
  16038. * @param radius the radius of the emission cone (1 by default)
  16039. * @param angle the cone base angle (PI by default)
  16040. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16041. */
  16042. constructor(radius?: number, angle?: number,
  16043. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16044. directionRandomizer?: number);
  16045. /**
  16046. * Called by the particle System when the direction is computed for the created particle.
  16047. * @param worldMatrix is the world matrix of the particle system
  16048. * @param directionToUpdate is the direction vector to update with the result
  16049. * @param particle is the particle we are computed the direction for
  16050. */
  16051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16052. /**
  16053. * Called by the particle System when the position is computed for the created particle.
  16054. * @param worldMatrix is the world matrix of the particle system
  16055. * @param positionToUpdate is the position vector to update with the result
  16056. * @param particle is the particle we are computed the position for
  16057. */
  16058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16059. /**
  16060. * Clones the current emitter and returns a copy of it
  16061. * @returns the new emitter
  16062. */
  16063. clone(): ConeParticleEmitter;
  16064. /**
  16065. * Called by the GPUParticleSystem to setup the update shader
  16066. * @param effect defines the update shader
  16067. */
  16068. applyToShader(effect: Effect): void;
  16069. /**
  16070. * Returns a string to use to update the GPU particles update shader
  16071. * @returns a string containng the defines string
  16072. */
  16073. getEffectDefines(): string;
  16074. /**
  16075. * Returns the string "ConeParticleEmitter"
  16076. * @returns a string containing the class name
  16077. */
  16078. getClassName(): string;
  16079. /**
  16080. * Serializes the particle system to a JSON object.
  16081. * @returns the JSON object
  16082. */
  16083. serialize(): any;
  16084. /**
  16085. * Parse properties from a JSON object
  16086. * @param serializationObject defines the JSON object
  16087. */
  16088. parse(serializationObject: any): void;
  16089. }
  16090. }
  16091. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16092. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16093. import { Effect } from "babylonjs/Materials/effect";
  16094. import { Particle } from "babylonjs/Particles/particle";
  16095. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16096. /**
  16097. * Particle emitter emitting particles from the inside of a cylinder.
  16098. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16099. */
  16100. export class CylinderParticleEmitter implements IParticleEmitterType {
  16101. /**
  16102. * The radius of the emission cylinder.
  16103. */
  16104. radius: number;
  16105. /**
  16106. * The height of the emission cylinder.
  16107. */
  16108. height: number;
  16109. /**
  16110. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16111. */
  16112. radiusRange: number;
  16113. /**
  16114. * How much to randomize the particle direction [0-1].
  16115. */
  16116. directionRandomizer: number;
  16117. /**
  16118. * Creates a new instance CylinderParticleEmitter
  16119. * @param radius the radius of the emission cylinder (1 by default)
  16120. * @param height the height of the emission cylinder (1 by default)
  16121. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16122. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16123. */
  16124. constructor(
  16125. /**
  16126. * The radius of the emission cylinder.
  16127. */
  16128. radius?: number,
  16129. /**
  16130. * The height of the emission cylinder.
  16131. */
  16132. height?: number,
  16133. /**
  16134. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16135. */
  16136. radiusRange?: number,
  16137. /**
  16138. * How much to randomize the particle direction [0-1].
  16139. */
  16140. directionRandomizer?: number);
  16141. /**
  16142. * Called by the particle System when the direction is computed for the created particle.
  16143. * @param worldMatrix is the world matrix of the particle system
  16144. * @param directionToUpdate is the direction vector to update with the result
  16145. * @param particle is the particle we are computed the direction for
  16146. */
  16147. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16148. /**
  16149. * Called by the particle System when the position is computed for the created particle.
  16150. * @param worldMatrix is the world matrix of the particle system
  16151. * @param positionToUpdate is the position vector to update with the result
  16152. * @param particle is the particle we are computed the position for
  16153. */
  16154. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16155. /**
  16156. * Clones the current emitter and returns a copy of it
  16157. * @returns the new emitter
  16158. */
  16159. clone(): CylinderParticleEmitter;
  16160. /**
  16161. * Called by the GPUParticleSystem to setup the update shader
  16162. * @param effect defines the update shader
  16163. */
  16164. applyToShader(effect: Effect): void;
  16165. /**
  16166. * Returns a string to use to update the GPU particles update shader
  16167. * @returns a string containng the defines string
  16168. */
  16169. getEffectDefines(): string;
  16170. /**
  16171. * Returns the string "CylinderParticleEmitter"
  16172. * @returns a string containing the class name
  16173. */
  16174. getClassName(): string;
  16175. /**
  16176. * Serializes the particle system to a JSON object.
  16177. * @returns the JSON object
  16178. */
  16179. serialize(): any;
  16180. /**
  16181. * Parse properties from a JSON object
  16182. * @param serializationObject defines the JSON object
  16183. */
  16184. parse(serializationObject: any): void;
  16185. }
  16186. /**
  16187. * Particle emitter emitting particles from the inside of a cylinder.
  16188. * It emits the particles randomly between two vectors.
  16189. */
  16190. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16191. /**
  16192. * The min limit of the emission direction.
  16193. */
  16194. direction1: Vector3;
  16195. /**
  16196. * The max limit of the emission direction.
  16197. */
  16198. direction2: Vector3;
  16199. /**
  16200. * Creates a new instance CylinderDirectedParticleEmitter
  16201. * @param radius the radius of the emission cylinder (1 by default)
  16202. * @param height the height of the emission cylinder (1 by default)
  16203. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16204. * @param direction1 the min limit of the emission direction (up vector by default)
  16205. * @param direction2 the max limit of the emission direction (up vector by default)
  16206. */
  16207. constructor(radius?: number, height?: number, radiusRange?: number,
  16208. /**
  16209. * The min limit of the emission direction.
  16210. */
  16211. direction1?: Vector3,
  16212. /**
  16213. * The max limit of the emission direction.
  16214. */
  16215. direction2?: Vector3);
  16216. /**
  16217. * Called by the particle System when the direction is computed for the created particle.
  16218. * @param worldMatrix is the world matrix of the particle system
  16219. * @param directionToUpdate is the direction vector to update with the result
  16220. * @param particle is the particle we are computed the direction for
  16221. */
  16222. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16223. /**
  16224. * Clones the current emitter and returns a copy of it
  16225. * @returns the new emitter
  16226. */
  16227. clone(): CylinderDirectedParticleEmitter;
  16228. /**
  16229. * Called by the GPUParticleSystem to setup the update shader
  16230. * @param effect defines the update shader
  16231. */
  16232. applyToShader(effect: Effect): void;
  16233. /**
  16234. * Returns a string to use to update the GPU particles update shader
  16235. * @returns a string containng the defines string
  16236. */
  16237. getEffectDefines(): string;
  16238. /**
  16239. * Returns the string "CylinderDirectedParticleEmitter"
  16240. * @returns a string containing the class name
  16241. */
  16242. getClassName(): string;
  16243. /**
  16244. * Serializes the particle system to a JSON object.
  16245. * @returns the JSON object
  16246. */
  16247. serialize(): any;
  16248. /**
  16249. * Parse properties from a JSON object
  16250. * @param serializationObject defines the JSON object
  16251. */
  16252. parse(serializationObject: any): void;
  16253. }
  16254. }
  16255. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16256. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16257. import { Effect } from "babylonjs/Materials/effect";
  16258. import { Particle } from "babylonjs/Particles/particle";
  16259. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16260. /**
  16261. * Particle emitter emitting particles from the inside of a hemisphere.
  16262. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16263. */
  16264. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16265. /**
  16266. * The radius of the emission hemisphere.
  16267. */
  16268. radius: number;
  16269. /**
  16270. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16271. */
  16272. radiusRange: number;
  16273. /**
  16274. * How much to randomize the particle direction [0-1].
  16275. */
  16276. directionRandomizer: number;
  16277. /**
  16278. * Creates a new instance HemisphericParticleEmitter
  16279. * @param radius the radius of the emission hemisphere (1 by default)
  16280. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16281. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16282. */
  16283. constructor(
  16284. /**
  16285. * The radius of the emission hemisphere.
  16286. */
  16287. radius?: number,
  16288. /**
  16289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16290. */
  16291. radiusRange?: number,
  16292. /**
  16293. * How much to randomize the particle direction [0-1].
  16294. */
  16295. directionRandomizer?: number);
  16296. /**
  16297. * Called by the particle System when the direction is computed for the created particle.
  16298. * @param worldMatrix is the world matrix of the particle system
  16299. * @param directionToUpdate is the direction vector to update with the result
  16300. * @param particle is the particle we are computed the direction for
  16301. */
  16302. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16303. /**
  16304. * Called by the particle System when the position is computed for the created particle.
  16305. * @param worldMatrix is the world matrix of the particle system
  16306. * @param positionToUpdate is the position vector to update with the result
  16307. * @param particle is the particle we are computed the position for
  16308. */
  16309. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16310. /**
  16311. * Clones the current emitter and returns a copy of it
  16312. * @returns the new emitter
  16313. */
  16314. clone(): HemisphericParticleEmitter;
  16315. /**
  16316. * Called by the GPUParticleSystem to setup the update shader
  16317. * @param effect defines the update shader
  16318. */
  16319. applyToShader(effect: Effect): void;
  16320. /**
  16321. * Returns a string to use to update the GPU particles update shader
  16322. * @returns a string containng the defines string
  16323. */
  16324. getEffectDefines(): string;
  16325. /**
  16326. * Returns the string "HemisphericParticleEmitter"
  16327. * @returns a string containing the class name
  16328. */
  16329. getClassName(): string;
  16330. /**
  16331. * Serializes the particle system to a JSON object.
  16332. * @returns the JSON object
  16333. */
  16334. serialize(): any;
  16335. /**
  16336. * Parse properties from a JSON object
  16337. * @param serializationObject defines the JSON object
  16338. */
  16339. parse(serializationObject: any): void;
  16340. }
  16341. }
  16342. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16343. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16344. import { Effect } from "babylonjs/Materials/effect";
  16345. import { Particle } from "babylonjs/Particles/particle";
  16346. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16347. /**
  16348. * Particle emitter emitting particles from a point.
  16349. * It emits the particles randomly between 2 given directions.
  16350. */
  16351. export class PointParticleEmitter implements IParticleEmitterType {
  16352. /**
  16353. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16354. */
  16355. direction1: Vector3;
  16356. /**
  16357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16358. */
  16359. direction2: Vector3;
  16360. /**
  16361. * Creates a new instance PointParticleEmitter
  16362. */
  16363. constructor();
  16364. /**
  16365. * Called by the particle System when the direction is computed for the created particle.
  16366. * @param worldMatrix is the world matrix of the particle system
  16367. * @param directionToUpdate is the direction vector to update with the result
  16368. * @param particle is the particle we are computed the direction for
  16369. */
  16370. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16371. /**
  16372. * Called by the particle System when the position is computed for the created particle.
  16373. * @param worldMatrix is the world matrix of the particle system
  16374. * @param positionToUpdate is the position vector to update with the result
  16375. * @param particle is the particle we are computed the position for
  16376. */
  16377. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16378. /**
  16379. * Clones the current emitter and returns a copy of it
  16380. * @returns the new emitter
  16381. */
  16382. clone(): PointParticleEmitter;
  16383. /**
  16384. * Called by the GPUParticleSystem to setup the update shader
  16385. * @param effect defines the update shader
  16386. */
  16387. applyToShader(effect: Effect): void;
  16388. /**
  16389. * Returns a string to use to update the GPU particles update shader
  16390. * @returns a string containng the defines string
  16391. */
  16392. getEffectDefines(): string;
  16393. /**
  16394. * Returns the string "PointParticleEmitter"
  16395. * @returns a string containing the class name
  16396. */
  16397. getClassName(): string;
  16398. /**
  16399. * Serializes the particle system to a JSON object.
  16400. * @returns the JSON object
  16401. */
  16402. serialize(): any;
  16403. /**
  16404. * Parse properties from a JSON object
  16405. * @param serializationObject defines the JSON object
  16406. */
  16407. parse(serializationObject: any): void;
  16408. }
  16409. }
  16410. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16411. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16412. import { Effect } from "babylonjs/Materials/effect";
  16413. import { Particle } from "babylonjs/Particles/particle";
  16414. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16415. /**
  16416. * Particle emitter emitting particles from the inside of a sphere.
  16417. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16418. */
  16419. export class SphereParticleEmitter implements IParticleEmitterType {
  16420. /**
  16421. * The radius of the emission sphere.
  16422. */
  16423. radius: number;
  16424. /**
  16425. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16426. */
  16427. radiusRange: number;
  16428. /**
  16429. * How much to randomize the particle direction [0-1].
  16430. */
  16431. directionRandomizer: number;
  16432. /**
  16433. * Creates a new instance SphereParticleEmitter
  16434. * @param radius the radius of the emission sphere (1 by default)
  16435. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16436. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16437. */
  16438. constructor(
  16439. /**
  16440. * The radius of the emission sphere.
  16441. */
  16442. radius?: number,
  16443. /**
  16444. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16445. */
  16446. radiusRange?: number,
  16447. /**
  16448. * How much to randomize the particle direction [0-1].
  16449. */
  16450. directionRandomizer?: number);
  16451. /**
  16452. * Called by the particle System when the direction is computed for the created particle.
  16453. * @param worldMatrix is the world matrix of the particle system
  16454. * @param directionToUpdate is the direction vector to update with the result
  16455. * @param particle is the particle we are computed the direction for
  16456. */
  16457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16458. /**
  16459. * Called by the particle System when the position is computed for the created particle.
  16460. * @param worldMatrix is the world matrix of the particle system
  16461. * @param positionToUpdate is the position vector to update with the result
  16462. * @param particle is the particle we are computed the position for
  16463. */
  16464. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16465. /**
  16466. * Clones the current emitter and returns a copy of it
  16467. * @returns the new emitter
  16468. */
  16469. clone(): SphereParticleEmitter;
  16470. /**
  16471. * Called by the GPUParticleSystem to setup the update shader
  16472. * @param effect defines the update shader
  16473. */
  16474. applyToShader(effect: Effect): void;
  16475. /**
  16476. * Returns a string to use to update the GPU particles update shader
  16477. * @returns a string containng the defines string
  16478. */
  16479. getEffectDefines(): string;
  16480. /**
  16481. * Returns the string "SphereParticleEmitter"
  16482. * @returns a string containing the class name
  16483. */
  16484. getClassName(): string;
  16485. /**
  16486. * Serializes the particle system to a JSON object.
  16487. * @returns the JSON object
  16488. */
  16489. serialize(): any;
  16490. /**
  16491. * Parse properties from a JSON object
  16492. * @param serializationObject defines the JSON object
  16493. */
  16494. parse(serializationObject: any): void;
  16495. }
  16496. /**
  16497. * Particle emitter emitting particles from the inside of a sphere.
  16498. * It emits the particles randomly between two vectors.
  16499. */
  16500. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16501. /**
  16502. * The min limit of the emission direction.
  16503. */
  16504. direction1: Vector3;
  16505. /**
  16506. * The max limit of the emission direction.
  16507. */
  16508. direction2: Vector3;
  16509. /**
  16510. * Creates a new instance SphereDirectedParticleEmitter
  16511. * @param radius the radius of the emission sphere (1 by default)
  16512. * @param direction1 the min limit of the emission direction (up vector by default)
  16513. * @param direction2 the max limit of the emission direction (up vector by default)
  16514. */
  16515. constructor(radius?: number,
  16516. /**
  16517. * The min limit of the emission direction.
  16518. */
  16519. direction1?: Vector3,
  16520. /**
  16521. * The max limit of the emission direction.
  16522. */
  16523. direction2?: Vector3);
  16524. /**
  16525. * Called by the particle System when the direction is computed for the created particle.
  16526. * @param worldMatrix is the world matrix of the particle system
  16527. * @param directionToUpdate is the direction vector to update with the result
  16528. * @param particle is the particle we are computed the direction for
  16529. */
  16530. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16531. /**
  16532. * Clones the current emitter and returns a copy of it
  16533. * @returns the new emitter
  16534. */
  16535. clone(): SphereDirectedParticleEmitter;
  16536. /**
  16537. * Called by the GPUParticleSystem to setup the update shader
  16538. * @param effect defines the update shader
  16539. */
  16540. applyToShader(effect: Effect): void;
  16541. /**
  16542. * Returns a string to use to update the GPU particles update shader
  16543. * @returns a string containng the defines string
  16544. */
  16545. getEffectDefines(): string;
  16546. /**
  16547. * Returns the string "SphereDirectedParticleEmitter"
  16548. * @returns a string containing the class name
  16549. */
  16550. getClassName(): string;
  16551. /**
  16552. * Serializes the particle system to a JSON object.
  16553. * @returns the JSON object
  16554. */
  16555. serialize(): any;
  16556. /**
  16557. * Parse properties from a JSON object
  16558. * @param serializationObject defines the JSON object
  16559. */
  16560. parse(serializationObject: any): void;
  16561. }
  16562. }
  16563. declare module "babylonjs/Particles/EmitterTypes/index" {
  16564. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16565. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16566. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16567. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16568. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16569. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16570. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16571. }
  16572. declare module "babylonjs/Particles/IParticleSystem" {
  16573. import { Nullable } from "babylonjs/types";
  16574. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16577. import { Texture } from "babylonjs/Materials/Textures/texture";
  16578. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16579. import { Scene } from "babylonjs/scene";
  16580. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16581. import { Animation } from "babylonjs/Animations/animation";
  16582. /**
  16583. * Interface representing a particle system in Babylon.js.
  16584. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16585. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16586. */
  16587. export interface IParticleSystem {
  16588. /**
  16589. * List of animations used by the particle system.
  16590. */
  16591. animations: Animation[];
  16592. /**
  16593. * The id of the Particle system.
  16594. */
  16595. id: string;
  16596. /**
  16597. * The name of the Particle system.
  16598. */
  16599. name: string;
  16600. /**
  16601. * The emitter represents the Mesh or position we are attaching the particle system to.
  16602. */
  16603. emitter: Nullable<AbstractMesh | Vector3>;
  16604. /**
  16605. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16606. */
  16607. isBillboardBased: boolean;
  16608. /**
  16609. * The rendering group used by the Particle system to chose when to render.
  16610. */
  16611. renderingGroupId: number;
  16612. /**
  16613. * The layer mask we are rendering the particles through.
  16614. */
  16615. layerMask: number;
  16616. /**
  16617. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16618. */
  16619. updateSpeed: number;
  16620. /**
  16621. * The amount of time the particle system is running (depends of the overall update speed).
  16622. */
  16623. targetStopDuration: number;
  16624. /**
  16625. * The texture used to render each particle. (this can be a spritesheet)
  16626. */
  16627. particleTexture: Nullable<Texture>;
  16628. /**
  16629. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16630. */
  16631. blendMode: number;
  16632. /**
  16633. * Minimum life time of emitting particles.
  16634. */
  16635. minLifeTime: number;
  16636. /**
  16637. * Maximum life time of emitting particles.
  16638. */
  16639. maxLifeTime: number;
  16640. /**
  16641. * Minimum Size of emitting particles.
  16642. */
  16643. minSize: number;
  16644. /**
  16645. * Maximum Size of emitting particles.
  16646. */
  16647. maxSize: number;
  16648. /**
  16649. * Minimum scale of emitting particles on X axis.
  16650. */
  16651. minScaleX: number;
  16652. /**
  16653. * Maximum scale of emitting particles on X axis.
  16654. */
  16655. maxScaleX: number;
  16656. /**
  16657. * Minimum scale of emitting particles on Y axis.
  16658. */
  16659. minScaleY: number;
  16660. /**
  16661. * Maximum scale of emitting particles on Y axis.
  16662. */
  16663. maxScaleY: number;
  16664. /**
  16665. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16666. */
  16667. color1: Color4;
  16668. /**
  16669. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16670. */
  16671. color2: Color4;
  16672. /**
  16673. * Color the particle will have at the end of its lifetime.
  16674. */
  16675. colorDead: Color4;
  16676. /**
  16677. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16678. */
  16679. emitRate: number;
  16680. /**
  16681. * You can use gravity if you want to give an orientation to your particles.
  16682. */
  16683. gravity: Vector3;
  16684. /**
  16685. * Minimum power of emitting particles.
  16686. */
  16687. minEmitPower: number;
  16688. /**
  16689. * Maximum power of emitting particles.
  16690. */
  16691. maxEmitPower: number;
  16692. /**
  16693. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16694. */
  16695. minAngularSpeed: number;
  16696. /**
  16697. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16698. */
  16699. maxAngularSpeed: number;
  16700. /**
  16701. * Gets or sets the minimal initial rotation in radians.
  16702. */
  16703. minInitialRotation: number;
  16704. /**
  16705. * Gets or sets the maximal initial rotation in radians.
  16706. */
  16707. maxInitialRotation: number;
  16708. /**
  16709. * The particle emitter type defines the emitter used by the particle system.
  16710. * It can be for example box, sphere, or cone...
  16711. */
  16712. particleEmitterType: Nullable<IParticleEmitterType>;
  16713. /**
  16714. * Defines the delay in milliseconds before starting the system (0 by default)
  16715. */
  16716. startDelay: number;
  16717. /**
  16718. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  16719. */
  16720. preWarmCycles: number;
  16721. /**
  16722. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16723. */
  16724. preWarmStepOffset: number;
  16725. /**
  16726. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16727. */
  16728. spriteCellChangeSpeed: number;
  16729. /**
  16730. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16731. */
  16732. startSpriteCellID: number;
  16733. /**
  16734. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16735. */
  16736. endSpriteCellID: number;
  16737. /**
  16738. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16739. */
  16740. spriteCellWidth: number;
  16741. /**
  16742. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16743. */
  16744. spriteCellHeight: number;
  16745. /**
  16746. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16747. */
  16748. spriteRandomStartCell: boolean;
  16749. /**
  16750. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16751. */
  16752. isAnimationSheetEnabled: boolean;
  16753. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16754. translationPivot: Vector2;
  16755. /**
  16756. * Gets or sets a texture used to add random noise to particle positions
  16757. */
  16758. noiseTexture: Nullable<BaseTexture>;
  16759. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16760. noiseStrength: Vector3;
  16761. /**
  16762. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16763. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16764. */
  16765. billboardMode: number;
  16766. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16767. limitVelocityDamping: number;
  16768. /**
  16769. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16770. */
  16771. beginAnimationOnStart: boolean;
  16772. /**
  16773. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16774. */
  16775. beginAnimationFrom: number;
  16776. /**
  16777. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16778. */
  16779. beginAnimationTo: number;
  16780. /**
  16781. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16782. */
  16783. beginAnimationLoop: boolean;
  16784. /**
  16785. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16786. */
  16787. disposeOnStop: boolean;
  16788. /**
  16789. * Gets the maximum number of particles active at the same time.
  16790. * @returns The max number of active particles.
  16791. */
  16792. getCapacity(): number;
  16793. /**
  16794. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16795. * @returns True if it has been started, otherwise false.
  16796. */
  16797. isStarted(): boolean;
  16798. /**
  16799. * Animates the particle system for this frame.
  16800. */
  16801. animate(): void;
  16802. /**
  16803. * Renders the particle system in its current state.
  16804. * @returns the current number of particles
  16805. */
  16806. render(): number;
  16807. /**
  16808. * Dispose the particle system and frees its associated resources.
  16809. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16810. */
  16811. dispose(disposeTexture?: boolean): void;
  16812. /**
  16813. * Clones the particle system.
  16814. * @param name The name of the cloned object
  16815. * @param newEmitter The new emitter to use
  16816. * @returns the cloned particle system
  16817. */
  16818. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16819. /**
  16820. * Serializes the particle system to a JSON object.
  16821. * @returns the JSON object
  16822. */
  16823. serialize(): any;
  16824. /**
  16825. * Rebuild the particle system
  16826. */
  16827. rebuild(): void;
  16828. /**
  16829. * Starts the particle system and begins to emit
  16830. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16831. */
  16832. start(delay?: number): void;
  16833. /**
  16834. * Stops the particle system.
  16835. */
  16836. stop(): void;
  16837. /**
  16838. * Remove all active particles
  16839. */
  16840. reset(): void;
  16841. /**
  16842. * Is this system ready to be used/rendered
  16843. * @return true if the system is ready
  16844. */
  16845. isReady(): boolean;
  16846. /**
  16847. * Adds a new color gradient
  16848. * @param gradient defines the gradient to use (between 0 and 1)
  16849. * @param color1 defines the color to affect to the specified gradient
  16850. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16851. * @returns the current particle system
  16852. */
  16853. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16854. /**
  16855. * Remove a specific color gradient
  16856. * @param gradient defines the gradient to remove
  16857. * @returns the current particle system
  16858. */
  16859. removeColorGradient(gradient: number): IParticleSystem;
  16860. /**
  16861. * Adds a new size gradient
  16862. * @param gradient defines the gradient to use (between 0 and 1)
  16863. * @param factor defines the size factor to affect to the specified gradient
  16864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16865. * @returns the current particle system
  16866. */
  16867. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16868. /**
  16869. * Remove a specific size gradient
  16870. * @param gradient defines the gradient to remove
  16871. * @returns the current particle system
  16872. */
  16873. removeSizeGradient(gradient: number): IParticleSystem;
  16874. /**
  16875. * Gets the current list of color gradients.
  16876. * You must use addColorGradient and removeColorGradient to udpate this list
  16877. * @returns the list of color gradients
  16878. */
  16879. getColorGradients(): Nullable<Array<ColorGradient>>;
  16880. /**
  16881. * Gets the current list of size gradients.
  16882. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16883. * @returns the list of size gradients
  16884. */
  16885. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16886. /**
  16887. * Gets the current list of angular speed gradients.
  16888. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16889. * @returns the list of angular speed gradients
  16890. */
  16891. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16892. /**
  16893. * Adds a new angular speed gradient
  16894. * @param gradient defines the gradient to use (between 0 and 1)
  16895. * @param factor defines the angular speed to affect to the specified gradient
  16896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16897. * @returns the current particle system
  16898. */
  16899. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16900. /**
  16901. * Remove a specific angular speed gradient
  16902. * @param gradient defines the gradient to remove
  16903. * @returns the current particle system
  16904. */
  16905. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16906. /**
  16907. * Gets the current list of velocity gradients.
  16908. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16909. * @returns the list of velocity gradients
  16910. */
  16911. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16912. /**
  16913. * Adds a new velocity gradient
  16914. * @param gradient defines the gradient to use (between 0 and 1)
  16915. * @param factor defines the velocity to affect to the specified gradient
  16916. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16917. * @returns the current particle system
  16918. */
  16919. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16920. /**
  16921. * Remove a specific velocity gradient
  16922. * @param gradient defines the gradient to remove
  16923. * @returns the current particle system
  16924. */
  16925. removeVelocityGradient(gradient: number): IParticleSystem;
  16926. /**
  16927. * Gets the current list of limit velocity gradients.
  16928. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16929. * @returns the list of limit velocity gradients
  16930. */
  16931. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16932. /**
  16933. * Adds a new limit velocity gradient
  16934. * @param gradient defines the gradient to use (between 0 and 1)
  16935. * @param factor defines the limit velocity to affect to the specified gradient
  16936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16937. * @returns the current particle system
  16938. */
  16939. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16940. /**
  16941. * Remove a specific limit velocity gradient
  16942. * @param gradient defines the gradient to remove
  16943. * @returns the current particle system
  16944. */
  16945. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16946. /**
  16947. * Adds a new drag gradient
  16948. * @param gradient defines the gradient to use (between 0 and 1)
  16949. * @param factor defines the drag to affect to the specified gradient
  16950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16951. * @returns the current particle system
  16952. */
  16953. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16954. /**
  16955. * Remove a specific drag gradient
  16956. * @param gradient defines the gradient to remove
  16957. * @returns the current particle system
  16958. */
  16959. removeDragGradient(gradient: number): IParticleSystem;
  16960. /**
  16961. * Gets the current list of drag gradients.
  16962. * You must use addDragGradient and removeDragGradient to udpate this list
  16963. * @returns the list of drag gradients
  16964. */
  16965. getDragGradients(): Nullable<Array<FactorGradient>>;
  16966. /**
  16967. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16968. * @param gradient defines the gradient to use (between 0 and 1)
  16969. * @param factor defines the emit rate to affect to the specified gradient
  16970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16971. * @returns the current particle system
  16972. */
  16973. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16974. /**
  16975. * Remove a specific emit rate gradient
  16976. * @param gradient defines the gradient to remove
  16977. * @returns the current particle system
  16978. */
  16979. removeEmitRateGradient(gradient: number): IParticleSystem;
  16980. /**
  16981. * Gets the current list of emit rate gradients.
  16982. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16983. * @returns the list of emit rate gradients
  16984. */
  16985. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16986. /**
  16987. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16988. * @param gradient defines the gradient to use (between 0 and 1)
  16989. * @param factor defines the start size to affect to the specified gradient
  16990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16991. * @returns the current particle system
  16992. */
  16993. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16994. /**
  16995. * Remove a specific start size gradient
  16996. * @param gradient defines the gradient to remove
  16997. * @returns the current particle system
  16998. */
  16999. removeStartSizeGradient(gradient: number): IParticleSystem;
  17000. /**
  17001. * Gets the current list of start size gradients.
  17002. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17003. * @returns the list of start size gradients
  17004. */
  17005. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17006. /**
  17007. * Adds a new life time gradient
  17008. * @param gradient defines the gradient to use (between 0 and 1)
  17009. * @param factor defines the life time factor to affect to the specified gradient
  17010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17011. * @returns the current particle system
  17012. */
  17013. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17014. /**
  17015. * Remove a specific life time gradient
  17016. * @param gradient defines the gradient to remove
  17017. * @returns the current particle system
  17018. */
  17019. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17020. /**
  17021. * Gets the current list of life time gradients.
  17022. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17023. * @returns the list of life time gradients
  17024. */
  17025. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17026. /**
  17027. * Gets the current list of color gradients.
  17028. * You must use addColorGradient and removeColorGradient to udpate this list
  17029. * @returns the list of color gradients
  17030. */
  17031. getColorGradients(): Nullable<Array<ColorGradient>>;
  17032. /**
  17033. * Adds a new ramp gradient used to remap particle colors
  17034. * @param gradient defines the gradient to use (between 0 and 1)
  17035. * @param color defines the color to affect to the specified gradient
  17036. * @returns the current particle system
  17037. */
  17038. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17039. /**
  17040. * Gets the current list of ramp gradients.
  17041. * You must use addRampGradient and removeRampGradient to udpate this list
  17042. * @returns the list of ramp gradients
  17043. */
  17044. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17045. /** Gets or sets a boolean indicating that ramp gradients must be used
  17046. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17047. */
  17048. useRampGradients: boolean;
  17049. /**
  17050. * Adds a new color remap gradient
  17051. * @param gradient defines the gradient to use (between 0 and 1)
  17052. * @param min defines the color remap minimal range
  17053. * @param max defines the color remap maximal range
  17054. * @returns the current particle system
  17055. */
  17056. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17057. /**
  17058. * Gets the current list of color remap gradients.
  17059. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17060. * @returns the list of color remap gradients
  17061. */
  17062. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17063. /**
  17064. * Adds a new alpha remap gradient
  17065. * @param gradient defines the gradient to use (between 0 and 1)
  17066. * @param min defines the alpha remap minimal range
  17067. * @param max defines the alpha remap maximal range
  17068. * @returns the current particle system
  17069. */
  17070. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17071. /**
  17072. * Gets the current list of alpha remap gradients.
  17073. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17074. * @returns the list of alpha remap gradients
  17075. */
  17076. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17077. /**
  17078. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17079. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17080. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @returns the emitter
  17082. */
  17083. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17084. /**
  17085. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17086. * @param radius The radius of the hemisphere to emit from
  17087. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17088. * @returns the emitter
  17089. */
  17090. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17091. /**
  17092. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17093. * @param radius The radius of the sphere to emit from
  17094. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17095. * @returns the emitter
  17096. */
  17097. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17098. /**
  17099. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17100. * @param radius The radius of the sphere to emit from
  17101. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17102. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17103. * @returns the emitter
  17104. */
  17105. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17106. /**
  17107. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17108. * @param radius The radius of the emission cylinder
  17109. * @param height The height of the emission cylinder
  17110. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17111. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17112. * @returns the emitter
  17113. */
  17114. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17115. /**
  17116. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17117. * @param radius The radius of the cylinder to emit from
  17118. * @param height The height of the emission cylinder
  17119. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17120. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17121. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17122. * @returns the emitter
  17123. */
  17124. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17125. /**
  17126. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17127. * @param radius The radius of the cone to emit from
  17128. * @param angle The base angle of the cone
  17129. * @returns the emitter
  17130. */
  17131. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17132. /**
  17133. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17134. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17135. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17136. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17137. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17138. * @returns the emitter
  17139. */
  17140. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17141. /**
  17142. * Get hosting scene
  17143. * @returns the scene
  17144. */
  17145. getScene(): Scene;
  17146. }
  17147. }
  17148. declare module "babylonjs/Meshes/instancedMesh" {
  17149. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17150. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17151. import { Camera } from "babylonjs/Cameras/camera";
  17152. import { Node } from "babylonjs/node";
  17153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17154. import { Mesh } from "babylonjs/Meshes/mesh";
  17155. import { Material } from "babylonjs/Materials/material";
  17156. import { Skeleton } from "babylonjs/Bones/skeleton";
  17157. import { Light } from "babylonjs/Lights/light";
  17158. /**
  17159. * Creates an instance based on a source mesh.
  17160. */
  17161. export class InstancedMesh extends AbstractMesh {
  17162. private _sourceMesh;
  17163. private _currentLOD;
  17164. /** @hidden */
  17165. _indexInSourceMeshInstanceArray: number;
  17166. constructor(name: string, source: Mesh);
  17167. /**
  17168. * Returns the string "InstancedMesh".
  17169. */
  17170. getClassName(): string;
  17171. /** Gets the list of lights affecting that mesh */
  17172. readonly lightSources: Light[];
  17173. _resyncLightSources(): void;
  17174. _resyncLighSource(light: Light): void;
  17175. _removeLightSource(light: Light): void;
  17176. /**
  17177. * If the source mesh receives shadows
  17178. */
  17179. readonly receiveShadows: boolean;
  17180. /**
  17181. * The material of the source mesh
  17182. */
  17183. readonly material: Nullable<Material>;
  17184. /**
  17185. * Visibility of the source mesh
  17186. */
  17187. readonly visibility: number;
  17188. /**
  17189. * Skeleton of the source mesh
  17190. */
  17191. readonly skeleton: Nullable<Skeleton>;
  17192. /**
  17193. * Rendering ground id of the source mesh
  17194. */
  17195. renderingGroupId: number;
  17196. /**
  17197. * Returns the total number of vertices (integer).
  17198. */
  17199. getTotalVertices(): number;
  17200. /**
  17201. * Returns a positive integer : the total number of indices in this mesh geometry.
  17202. * @returns the numner of indices or zero if the mesh has no geometry.
  17203. */
  17204. getTotalIndices(): number;
  17205. /**
  17206. * The source mesh of the instance
  17207. */
  17208. readonly sourceMesh: Mesh;
  17209. /**
  17210. * Is this node ready to be used/rendered
  17211. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17212. * @return {boolean} is it ready
  17213. */
  17214. isReady(completeCheck?: boolean): boolean;
  17215. /**
  17216. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17217. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17218. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  17219. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17220. */
  17221. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17222. /**
  17223. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17224. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17225. * The `data` are either a numeric array either a Float32Array.
  17226. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17227. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  17228. * Note that a new underlying VertexBuffer object is created each call.
  17229. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17230. *
  17231. * Possible `kind` values :
  17232. * - VertexBuffer.PositionKind
  17233. * - VertexBuffer.UVKind
  17234. * - VertexBuffer.UV2Kind
  17235. * - VertexBuffer.UV3Kind
  17236. * - VertexBuffer.UV4Kind
  17237. * - VertexBuffer.UV5Kind
  17238. * - VertexBuffer.UV6Kind
  17239. * - VertexBuffer.ColorKind
  17240. * - VertexBuffer.MatricesIndicesKind
  17241. * - VertexBuffer.MatricesIndicesExtraKind
  17242. * - VertexBuffer.MatricesWeightsKind
  17243. * - VertexBuffer.MatricesWeightsExtraKind
  17244. *
  17245. * Returns the Mesh.
  17246. */
  17247. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17248. /**
  17249. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17250. * If the mesh has no geometry, it is simply returned as it is.
  17251. * The `data` are either a numeric array either a Float32Array.
  17252. * No new underlying VertexBuffer object is created.
  17253. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17254. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17255. *
  17256. * Possible `kind` values :
  17257. * - VertexBuffer.PositionKind
  17258. * - VertexBuffer.UVKind
  17259. * - VertexBuffer.UV2Kind
  17260. * - VertexBuffer.UV3Kind
  17261. * - VertexBuffer.UV4Kind
  17262. * - VertexBuffer.UV5Kind
  17263. * - VertexBuffer.UV6Kind
  17264. * - VertexBuffer.ColorKind
  17265. * - VertexBuffer.MatricesIndicesKind
  17266. * - VertexBuffer.MatricesIndicesExtraKind
  17267. * - VertexBuffer.MatricesWeightsKind
  17268. * - VertexBuffer.MatricesWeightsExtraKind
  17269. *
  17270. * Returns the Mesh.
  17271. */
  17272. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17273. /**
  17274. * Sets the mesh indices.
  17275. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17276. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17277. * This method creates a new index buffer each call.
  17278. * Returns the Mesh.
  17279. */
  17280. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17281. /**
  17282. * Boolean : True if the mesh owns the requested kind of data.
  17283. */
  17284. isVerticesDataPresent(kind: string): boolean;
  17285. /**
  17286. * Returns an array of indices (IndicesArray).
  17287. */
  17288. getIndices(): Nullable<IndicesArray>;
  17289. readonly _positions: Nullable<Vector3[]>;
  17290. /**
  17291. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17292. * This means the mesh underlying bounding box and sphere are recomputed.
  17293. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17294. * @returns the current mesh
  17295. */
  17296. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17297. /** @hidden */
  17298. _preActivate(): InstancedMesh;
  17299. /** @hidden */
  17300. _activate(renderId: number): boolean;
  17301. /** @hidden */
  17302. _postActivate(): void;
  17303. getWorldMatrix(): Matrix;
  17304. readonly isAnInstance: boolean;
  17305. /**
  17306. * Returns the current associated LOD AbstractMesh.
  17307. */
  17308. getLOD(camera: Camera): AbstractMesh;
  17309. /** @hidden */
  17310. _syncSubMeshes(): InstancedMesh;
  17311. /** @hidden */
  17312. _generatePointsArray(): boolean;
  17313. /**
  17314. * Creates a new InstancedMesh from the current mesh.
  17315. * - name (string) : the cloned mesh name
  17316. * - newParent (optional Node) : the optional Node to parent the clone to.
  17317. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17318. *
  17319. * Returns the clone.
  17320. */
  17321. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17322. /**
  17323. * Disposes the InstancedMesh.
  17324. * Returns nothing.
  17325. */
  17326. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17327. }
  17328. }
  17329. declare module "babylonjs/Materials/shaderMaterial" {
  17330. import { Scene } from "babylonjs/scene";
  17331. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17333. import { Mesh } from "babylonjs/Meshes/mesh";
  17334. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17335. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17336. import { Texture } from "babylonjs/Materials/Textures/texture";
  17337. import { Material } from "babylonjs/Materials/material";
  17338. /**
  17339. * Defines the options associated with the creation of a shader material.
  17340. */
  17341. export interface IShaderMaterialOptions {
  17342. /**
  17343. * Does the material work in alpha blend mode
  17344. */
  17345. needAlphaBlending: boolean;
  17346. /**
  17347. * Does the material work in alpha test mode
  17348. */
  17349. needAlphaTesting: boolean;
  17350. /**
  17351. * The list of attribute names used in the shader
  17352. */
  17353. attributes: string[];
  17354. /**
  17355. * The list of unifrom names used in the shader
  17356. */
  17357. uniforms: string[];
  17358. /**
  17359. * The list of UBO names used in the shader
  17360. */
  17361. uniformBuffers: string[];
  17362. /**
  17363. * The list of sampler names used in the shader
  17364. */
  17365. samplers: string[];
  17366. /**
  17367. * The list of defines used in the shader
  17368. */
  17369. defines: string[];
  17370. }
  17371. /**
  17372. * 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.
  17373. *
  17374. * This returned material effects how the mesh will look based on the code in the shaders.
  17375. *
  17376. * @see http://doc.babylonjs.com/how_to/shader_material
  17377. */
  17378. export class ShaderMaterial extends Material {
  17379. private _shaderPath;
  17380. private _options;
  17381. private _textures;
  17382. private _textureArrays;
  17383. private _floats;
  17384. private _ints;
  17385. private _floatsArrays;
  17386. private _colors3;
  17387. private _colors3Arrays;
  17388. private _colors4;
  17389. private _vectors2;
  17390. private _vectors3;
  17391. private _vectors4;
  17392. private _matrices;
  17393. private _matrices3x3;
  17394. private _matrices2x2;
  17395. private _vectors2Arrays;
  17396. private _vectors3Arrays;
  17397. private _cachedWorldViewMatrix;
  17398. private _renderId;
  17399. /**
  17400. * Instantiate a new shader material.
  17401. * 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.
  17402. * This returned material effects how the mesh will look based on the code in the shaders.
  17403. * @see http://doc.babylonjs.com/how_to/shader_material
  17404. * @param name Define the name of the material in the scene
  17405. * @param scene Define the scene the material belongs to
  17406. * @param shaderPath Defines the route to the shader code in one of three ways:
  17407. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17408. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17409. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17410. * @param options Define the options used to create the shader
  17411. */
  17412. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17413. /**
  17414. * Gets the options used to compile the shader.
  17415. * They can be modified to trigger a new compilation
  17416. */
  17417. readonly options: IShaderMaterialOptions;
  17418. /**
  17419. * Gets the current class name of the material e.g. "ShaderMaterial"
  17420. * Mainly use in serialization.
  17421. * @returns the class name
  17422. */
  17423. getClassName(): string;
  17424. /**
  17425. * Specifies if the material will require alpha blending
  17426. * @returns a boolean specifying if alpha blending is needed
  17427. */
  17428. needAlphaBlending(): boolean;
  17429. /**
  17430. * Specifies if this material should be rendered in alpha test mode
  17431. * @returns a boolean specifying if an alpha test is needed.
  17432. */
  17433. needAlphaTesting(): boolean;
  17434. private _checkUniform;
  17435. /**
  17436. * Set a texture in the shader.
  17437. * @param name Define the name of the uniform samplers as defined in the shader
  17438. * @param texture Define the texture to bind to this sampler
  17439. * @return the material itself allowing "fluent" like uniform updates
  17440. */
  17441. setTexture(name: string, texture: Texture): ShaderMaterial;
  17442. /**
  17443. * Set a texture array in the shader.
  17444. * @param name Define the name of the uniform sampler array as defined in the shader
  17445. * @param textures Define the list of textures to bind to this sampler
  17446. * @return the material itself allowing "fluent" like uniform updates
  17447. */
  17448. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17449. /**
  17450. * Set a float in the shader.
  17451. * @param name Define the name of the uniform as defined in the shader
  17452. * @param value Define the value to give to the uniform
  17453. * @return the material itself allowing "fluent" like uniform updates
  17454. */
  17455. setFloat(name: string, value: number): ShaderMaterial;
  17456. /**
  17457. * Set a int in the shader.
  17458. * @param name Define the name of the uniform as defined in the shader
  17459. * @param value Define the value to give to the uniform
  17460. * @return the material itself allowing "fluent" like uniform updates
  17461. */
  17462. setInt(name: string, value: number): ShaderMaterial;
  17463. /**
  17464. * Set an array of floats in the shader.
  17465. * @param name Define the name of the uniform as defined in the shader
  17466. * @param value Define the value to give to the uniform
  17467. * @return the material itself allowing "fluent" like uniform updates
  17468. */
  17469. setFloats(name: string, value: number[]): ShaderMaterial;
  17470. /**
  17471. * Set a vec3 in the shader from a Color3.
  17472. * @param name Define the name of the uniform as defined in the shader
  17473. * @param value Define the value to give to the uniform
  17474. * @return the material itself allowing "fluent" like uniform updates
  17475. */
  17476. setColor3(name: string, value: Color3): ShaderMaterial;
  17477. /**
  17478. * Set a vec3 array in the shader from a Color3 array.
  17479. * @param name Define the name of the uniform as defined in the shader
  17480. * @param value Define the value to give to the uniform
  17481. * @return the material itself allowing "fluent" like uniform updates
  17482. */
  17483. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17484. /**
  17485. * Set a vec4 in the shader from a Color4.
  17486. * @param name Define the name of the uniform as defined in the shader
  17487. * @param value Define the value to give to the uniform
  17488. * @return the material itself allowing "fluent" like uniform updates
  17489. */
  17490. setColor4(name: string, value: Color4): ShaderMaterial;
  17491. /**
  17492. * Set a vec2 in the shader from a Vector2.
  17493. * @param name Define the name of the uniform as defined in the shader
  17494. * @param value Define the value to give to the uniform
  17495. * @return the material itself allowing "fluent" like uniform updates
  17496. */
  17497. setVector2(name: string, value: Vector2): ShaderMaterial;
  17498. /**
  17499. * Set a vec3 in the shader from a Vector3.
  17500. * @param name Define the name of the uniform as defined in the shader
  17501. * @param value Define the value to give to the uniform
  17502. * @return the material itself allowing "fluent" like uniform updates
  17503. */
  17504. setVector3(name: string, value: Vector3): ShaderMaterial;
  17505. /**
  17506. * Set a vec4 in the shader from a Vector4.
  17507. * @param name Define the name of the uniform as defined in the shader
  17508. * @param value Define the value to give to the uniform
  17509. * @return the material itself allowing "fluent" like uniform updates
  17510. */
  17511. setVector4(name: string, value: Vector4): ShaderMaterial;
  17512. /**
  17513. * Set a mat4 in the shader from a Matrix.
  17514. * @param name Define the name of the uniform as defined in the shader
  17515. * @param value Define the value to give to the uniform
  17516. * @return the material itself allowing "fluent" like uniform updates
  17517. */
  17518. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17519. /**
  17520. * Set a mat3 in the shader from a Float32Array.
  17521. * @param name Define the name of the uniform as defined in the shader
  17522. * @param value Define the value to give to the uniform
  17523. * @return the material itself allowing "fluent" like uniform updates
  17524. */
  17525. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17526. /**
  17527. * Set a mat2 in the shader from a Float32Array.
  17528. * @param name Define the name of the uniform as defined in the shader
  17529. * @param value Define the value to give to the uniform
  17530. * @return the material itself allowing "fluent" like uniform updates
  17531. */
  17532. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17533. /**
  17534. * Set a vec2 array in the shader from a number array.
  17535. * @param name Define the name of the uniform as defined in the shader
  17536. * @param value Define the value to give to the uniform
  17537. * @return the material itself allowing "fluent" like uniform updates
  17538. */
  17539. setArray2(name: string, value: number[]): ShaderMaterial;
  17540. /**
  17541. * Set a vec3 array in the shader from a number array.
  17542. * @param name Define the name of the uniform as defined in the shader
  17543. * @param value Define the value to give to the uniform
  17544. * @return the material itself allowing "fluent" like uniform updates
  17545. */
  17546. setArray3(name: string, value: number[]): ShaderMaterial;
  17547. private _checkCache;
  17548. /**
  17549. * Specifies that the submesh is ready to be used
  17550. * @param mesh defines the mesh to check
  17551. * @param subMesh defines which submesh to check
  17552. * @param useInstances specifies that instances should be used
  17553. * @returns a boolean indicating that the submesh is ready or not
  17554. */
  17555. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17556. /**
  17557. * Checks if the material is ready to render the requested mesh
  17558. * @param mesh Define the mesh to render
  17559. * @param useInstances Define whether or not the material is used with instances
  17560. * @returns true if ready, otherwise false
  17561. */
  17562. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17563. /**
  17564. * Binds the world matrix to the material
  17565. * @param world defines the world transformation matrix
  17566. */
  17567. bindOnlyWorldMatrix(world: Matrix): void;
  17568. /**
  17569. * Binds the material to the mesh
  17570. * @param world defines the world transformation matrix
  17571. * @param mesh defines the mesh to bind the material to
  17572. */
  17573. bind(world: Matrix, mesh?: Mesh): void;
  17574. /**
  17575. * Gets the active textures from the material
  17576. * @returns an array of textures
  17577. */
  17578. getActiveTextures(): BaseTexture[];
  17579. /**
  17580. * Specifies if the material uses a texture
  17581. * @param texture defines the texture to check against the material
  17582. * @returns a boolean specifying if the material uses the texture
  17583. */
  17584. hasTexture(texture: BaseTexture): boolean;
  17585. /**
  17586. * Makes a duplicate of the material, and gives it a new name
  17587. * @param name defines the new name for the duplicated material
  17588. * @returns the cloned material
  17589. */
  17590. clone(name: string): ShaderMaterial;
  17591. /**
  17592. * Disposes the material
  17593. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17594. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17595. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17596. */
  17597. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17598. /**
  17599. * Serializes this material in a JSON representation
  17600. * @returns the serialized material object
  17601. */
  17602. serialize(): any;
  17603. /**
  17604. * Creates a shader material from parsed shader material data
  17605. * @param source defines the JSON represnetation of the material
  17606. * @param scene defines the hosting scene
  17607. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17608. * @returns a new material
  17609. */
  17610. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17611. }
  17612. }
  17613. declare module "babylonjs/Shaders/color.fragment" {
  17614. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17615. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17616. /** @hidden */
  17617. export var colorPixelShader: {
  17618. name: string;
  17619. shader: string;
  17620. };
  17621. }
  17622. declare module "babylonjs/Shaders/color.vertex" {
  17623. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17624. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17625. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17626. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17627. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17628. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17629. /** @hidden */
  17630. export var colorVertexShader: {
  17631. name: string;
  17632. shader: string;
  17633. };
  17634. }
  17635. declare module "babylonjs/Meshes/linesMesh" {
  17636. import { Nullable } from "babylonjs/types";
  17637. import { Scene } from "babylonjs/scene";
  17638. import { Color3 } from "babylonjs/Maths/math";
  17639. import { Node } from "babylonjs/node";
  17640. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17641. import { Mesh } from "babylonjs/Meshes/mesh";
  17642. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17643. import { Effect } from "babylonjs/Materials/effect";
  17644. import { Material } from "babylonjs/Materials/material";
  17645. import "babylonjs/Shaders/color.fragment";
  17646. import "babylonjs/Shaders/color.vertex";
  17647. /**
  17648. * Line mesh
  17649. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17650. */
  17651. export class LinesMesh extends Mesh {
  17652. /**
  17653. * If vertex color should be applied to the mesh
  17654. */
  17655. useVertexColor?: boolean | undefined;
  17656. /**
  17657. * If vertex alpha should be applied to the mesh
  17658. */
  17659. useVertexAlpha?: boolean | undefined;
  17660. /**
  17661. * Color of the line (Default: White)
  17662. */
  17663. color: Color3;
  17664. /**
  17665. * Alpha of the line (Default: 1)
  17666. */
  17667. alpha: number;
  17668. /**
  17669. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17670. * This margin is expressed in world space coordinates, so its value may vary.
  17671. * Default value is 0.1
  17672. */
  17673. intersectionThreshold: number;
  17674. private _colorShader;
  17675. /**
  17676. * Creates a new LinesMesh
  17677. * @param name defines the name
  17678. * @param scene defines the hosting scene
  17679. * @param parent defines the parent mesh if any
  17680. * @param source defines the optional source LinesMesh used to clone data from
  17681. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17682. * When false, achieved by calling a clone(), also passing False.
  17683. * This will make creation of children, recursive.
  17684. * @param useVertexColor defines if this LinesMesh supports vertex color
  17685. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17686. */
  17687. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17688. /**
  17689. * If vertex color should be applied to the mesh
  17690. */
  17691. useVertexColor?: boolean | undefined,
  17692. /**
  17693. * If vertex alpha should be applied to the mesh
  17694. */
  17695. useVertexAlpha?: boolean | undefined);
  17696. private _addClipPlaneDefine;
  17697. private _removeClipPlaneDefine;
  17698. isReady(): boolean;
  17699. /**
  17700. * Returns the string "LineMesh"
  17701. */
  17702. getClassName(): string;
  17703. /**
  17704. * @hidden
  17705. */
  17706. /**
  17707. * @hidden
  17708. */
  17709. material: Material;
  17710. /**
  17711. * @hidden
  17712. */
  17713. readonly checkCollisions: boolean;
  17714. /** @hidden */
  17715. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17716. /** @hidden */
  17717. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17718. /**
  17719. * Disposes of the line mesh
  17720. * @param doNotRecurse If children should be disposed
  17721. */
  17722. dispose(doNotRecurse?: boolean): void;
  17723. /**
  17724. * Returns a new LineMesh object cloned from the current one.
  17725. */
  17726. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17727. /**
  17728. * Creates a new InstancedLinesMesh object from the mesh model.
  17729. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17730. * @param name defines the name of the new instance
  17731. * @returns a new InstancedLinesMesh
  17732. */
  17733. createInstance(name: string): InstancedLinesMesh;
  17734. }
  17735. /**
  17736. * Creates an instance based on a source LinesMesh
  17737. */
  17738. export class InstancedLinesMesh extends InstancedMesh {
  17739. /**
  17740. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17741. * This margin is expressed in world space coordinates, so its value may vary.
  17742. * Initilized with the intersectionThreshold value of the source LinesMesh
  17743. */
  17744. intersectionThreshold: number;
  17745. constructor(name: string, source: LinesMesh);
  17746. /**
  17747. * Returns the string "InstancedLinesMesh".
  17748. */
  17749. getClassName(): string;
  17750. }
  17751. }
  17752. declare module "babylonjs/Shaders/line.fragment" {
  17753. /** @hidden */
  17754. export var linePixelShader: {
  17755. name: string;
  17756. shader: string;
  17757. };
  17758. }
  17759. declare module "babylonjs/Shaders/line.vertex" {
  17760. /** @hidden */
  17761. export var lineVertexShader: {
  17762. name: string;
  17763. shader: string;
  17764. };
  17765. }
  17766. declare module "babylonjs/Rendering/edgesRenderer" {
  17767. import { Nullable } from "babylonjs/types";
  17768. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17770. import { Vector3 } from "babylonjs/Maths/math";
  17771. import { IDisposable } from "babylonjs/scene";
  17772. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17773. import "babylonjs/Shaders/line.fragment";
  17774. import "babylonjs/Shaders/line.vertex";
  17775. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17776. module "babylonjs/Meshes/abstractMesh" {
  17777. interface AbstractMesh {
  17778. /**
  17779. * Disables the mesh edge rendering mode
  17780. * @returns the currentAbstractMesh
  17781. */
  17782. disableEdgesRendering(): AbstractMesh;
  17783. /**
  17784. * Enables the edge rendering mode on the mesh.
  17785. * This mode makes the mesh edges visible
  17786. * @param epsilon defines the maximal distance between two angles to detect a face
  17787. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17788. * @returns the currentAbstractMesh
  17789. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17790. */
  17791. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17792. /**
  17793. * Gets the edgesRenderer associated with the mesh
  17794. */
  17795. edgesRenderer: Nullable<EdgesRenderer>;
  17796. }
  17797. }
  17798. module "babylonjs/Meshes/linesMesh" {
  17799. interface LinesMesh {
  17800. /**
  17801. * Enables the edge rendering mode on the mesh.
  17802. * This mode makes the mesh edges visible
  17803. * @param epsilon defines the maximal distance between two angles to detect a face
  17804. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17805. * @returns the currentAbstractMesh
  17806. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17807. */
  17808. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17809. }
  17810. }
  17811. module "babylonjs/Meshes/linesMesh" {
  17812. interface InstancedLinesMesh {
  17813. /**
  17814. * Enables the edge rendering mode on the mesh.
  17815. * This mode makes the mesh edges visible
  17816. * @param epsilon defines the maximal distance between two angles to detect a face
  17817. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17818. * @returns the current InstancedLinesMesh
  17819. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17820. */
  17821. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17822. }
  17823. }
  17824. /**
  17825. * Defines the minimum contract an Edges renderer should follow.
  17826. */
  17827. export interface IEdgesRenderer extends IDisposable {
  17828. /**
  17829. * Gets or sets a boolean indicating if the edgesRenderer is active
  17830. */
  17831. isEnabled: boolean;
  17832. /**
  17833. * Renders the edges of the attached mesh,
  17834. */
  17835. render(): void;
  17836. /**
  17837. * Checks wether or not the edges renderer is ready to render.
  17838. * @return true if ready, otherwise false.
  17839. */
  17840. isReady(): boolean;
  17841. }
  17842. /**
  17843. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17844. */
  17845. export class EdgesRenderer implements IEdgesRenderer {
  17846. /**
  17847. * Define the size of the edges with an orthographic camera
  17848. */
  17849. edgesWidthScalerForOrthographic: number;
  17850. /**
  17851. * Define the size of the edges with a perspective camera
  17852. */
  17853. edgesWidthScalerForPerspective: number;
  17854. protected _source: AbstractMesh;
  17855. protected _linesPositions: number[];
  17856. protected _linesNormals: number[];
  17857. protected _linesIndices: number[];
  17858. protected _epsilon: number;
  17859. protected _indicesCount: number;
  17860. protected _lineShader: ShaderMaterial;
  17861. protected _ib: DataBuffer;
  17862. protected _buffers: {
  17863. [key: string]: Nullable<VertexBuffer>;
  17864. };
  17865. protected _checkVerticesInsteadOfIndices: boolean;
  17866. private _meshRebuildObserver;
  17867. private _meshDisposeObserver;
  17868. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17869. isEnabled: boolean;
  17870. /**
  17871. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17872. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17873. * @param source Mesh used to create edges
  17874. * @param epsilon sum of angles in adjacency to check for edge
  17875. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17876. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17877. */
  17878. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17879. protected _prepareRessources(): void;
  17880. /** @hidden */
  17881. _rebuild(): void;
  17882. /**
  17883. * Releases the required resources for the edges renderer
  17884. */
  17885. dispose(): void;
  17886. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17887. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17888. /**
  17889. * Checks if the pair of p0 and p1 is en edge
  17890. * @param faceIndex
  17891. * @param edge
  17892. * @param faceNormals
  17893. * @param p0
  17894. * @param p1
  17895. * @private
  17896. */
  17897. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17898. /**
  17899. * push line into the position, normal and index buffer
  17900. * @protected
  17901. */
  17902. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17903. /**
  17904. * Generates lines edges from adjacencjes
  17905. * @private
  17906. */
  17907. _generateEdgesLines(): void;
  17908. /**
  17909. * Checks wether or not the edges renderer is ready to render.
  17910. * @return true if ready, otherwise false.
  17911. */
  17912. isReady(): boolean;
  17913. /**
  17914. * Renders the edges of the attached mesh,
  17915. */
  17916. render(): void;
  17917. }
  17918. /**
  17919. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17920. */
  17921. export class LineEdgesRenderer extends EdgesRenderer {
  17922. /**
  17923. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17924. * @param source LineMesh used to generate edges
  17925. * @param epsilon not important (specified angle for edge detection)
  17926. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17927. */
  17928. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17929. /**
  17930. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17931. */
  17932. _generateEdgesLines(): void;
  17933. }
  17934. }
  17935. declare module "babylonjs/Rendering/renderingGroup" {
  17936. import { SmartArray } from "babylonjs/Misc/smartArray";
  17937. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17939. import { Nullable } from "babylonjs/types";
  17940. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17941. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17942. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17943. import { Material } from "babylonjs/Materials/material";
  17944. import { Scene } from "babylonjs/scene";
  17945. /**
  17946. * This represents the object necessary to create a rendering group.
  17947. * This is exclusively used and created by the rendering manager.
  17948. * To modify the behavior, you use the available helpers in your scene or meshes.
  17949. * @hidden
  17950. */
  17951. export class RenderingGroup {
  17952. index: number;
  17953. private _scene;
  17954. private _opaqueSubMeshes;
  17955. private _transparentSubMeshes;
  17956. private _alphaTestSubMeshes;
  17957. private _depthOnlySubMeshes;
  17958. private _particleSystems;
  17959. private _spriteManagers;
  17960. private _opaqueSortCompareFn;
  17961. private _alphaTestSortCompareFn;
  17962. private _transparentSortCompareFn;
  17963. private _renderOpaque;
  17964. private _renderAlphaTest;
  17965. private _renderTransparent;
  17966. /** @hidden */
  17967. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17968. onBeforeTransparentRendering: () => void;
  17969. /**
  17970. * Set the opaque sort comparison function.
  17971. * If null the sub meshes will be render in the order they were created
  17972. */
  17973. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17974. /**
  17975. * Set the alpha test sort comparison function.
  17976. * If null the sub meshes will be render in the order they were created
  17977. */
  17978. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17979. /**
  17980. * Set the transparent sort comparison function.
  17981. * If null the sub meshes will be render in the order they were created
  17982. */
  17983. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17984. /**
  17985. * Creates a new rendering group.
  17986. * @param index The rendering group index
  17987. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17988. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17989. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17990. */
  17991. 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>);
  17992. /**
  17993. * Render all the sub meshes contained in the group.
  17994. * @param customRenderFunction Used to override the default render behaviour of the group.
  17995. * @returns true if rendered some submeshes.
  17996. */
  17997. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17998. /**
  17999. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  18000. * @param subMeshes The submeshes to render
  18001. */
  18002. private renderOpaqueSorted;
  18003. /**
  18004. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  18005. * @param subMeshes The submeshes to render
  18006. */
  18007. private renderAlphaTestSorted;
  18008. /**
  18009. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  18010. * @param subMeshes The submeshes to render
  18011. */
  18012. private renderTransparentSorted;
  18013. /**
  18014. * Renders the submeshes in a specified order.
  18015. * @param subMeshes The submeshes to sort before render
  18016. * @param sortCompareFn The comparison function use to sort
  18017. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18018. * @param transparent Specifies to activate blending if true
  18019. */
  18020. private static renderSorted;
  18021. /**
  18022. * Renders the submeshes in the order they were dispatched (no sort applied).
  18023. * @param subMeshes The submeshes to render
  18024. */
  18025. private static renderUnsorted;
  18026. /**
  18027. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18028. * are rendered back to front if in the same alpha index.
  18029. *
  18030. * @param a The first submesh
  18031. * @param b The second submesh
  18032. * @returns The result of the comparison
  18033. */
  18034. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18035. /**
  18036. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18037. * are rendered back to front.
  18038. *
  18039. * @param a The first submesh
  18040. * @param b The second submesh
  18041. * @returns The result of the comparison
  18042. */
  18043. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18044. /**
  18045. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18046. * are rendered front to back (prevent overdraw).
  18047. *
  18048. * @param a The first submesh
  18049. * @param b The second submesh
  18050. * @returns The result of the comparison
  18051. */
  18052. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18053. /**
  18054. * Resets the different lists of submeshes to prepare a new frame.
  18055. */
  18056. prepare(): void;
  18057. dispose(): void;
  18058. /**
  18059. * Inserts the submesh in its correct queue depending on its material.
  18060. * @param subMesh The submesh to dispatch
  18061. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18062. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18063. */
  18064. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18065. dispatchSprites(spriteManager: ISpriteManager): void;
  18066. dispatchParticles(particleSystem: IParticleSystem): void;
  18067. private _renderParticles;
  18068. private _renderSprites;
  18069. }
  18070. }
  18071. declare module "babylonjs/Rendering/renderingManager" {
  18072. import { Nullable } from "babylonjs/types";
  18073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18074. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18075. import { SmartArray } from "babylonjs/Misc/smartArray";
  18076. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18077. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18078. import { Material } from "babylonjs/Materials/material";
  18079. import { Scene } from "babylonjs/scene";
  18080. import { Camera } from "babylonjs/Cameras/camera";
  18081. /**
  18082. * Interface describing the different options available in the rendering manager
  18083. * regarding Auto Clear between groups.
  18084. */
  18085. export interface IRenderingManagerAutoClearSetup {
  18086. /**
  18087. * Defines whether or not autoclear is enable.
  18088. */
  18089. autoClear: boolean;
  18090. /**
  18091. * Defines whether or not to autoclear the depth buffer.
  18092. */
  18093. depth: boolean;
  18094. /**
  18095. * Defines whether or not to autoclear the stencil buffer.
  18096. */
  18097. stencil: boolean;
  18098. }
  18099. /**
  18100. * This class is used by the onRenderingGroupObservable
  18101. */
  18102. export class RenderingGroupInfo {
  18103. /**
  18104. * The Scene that being rendered
  18105. */
  18106. scene: Scene;
  18107. /**
  18108. * The camera currently used for the rendering pass
  18109. */
  18110. camera: Nullable<Camera>;
  18111. /**
  18112. * The ID of the renderingGroup being processed
  18113. */
  18114. renderingGroupId: number;
  18115. }
  18116. /**
  18117. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18118. * It is enable to manage the different groups as well as the different necessary sort functions.
  18119. * This should not be used directly aside of the few static configurations
  18120. */
  18121. export class RenderingManager {
  18122. /**
  18123. * The max id used for rendering groups (not included)
  18124. */
  18125. static MAX_RENDERINGGROUPS: number;
  18126. /**
  18127. * The min id used for rendering groups (included)
  18128. */
  18129. static MIN_RENDERINGGROUPS: number;
  18130. /**
  18131. * Used to globally prevent autoclearing scenes.
  18132. */
  18133. static AUTOCLEAR: boolean;
  18134. /**
  18135. * @hidden
  18136. */
  18137. _useSceneAutoClearSetup: boolean;
  18138. private _scene;
  18139. private _renderingGroups;
  18140. private _depthStencilBufferAlreadyCleaned;
  18141. private _autoClearDepthStencil;
  18142. private _customOpaqueSortCompareFn;
  18143. private _customAlphaTestSortCompareFn;
  18144. private _customTransparentSortCompareFn;
  18145. private _renderingGroupInfo;
  18146. /**
  18147. * Instantiates a new rendering group for a particular scene
  18148. * @param scene Defines the scene the groups belongs to
  18149. */
  18150. constructor(scene: Scene);
  18151. private _clearDepthStencilBuffer;
  18152. /**
  18153. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18154. * @hidden
  18155. */
  18156. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18157. /**
  18158. * Resets the different information of the group to prepare a new frame
  18159. * @hidden
  18160. */
  18161. reset(): void;
  18162. /**
  18163. * Dispose and release the group and its associated resources.
  18164. * @hidden
  18165. */
  18166. dispose(): void;
  18167. /**
  18168. * Clear the info related to rendering groups preventing retention points during dispose.
  18169. */
  18170. freeRenderingGroups(): void;
  18171. private _prepareRenderingGroup;
  18172. /**
  18173. * Add a sprite manager to the rendering manager in order to render it this frame.
  18174. * @param spriteManager Define the sprite manager to render
  18175. */
  18176. dispatchSprites(spriteManager: ISpriteManager): void;
  18177. /**
  18178. * Add a particle system to the rendering manager in order to render it this frame.
  18179. * @param particleSystem Define the particle system to render
  18180. */
  18181. dispatchParticles(particleSystem: IParticleSystem): void;
  18182. /**
  18183. * Add a submesh to the manager in order to render it this frame
  18184. * @param subMesh The submesh to dispatch
  18185. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18186. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18187. */
  18188. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18189. /**
  18190. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18191. * This allowed control for front to back rendering or reversly depending of the special needs.
  18192. *
  18193. * @param renderingGroupId The rendering group id corresponding to its index
  18194. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18195. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18196. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18197. */
  18198. 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;
  18199. /**
  18200. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18201. *
  18202. * @param renderingGroupId The rendering group id corresponding to its index
  18203. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18204. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18205. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18206. */
  18207. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18208. /**
  18209. * Gets the current auto clear configuration for one rendering group of the rendering
  18210. * manager.
  18211. * @param index the rendering group index to get the information for
  18212. * @returns The auto clear setup for the requested rendering group
  18213. */
  18214. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18215. }
  18216. }
  18217. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18218. import { Observable } from "babylonjs/Misc/observable";
  18219. import { SmartArray } from "babylonjs/Misc/smartArray";
  18220. import { Nullable } from "babylonjs/types";
  18221. import { Camera } from "babylonjs/Cameras/camera";
  18222. import { Scene } from "babylonjs/scene";
  18223. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18224. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18226. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18227. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18228. import { Texture } from "babylonjs/Materials/Textures/texture";
  18229. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18230. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18231. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18232. import { Engine } from "babylonjs/Engines/engine";
  18233. /**
  18234. * This Helps creating a texture that will be created from a camera in your scene.
  18235. * It is basically a dynamic texture that could be used to create special effects for instance.
  18236. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18237. */
  18238. export class RenderTargetTexture extends Texture {
  18239. isCube: boolean;
  18240. /**
  18241. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18242. */
  18243. static readonly REFRESHRATE_RENDER_ONCE: number;
  18244. /**
  18245. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18246. */
  18247. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18248. /**
  18249. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18250. * the central point of your effect and can save a lot of performances.
  18251. */
  18252. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18253. /**
  18254. * Use this predicate to dynamically define the list of mesh you want to render.
  18255. * If set, the renderList property will be overwritten.
  18256. */
  18257. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18258. private _renderList;
  18259. /**
  18260. * Use this list to define the list of mesh you want to render.
  18261. */
  18262. renderList: Nullable<Array<AbstractMesh>>;
  18263. private _hookArray;
  18264. /**
  18265. * Define if particles should be rendered in your texture.
  18266. */
  18267. renderParticles: boolean;
  18268. /**
  18269. * Define if sprites should be rendered in your texture.
  18270. */
  18271. renderSprites: boolean;
  18272. /**
  18273. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18274. */
  18275. coordinatesMode: number;
  18276. /**
  18277. * Define the camera used to render the texture.
  18278. */
  18279. activeCamera: Nullable<Camera>;
  18280. /**
  18281. * Override the render function of the texture with your own one.
  18282. */
  18283. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18284. /**
  18285. * Define if camera post processes should be use while rendering the texture.
  18286. */
  18287. useCameraPostProcesses: boolean;
  18288. /**
  18289. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18290. */
  18291. ignoreCameraViewport: boolean;
  18292. private _postProcessManager;
  18293. private _postProcesses;
  18294. private _resizeObserver;
  18295. /**
  18296. * An event triggered when the texture is unbind.
  18297. */
  18298. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18299. /**
  18300. * An event triggered when the texture is unbind.
  18301. */
  18302. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18303. private _onAfterUnbindObserver;
  18304. /**
  18305. * Set a after unbind callback in the texture.
  18306. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18307. */
  18308. onAfterUnbind: () => void;
  18309. /**
  18310. * An event triggered before rendering the texture
  18311. */
  18312. onBeforeRenderObservable: Observable<number>;
  18313. private _onBeforeRenderObserver;
  18314. /**
  18315. * Set a before render callback in the texture.
  18316. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18317. */
  18318. onBeforeRender: (faceIndex: number) => void;
  18319. /**
  18320. * An event triggered after rendering the texture
  18321. */
  18322. onAfterRenderObservable: Observable<number>;
  18323. private _onAfterRenderObserver;
  18324. /**
  18325. * Set a after render callback in the texture.
  18326. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18327. */
  18328. onAfterRender: (faceIndex: number) => void;
  18329. /**
  18330. * An event triggered after the texture clear
  18331. */
  18332. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18333. private _onClearObserver;
  18334. /**
  18335. * Set a clear callback in the texture.
  18336. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18337. */
  18338. onClear: (Engine: Engine) => void;
  18339. /**
  18340. * Define the clear color of the Render Target if it should be different from the scene.
  18341. */
  18342. clearColor: Color4;
  18343. protected _size: number | {
  18344. width: number;
  18345. height: number;
  18346. };
  18347. protected _initialSizeParameter: number | {
  18348. width: number;
  18349. height: number;
  18350. } | {
  18351. ratio: number;
  18352. };
  18353. protected _sizeRatio: Nullable<number>;
  18354. /** @hidden */
  18355. _generateMipMaps: boolean;
  18356. protected _renderingManager: RenderingManager;
  18357. /** @hidden */
  18358. _waitingRenderList: string[];
  18359. protected _doNotChangeAspectRatio: boolean;
  18360. protected _currentRefreshId: number;
  18361. protected _refreshRate: number;
  18362. protected _textureMatrix: Matrix;
  18363. protected _samples: number;
  18364. protected _renderTargetOptions: RenderTargetCreationOptions;
  18365. /**
  18366. * Gets render target creation options that were used.
  18367. */
  18368. readonly renderTargetOptions: RenderTargetCreationOptions;
  18369. protected _engine: Engine;
  18370. protected _onRatioRescale(): void;
  18371. /**
  18372. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18373. * It must define where the camera used to render the texture is set
  18374. */
  18375. boundingBoxPosition: Vector3;
  18376. private _boundingBoxSize;
  18377. /**
  18378. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18379. * When defined, the cubemap will switch to local mode
  18380. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18381. * @example https://www.babylonjs-playground.com/#RNASML
  18382. */
  18383. boundingBoxSize: Vector3;
  18384. /**
  18385. * In case the RTT has been created with a depth texture, get the associated
  18386. * depth texture.
  18387. * Otherwise, return null.
  18388. */
  18389. depthStencilTexture: Nullable<InternalTexture>;
  18390. /**
  18391. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18392. * or used a shadow, depth texture...
  18393. * @param name The friendly name of the texture
  18394. * @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)
  18395. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18396. * @param generateMipMaps True if mip maps need to be generated after render.
  18397. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18398. * @param type The type of the buffer in the RTT (int, half float, float...)
  18399. * @param isCube True if a cube texture needs to be created
  18400. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18401. * @param generateDepthBuffer True to generate a depth buffer
  18402. * @param generateStencilBuffer True to generate a stencil buffer
  18403. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18404. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18405. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18406. */
  18407. constructor(name: string, size: number | {
  18408. width: number;
  18409. height: number;
  18410. } | {
  18411. ratio: number;
  18412. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18413. /**
  18414. * Creates a depth stencil texture.
  18415. * This is only available in WebGL 2 or with the depth texture extension available.
  18416. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18417. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18418. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18419. */
  18420. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18421. private _processSizeParameter;
  18422. /**
  18423. * Define the number of samples to use in case of MSAA.
  18424. * It defaults to one meaning no MSAA has been enabled.
  18425. */
  18426. samples: number;
  18427. /**
  18428. * Resets the refresh counter of the texture and start bak from scratch.
  18429. * Could be useful to regenerate the texture if it is setup to render only once.
  18430. */
  18431. resetRefreshCounter(): void;
  18432. /**
  18433. * Define the refresh rate of the texture or the rendering frequency.
  18434. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18435. */
  18436. refreshRate: number;
  18437. /**
  18438. * Adds a post process to the render target rendering passes.
  18439. * @param postProcess define the post process to add
  18440. */
  18441. addPostProcess(postProcess: PostProcess): void;
  18442. /**
  18443. * Clear all the post processes attached to the render target
  18444. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18445. */
  18446. clearPostProcesses(dispose?: boolean): void;
  18447. /**
  18448. * Remove one of the post process from the list of attached post processes to the texture
  18449. * @param postProcess define the post process to remove from the list
  18450. */
  18451. removePostProcess(postProcess: PostProcess): void;
  18452. /** @hidden */
  18453. _shouldRender(): boolean;
  18454. /**
  18455. * Gets the actual render size of the texture.
  18456. * @returns the width of the render size
  18457. */
  18458. getRenderSize(): number;
  18459. /**
  18460. * Gets the actual render width of the texture.
  18461. * @returns the width of the render size
  18462. */
  18463. getRenderWidth(): number;
  18464. /**
  18465. * Gets the actual render height of the texture.
  18466. * @returns the height of the render size
  18467. */
  18468. getRenderHeight(): number;
  18469. /**
  18470. * Get if the texture can be rescaled or not.
  18471. */
  18472. readonly canRescale: boolean;
  18473. /**
  18474. * Resize the texture using a ratio.
  18475. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18476. */
  18477. scale(ratio: number): void;
  18478. /**
  18479. * Get the texture reflection matrix used to rotate/transform the reflection.
  18480. * @returns the reflection matrix
  18481. */
  18482. getReflectionTextureMatrix(): Matrix;
  18483. /**
  18484. * Resize the texture to a new desired size.
  18485. * Be carrefull as it will recreate all the data in the new texture.
  18486. * @param size Define the new size. It can be:
  18487. * - a number for squared texture,
  18488. * - an object containing { width: number, height: number }
  18489. * - or an object containing a ratio { ratio: number }
  18490. */
  18491. resize(size: number | {
  18492. width: number;
  18493. height: number;
  18494. } | {
  18495. ratio: number;
  18496. }): void;
  18497. /**
  18498. * Renders all the objects from the render list into the texture.
  18499. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18500. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18501. */
  18502. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18503. private _bestReflectionRenderTargetDimension;
  18504. /**
  18505. * @hidden
  18506. * @param faceIndex face index to bind to if this is a cubetexture
  18507. */
  18508. _bindFrameBuffer(faceIndex?: number): void;
  18509. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18510. private renderToTarget;
  18511. /**
  18512. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18513. * This allowed control for front to back rendering or reversly depending of the special needs.
  18514. *
  18515. * @param renderingGroupId The rendering group id corresponding to its index
  18516. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18517. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18518. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18519. */
  18520. 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;
  18521. /**
  18522. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18523. *
  18524. * @param renderingGroupId The rendering group id corresponding to its index
  18525. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18526. */
  18527. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18528. /**
  18529. * Clones the texture.
  18530. * @returns the cloned texture
  18531. */
  18532. clone(): RenderTargetTexture;
  18533. /**
  18534. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18535. * @returns The JSON representation of the texture
  18536. */
  18537. serialize(): any;
  18538. /**
  18539. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18540. */
  18541. disposeFramebufferObjects(): void;
  18542. /**
  18543. * Dispose the texture and release its associated resources.
  18544. */
  18545. dispose(): void;
  18546. /** @hidden */
  18547. _rebuild(): void;
  18548. /**
  18549. * Clear the info related to rendering groups preventing retention point in material dispose.
  18550. */
  18551. freeRenderingGroups(): void;
  18552. /**
  18553. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18554. * @returns the view count
  18555. */
  18556. getViewCount(): number;
  18557. }
  18558. }
  18559. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18560. import { Scene } from "babylonjs/scene";
  18561. import { Plane } from "babylonjs/Maths/math";
  18562. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18563. /**
  18564. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18565. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18566. * You can then easily use it as a reflectionTexture on a flat surface.
  18567. * In case the surface is not a plane, please consider relying on reflection probes.
  18568. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18569. */
  18570. export class MirrorTexture extends RenderTargetTexture {
  18571. private scene;
  18572. /**
  18573. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18574. * 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.
  18575. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18576. */
  18577. mirrorPlane: Plane;
  18578. /**
  18579. * Define the blur ratio used to blur the reflection if needed.
  18580. */
  18581. blurRatio: number;
  18582. /**
  18583. * Define the adaptive blur kernel used to blur the reflection if needed.
  18584. * This will autocompute the closest best match for the `blurKernel`
  18585. */
  18586. adaptiveBlurKernel: number;
  18587. /**
  18588. * Define the blur kernel used to blur the reflection if needed.
  18589. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18590. */
  18591. blurKernel: number;
  18592. /**
  18593. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18594. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18595. */
  18596. blurKernelX: number;
  18597. /**
  18598. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18599. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18600. */
  18601. blurKernelY: number;
  18602. private _autoComputeBlurKernel;
  18603. protected _onRatioRescale(): void;
  18604. private _updateGammaSpace;
  18605. private _imageProcessingConfigChangeObserver;
  18606. private _transformMatrix;
  18607. private _mirrorMatrix;
  18608. private _savedViewMatrix;
  18609. private _blurX;
  18610. private _blurY;
  18611. private _adaptiveBlurKernel;
  18612. private _blurKernelX;
  18613. private _blurKernelY;
  18614. private _blurRatio;
  18615. /**
  18616. * Instantiates a Mirror Texture.
  18617. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18618. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18619. * You can then easily use it as a reflectionTexture on a flat surface.
  18620. * In case the surface is not a plane, please consider relying on reflection probes.
  18621. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18622. * @param name
  18623. * @param size
  18624. * @param scene
  18625. * @param generateMipMaps
  18626. * @param type
  18627. * @param samplingMode
  18628. * @param generateDepthBuffer
  18629. */
  18630. constructor(name: string, size: number | {
  18631. width: number;
  18632. height: number;
  18633. } | {
  18634. ratio: number;
  18635. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18636. private _preparePostProcesses;
  18637. /**
  18638. * Clone the mirror texture.
  18639. * @returns the cloned texture
  18640. */
  18641. clone(): MirrorTexture;
  18642. /**
  18643. * Serialize the texture to a JSON representation you could use in Parse later on
  18644. * @returns the serialized JSON representation
  18645. */
  18646. serialize(): any;
  18647. /**
  18648. * Dispose the texture and release its associated resources.
  18649. */
  18650. dispose(): void;
  18651. }
  18652. }
  18653. declare module "babylonjs/Materials/Textures/texture" {
  18654. import { Observable } from "babylonjs/Misc/observable";
  18655. import { Nullable } from "babylonjs/types";
  18656. import { Scene } from "babylonjs/scene";
  18657. import { Matrix } from "babylonjs/Maths/math";
  18658. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18659. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18660. /**
  18661. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18662. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18663. */
  18664. export class Texture extends BaseTexture {
  18665. /** @hidden */
  18666. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18667. /** @hidden */
  18668. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18669. /** @hidden */
  18670. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18671. /** nearest is mag = nearest and min = nearest and mip = linear */
  18672. static readonly NEAREST_SAMPLINGMODE: number;
  18673. /** nearest is mag = nearest and min = nearest and mip = linear */
  18674. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18675. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18676. static readonly BILINEAR_SAMPLINGMODE: number;
  18677. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18678. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18679. /** Trilinear is mag = linear and min = linear and mip = linear */
  18680. static readonly TRILINEAR_SAMPLINGMODE: number;
  18681. /** Trilinear is mag = linear and min = linear and mip = linear */
  18682. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18683. /** mag = nearest and min = nearest and mip = nearest */
  18684. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18685. /** mag = nearest and min = linear and mip = nearest */
  18686. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18687. /** mag = nearest and min = linear and mip = linear */
  18688. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18689. /** mag = nearest and min = linear and mip = none */
  18690. static readonly NEAREST_LINEAR: number;
  18691. /** mag = nearest and min = nearest and mip = none */
  18692. static readonly NEAREST_NEAREST: number;
  18693. /** mag = linear and min = nearest and mip = nearest */
  18694. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18695. /** mag = linear and min = nearest and mip = linear */
  18696. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18697. /** mag = linear and min = linear and mip = none */
  18698. static readonly LINEAR_LINEAR: number;
  18699. /** mag = linear and min = nearest and mip = none */
  18700. static readonly LINEAR_NEAREST: number;
  18701. /** Explicit coordinates mode */
  18702. static readonly EXPLICIT_MODE: number;
  18703. /** Spherical coordinates mode */
  18704. static readonly SPHERICAL_MODE: number;
  18705. /** Planar coordinates mode */
  18706. static readonly PLANAR_MODE: number;
  18707. /** Cubic coordinates mode */
  18708. static readonly CUBIC_MODE: number;
  18709. /** Projection coordinates mode */
  18710. static readonly PROJECTION_MODE: number;
  18711. /** Inverse Cubic coordinates mode */
  18712. static readonly SKYBOX_MODE: number;
  18713. /** Inverse Cubic coordinates mode */
  18714. static readonly INVCUBIC_MODE: number;
  18715. /** Equirectangular coordinates mode */
  18716. static readonly EQUIRECTANGULAR_MODE: number;
  18717. /** Equirectangular Fixed coordinates mode */
  18718. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18719. /** Equirectangular Fixed Mirrored coordinates mode */
  18720. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18721. /** Texture is not repeating outside of 0..1 UVs */
  18722. static readonly CLAMP_ADDRESSMODE: number;
  18723. /** Texture is repeating outside of 0..1 UVs */
  18724. static readonly WRAP_ADDRESSMODE: number;
  18725. /** Texture is repeating and mirrored */
  18726. static readonly MIRROR_ADDRESSMODE: number;
  18727. /**
  18728. * 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
  18729. */
  18730. static UseSerializedUrlIfAny: boolean;
  18731. /**
  18732. * Define the url of the texture.
  18733. */
  18734. url: Nullable<string>;
  18735. /**
  18736. * Define an offset on the texture to offset the u coordinates of the UVs
  18737. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18738. */
  18739. uOffset: number;
  18740. /**
  18741. * Define an offset on the texture to offset the v coordinates of the UVs
  18742. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18743. */
  18744. vOffset: number;
  18745. /**
  18746. * Define an offset on the texture to scale the u coordinates of the UVs
  18747. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18748. */
  18749. uScale: number;
  18750. /**
  18751. * Define an offset on the texture to scale the v coordinates of the UVs
  18752. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18753. */
  18754. vScale: number;
  18755. /**
  18756. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18757. * @see http://doc.babylonjs.com/how_to/more_materials
  18758. */
  18759. uAng: number;
  18760. /**
  18761. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18762. * @see http://doc.babylonjs.com/how_to/more_materials
  18763. */
  18764. vAng: number;
  18765. /**
  18766. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18767. * @see http://doc.babylonjs.com/how_to/more_materials
  18768. */
  18769. wAng: number;
  18770. /**
  18771. * Defines the center of rotation (U)
  18772. */
  18773. uRotationCenter: number;
  18774. /**
  18775. * Defines the center of rotation (V)
  18776. */
  18777. vRotationCenter: number;
  18778. /**
  18779. * Defines the center of rotation (W)
  18780. */
  18781. wRotationCenter: number;
  18782. /**
  18783. * Are mip maps generated for this texture or not.
  18784. */
  18785. readonly noMipmap: boolean;
  18786. /**
  18787. * List of inspectable custom properties (used by the Inspector)
  18788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18789. */
  18790. inspectableCustomProperties: Nullable<IInspectable[]>;
  18791. private _noMipmap;
  18792. /** @hidden */
  18793. _invertY: boolean;
  18794. private _rowGenerationMatrix;
  18795. private _cachedTextureMatrix;
  18796. private _projectionModeMatrix;
  18797. private _t0;
  18798. private _t1;
  18799. private _t2;
  18800. private _cachedUOffset;
  18801. private _cachedVOffset;
  18802. private _cachedUScale;
  18803. private _cachedVScale;
  18804. private _cachedUAng;
  18805. private _cachedVAng;
  18806. private _cachedWAng;
  18807. private _cachedProjectionMatrixId;
  18808. private _cachedCoordinatesMode;
  18809. /** @hidden */
  18810. protected _initialSamplingMode: number;
  18811. /** @hidden */
  18812. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18813. private _deleteBuffer;
  18814. protected _format: Nullable<number>;
  18815. private _delayedOnLoad;
  18816. private _delayedOnError;
  18817. /**
  18818. * Observable triggered once the texture has been loaded.
  18819. */
  18820. onLoadObservable: Observable<Texture>;
  18821. protected _isBlocking: boolean;
  18822. /**
  18823. * Is the texture preventing material to render while loading.
  18824. * If false, a default texture will be used instead of the loading one during the preparation step.
  18825. */
  18826. isBlocking: boolean;
  18827. /**
  18828. * Get the current sampling mode associated with the texture.
  18829. */
  18830. readonly samplingMode: number;
  18831. /**
  18832. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18833. */
  18834. readonly invertY: boolean;
  18835. /**
  18836. * Instantiates a new texture.
  18837. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18838. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18839. * @param url define the url of the picture to load as a texture
  18840. * @param scene define the scene the texture will belong to
  18841. * @param noMipmap define if the texture will require mip maps or not
  18842. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18843. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18844. * @param onLoad define a callback triggered when the texture has been loaded
  18845. * @param onError define a callback triggered when an error occurred during the loading session
  18846. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18847. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18848. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18849. */
  18850. 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);
  18851. /**
  18852. * Update the url (and optional buffer) of this texture if url was null during construction.
  18853. * @param url the url of the texture
  18854. * @param buffer the buffer of the texture (defaults to null)
  18855. * @param onLoad callback called when the texture is loaded (defaults to null)
  18856. */
  18857. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18858. /**
  18859. * Finish the loading sequence of a texture flagged as delayed load.
  18860. * @hidden
  18861. */
  18862. delayLoad(): void;
  18863. private _prepareRowForTextureGeneration;
  18864. /**
  18865. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18866. * @returns the transform matrix of the texture.
  18867. */
  18868. getTextureMatrix(): Matrix;
  18869. /**
  18870. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18871. * @returns The reflection texture transform
  18872. */
  18873. getReflectionTextureMatrix(): Matrix;
  18874. /**
  18875. * Clones the texture.
  18876. * @returns the cloned texture
  18877. */
  18878. clone(): Texture;
  18879. /**
  18880. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18881. * @returns The JSON representation of the texture
  18882. */
  18883. serialize(): any;
  18884. /**
  18885. * Get the current class name of the texture useful for serialization or dynamic coding.
  18886. * @returns "Texture"
  18887. */
  18888. getClassName(): string;
  18889. /**
  18890. * Dispose the texture and release its associated resources.
  18891. */
  18892. dispose(): void;
  18893. /**
  18894. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18895. * @param parsedTexture Define the JSON representation of the texture
  18896. * @param scene Define the scene the parsed texture should be instantiated in
  18897. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18898. * @returns The parsed texture if successful
  18899. */
  18900. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18901. /**
  18902. * Creates a texture from its base 64 representation.
  18903. * @param data Define the base64 payload without the data: prefix
  18904. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18905. * @param scene Define the scene the texture should belong to
  18906. * @param noMipmap Forces the texture to not create mip map information if true
  18907. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18908. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18909. * @param onLoad define a callback triggered when the texture has been loaded
  18910. * @param onError define a callback triggered when an error occurred during the loading session
  18911. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18912. * @returns the created texture
  18913. */
  18914. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18915. /**
  18916. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18917. * @param data Define the base64 payload without the data: prefix
  18918. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18919. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18920. * @param scene Define the scene the texture should belong to
  18921. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18922. * @param noMipmap Forces the texture to not create mip map information if true
  18923. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18924. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18925. * @param onLoad define a callback triggered when the texture has been loaded
  18926. * @param onError define a callback triggered when an error occurred during the loading session
  18927. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18928. * @returns the created texture
  18929. */
  18930. 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;
  18931. }
  18932. }
  18933. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18934. import { Nullable } from "babylonjs/types";
  18935. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18936. import { Scene } from "babylonjs/scene";
  18937. module "babylonjs/Engines/engine" {
  18938. interface Engine {
  18939. /**
  18940. * Creates a raw texture
  18941. * @param data defines the data to store in the texture
  18942. * @param width defines the width of the texture
  18943. * @param height defines the height of the texture
  18944. * @param format defines the format of the data
  18945. * @param generateMipMaps defines if the engine should generate the mip levels
  18946. * @param invertY defines if data must be stored with Y axis inverted
  18947. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18948. * @param compression defines the compression used (null by default)
  18949. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18950. * @returns the raw texture inside an InternalTexture
  18951. */
  18952. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18953. /**
  18954. * Update a raw texture
  18955. * @param texture defines the texture to update
  18956. * @param data defines the data to store in the texture
  18957. * @param format defines the format of the data
  18958. * @param invertY defines if data must be stored with Y axis inverted
  18959. */
  18960. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18961. /**
  18962. * Update a raw texture
  18963. * @param texture defines the texture to update
  18964. * @param data defines the data to store in the texture
  18965. * @param format defines the format of the data
  18966. * @param invertY defines if data must be stored with Y axis inverted
  18967. * @param compression defines the compression used (null by default)
  18968. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18969. */
  18970. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18971. /**
  18972. * Creates a new raw cube texture
  18973. * @param data defines the array of data to use to create each face
  18974. * @param size defines the size of the textures
  18975. * @param format defines the format of the data
  18976. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18977. * @param generateMipMaps defines if the engine should generate the mip levels
  18978. * @param invertY defines if data must be stored with Y axis inverted
  18979. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18980. * @param compression defines the compression used (null by default)
  18981. * @returns the cube texture as an InternalTexture
  18982. */
  18983. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18984. /**
  18985. * Update a raw cube texture
  18986. * @param texture defines the texture to udpdate
  18987. * @param data defines the data to store
  18988. * @param format defines the data format
  18989. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18990. * @param invertY defines if data must be stored with Y axis inverted
  18991. */
  18992. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18993. /**
  18994. * Update a raw cube texture
  18995. * @param texture defines the texture to udpdate
  18996. * @param data defines the data to store
  18997. * @param format defines the data format
  18998. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18999. * @param invertY defines if data must be stored with Y axis inverted
  19000. * @param compression defines the compression used (null by default)
  19001. */
  19002. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  19003. /**
  19004. * Update a raw cube texture
  19005. * @param texture defines the texture to udpdate
  19006. * @param data defines the data to store
  19007. * @param format defines the data format
  19008. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19009. * @param invertY defines if data must be stored with Y axis inverted
  19010. * @param compression defines the compression used (null by default)
  19011. * @param level defines which level of the texture to update
  19012. */
  19013. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19014. /**
  19015. * Creates a new raw cube texture from a specified url
  19016. * @param url defines the url where the data is located
  19017. * @param scene defines the current scene
  19018. * @param size defines the size of the textures
  19019. * @param format defines the format of the data
  19020. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19021. * @param noMipmap defines if the engine should avoid generating the mip levels
  19022. * @param callback defines a callback used to extract texture data from loaded data
  19023. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19024. * @param onLoad defines a callback called when texture is loaded
  19025. * @param onError defines a callback called if there is an error
  19026. * @returns the cube texture as an InternalTexture
  19027. */
  19028. 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;
  19029. /**
  19030. * Creates a new raw cube texture from a specified url
  19031. * @param url defines the url where the data is located
  19032. * @param scene defines the current scene
  19033. * @param size defines the size of the textures
  19034. * @param format defines the format of the data
  19035. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19036. * @param noMipmap defines if the engine should avoid generating the mip levels
  19037. * @param callback defines a callback used to extract texture data from loaded data
  19038. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19039. * @param onLoad defines a callback called when texture is loaded
  19040. * @param onError defines a callback called if there is an error
  19041. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19042. * @param invertY defines if data must be stored with Y axis inverted
  19043. * @returns the cube texture as an InternalTexture
  19044. */
  19045. 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;
  19046. /**
  19047. * Creates a new raw 3D texture
  19048. * @param data defines the data used to create the texture
  19049. * @param width defines the width of the texture
  19050. * @param height defines the height of the texture
  19051. * @param depth defines the depth of the texture
  19052. * @param format defines the format of the texture
  19053. * @param generateMipMaps defines if the engine must generate mip levels
  19054. * @param invertY defines if data must be stored with Y axis inverted
  19055. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19056. * @param compression defines the compressed used (can be null)
  19057. * @param textureType defines the compressed used (can be null)
  19058. * @returns a new raw 3D texture (stored in an InternalTexture)
  19059. */
  19060. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19061. /**
  19062. * Update a raw 3D texture
  19063. * @param texture defines the texture to update
  19064. * @param data defines the data to store
  19065. * @param format defines the data format
  19066. * @param invertY defines if data must be stored with Y axis inverted
  19067. */
  19068. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19069. /**
  19070. * Update a raw 3D texture
  19071. * @param texture defines the texture to update
  19072. * @param data defines the data to store
  19073. * @param format defines the data format
  19074. * @param invertY defines if data must be stored with Y axis inverted
  19075. * @param compression defines the used compression (can be null)
  19076. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19077. */
  19078. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19079. }
  19080. }
  19081. }
  19082. declare module "babylonjs/Materials/Textures/rawTexture" {
  19083. import { Scene } from "babylonjs/scene";
  19084. import { Texture } from "babylonjs/Materials/Textures/texture";
  19085. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19086. /**
  19087. * Raw texture can help creating a texture directly from an array of data.
  19088. * This can be super useful if you either get the data from an uncompressed source or
  19089. * if you wish to create your texture pixel by pixel.
  19090. */
  19091. export class RawTexture extends Texture {
  19092. /**
  19093. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19094. */
  19095. format: number;
  19096. private _engine;
  19097. /**
  19098. * Instantiates a new RawTexture.
  19099. * Raw texture can help creating a texture directly from an array of data.
  19100. * This can be super useful if you either get the data from an uncompressed source or
  19101. * if you wish to create your texture pixel by pixel.
  19102. * @param data define the array of data to use to create the texture
  19103. * @param width define the width of the texture
  19104. * @param height define the height of the texture
  19105. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19106. * @param scene define the scene the texture belongs to
  19107. * @param generateMipMaps define whether mip maps should be generated or not
  19108. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19109. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19110. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19111. */
  19112. constructor(data: ArrayBufferView, width: number, height: number,
  19113. /**
  19114. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19115. */
  19116. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19117. /**
  19118. * Updates the texture underlying data.
  19119. * @param data Define the new data of the texture
  19120. */
  19121. update(data: ArrayBufferView): void;
  19122. /**
  19123. * Creates a luminance texture from some data.
  19124. * @param data Define the texture data
  19125. * @param width Define the width of the texture
  19126. * @param height Define the height of the texture
  19127. * @param scene Define the scene the texture belongs to
  19128. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19129. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19130. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19131. * @returns the luminance texture
  19132. */
  19133. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19134. /**
  19135. * Creates a luminance alpha texture from some data.
  19136. * @param data Define the texture data
  19137. * @param width Define the width of the texture
  19138. * @param height Define the height of the texture
  19139. * @param scene Define the scene the texture belongs to
  19140. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19141. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19142. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19143. * @returns the luminance alpha texture
  19144. */
  19145. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19146. /**
  19147. * Creates an alpha texture from some data.
  19148. * @param data Define the texture data
  19149. * @param width Define the width of the texture
  19150. * @param height Define the height of the texture
  19151. * @param scene Define the scene the texture belongs to
  19152. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19153. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19154. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19155. * @returns the alpha texture
  19156. */
  19157. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19158. /**
  19159. * Creates a RGB texture from some data.
  19160. * @param data Define the texture data
  19161. * @param width Define the width of the texture
  19162. * @param height Define the height of the texture
  19163. * @param scene Define the scene the texture belongs to
  19164. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19165. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19166. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19167. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19168. * @returns the RGB alpha texture
  19169. */
  19170. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19171. /**
  19172. * Creates a RGBA texture from some data.
  19173. * @param data Define the texture data
  19174. * @param width Define the width of the texture
  19175. * @param height Define the height of the texture
  19176. * @param scene Define the scene the texture belongs to
  19177. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19178. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19179. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19180. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19181. * @returns the RGBA texture
  19182. */
  19183. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19184. /**
  19185. * Creates a R texture from some data.
  19186. * @param data Define the texture data
  19187. * @param width Define the width of the texture
  19188. * @param height Define the height of the texture
  19189. * @param scene Define the scene the texture belongs to
  19190. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19191. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19192. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19193. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19194. * @returns the R texture
  19195. */
  19196. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19197. }
  19198. }
  19199. declare module "babylonjs/Animations/runtimeAnimation" {
  19200. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19201. import { Animatable } from "babylonjs/Animations/animatable";
  19202. import { Scene } from "babylonjs/scene";
  19203. /**
  19204. * Defines a runtime animation
  19205. */
  19206. export class RuntimeAnimation {
  19207. private _events;
  19208. /**
  19209. * The current frame of the runtime animation
  19210. */
  19211. private _currentFrame;
  19212. /**
  19213. * The animation used by the runtime animation
  19214. */
  19215. private _animation;
  19216. /**
  19217. * The target of the runtime animation
  19218. */
  19219. private _target;
  19220. /**
  19221. * The initiating animatable
  19222. */
  19223. private _host;
  19224. /**
  19225. * The original value of the runtime animation
  19226. */
  19227. private _originalValue;
  19228. /**
  19229. * The original blend value of the runtime animation
  19230. */
  19231. private _originalBlendValue;
  19232. /**
  19233. * The offsets cache of the runtime animation
  19234. */
  19235. private _offsetsCache;
  19236. /**
  19237. * The high limits cache of the runtime animation
  19238. */
  19239. private _highLimitsCache;
  19240. /**
  19241. * Specifies if the runtime animation has been stopped
  19242. */
  19243. private _stopped;
  19244. /**
  19245. * The blending factor of the runtime animation
  19246. */
  19247. private _blendingFactor;
  19248. /**
  19249. * The BabylonJS scene
  19250. */
  19251. private _scene;
  19252. /**
  19253. * The current value of the runtime animation
  19254. */
  19255. private _currentValue;
  19256. /** @hidden */
  19257. _animationState: _IAnimationState;
  19258. /**
  19259. * The active target of the runtime animation
  19260. */
  19261. private _activeTargets;
  19262. private _currentActiveTarget;
  19263. private _directTarget;
  19264. /**
  19265. * The target path of the runtime animation
  19266. */
  19267. private _targetPath;
  19268. /**
  19269. * The weight of the runtime animation
  19270. */
  19271. private _weight;
  19272. /**
  19273. * The ratio offset of the runtime animation
  19274. */
  19275. private _ratioOffset;
  19276. /**
  19277. * The previous delay of the runtime animation
  19278. */
  19279. private _previousDelay;
  19280. /**
  19281. * The previous ratio of the runtime animation
  19282. */
  19283. private _previousRatio;
  19284. private _enableBlending;
  19285. private _keys;
  19286. private _minFrame;
  19287. private _maxFrame;
  19288. private _minValue;
  19289. private _maxValue;
  19290. private _targetIsArray;
  19291. /**
  19292. * Gets the current frame of the runtime animation
  19293. */
  19294. readonly currentFrame: number;
  19295. /**
  19296. * Gets the weight of the runtime animation
  19297. */
  19298. readonly weight: number;
  19299. /**
  19300. * Gets the current value of the runtime animation
  19301. */
  19302. readonly currentValue: any;
  19303. /**
  19304. * Gets the target path of the runtime animation
  19305. */
  19306. readonly targetPath: string;
  19307. /**
  19308. * Gets the actual target of the runtime animation
  19309. */
  19310. readonly target: any;
  19311. /** @hidden */
  19312. _onLoop: () => void;
  19313. /**
  19314. * Create a new RuntimeAnimation object
  19315. * @param target defines the target of the animation
  19316. * @param animation defines the source animation object
  19317. * @param scene defines the hosting scene
  19318. * @param host defines the initiating Animatable
  19319. */
  19320. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19321. private _preparePath;
  19322. /**
  19323. * Gets the animation from the runtime animation
  19324. */
  19325. readonly animation: Animation;
  19326. /**
  19327. * Resets the runtime animation to the beginning
  19328. * @param restoreOriginal defines whether to restore the target property to the original value
  19329. */
  19330. reset(restoreOriginal?: boolean): void;
  19331. /**
  19332. * Specifies if the runtime animation is stopped
  19333. * @returns Boolean specifying if the runtime animation is stopped
  19334. */
  19335. isStopped(): boolean;
  19336. /**
  19337. * Disposes of the runtime animation
  19338. */
  19339. dispose(): void;
  19340. /**
  19341. * Apply the interpolated value to the target
  19342. * @param currentValue defines the value computed by the animation
  19343. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19344. */
  19345. setValue(currentValue: any, weight: number): void;
  19346. private _getOriginalValues;
  19347. private _setValue;
  19348. /**
  19349. * Gets the loop pmode of the runtime animation
  19350. * @returns Loop Mode
  19351. */
  19352. private _getCorrectLoopMode;
  19353. /**
  19354. * Move the current animation to a given frame
  19355. * @param frame defines the frame to move to
  19356. */
  19357. goToFrame(frame: number): void;
  19358. /**
  19359. * @hidden Internal use only
  19360. */
  19361. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19362. /**
  19363. * Execute the current animation
  19364. * @param delay defines the delay to add to the current frame
  19365. * @param from defines the lower bound of the animation range
  19366. * @param to defines the upper bound of the animation range
  19367. * @param loop defines if the current animation must loop
  19368. * @param speedRatio defines the current speed ratio
  19369. * @param weight defines the weight of the animation (default is -1 so no weight)
  19370. * @param onLoop optional callback called when animation loops
  19371. * @returns a boolean indicating if the animation is running
  19372. */
  19373. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19374. }
  19375. }
  19376. declare module "babylonjs/Animations/animatable" {
  19377. import { Animation } from "babylonjs/Animations/animation";
  19378. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19379. import { Nullable } from "babylonjs/types";
  19380. import { Observable } from "babylonjs/Misc/observable";
  19381. import { Scene } from "babylonjs/scene";
  19382. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19383. import { Node } from "babylonjs/node";
  19384. /**
  19385. * Class used to store an actual running animation
  19386. */
  19387. export class Animatable {
  19388. /** defines the target object */
  19389. target: any;
  19390. /** defines the starting frame number (default is 0) */
  19391. fromFrame: number;
  19392. /** defines the ending frame number (default is 100) */
  19393. toFrame: number;
  19394. /** defines if the animation must loop (default is false) */
  19395. loopAnimation: boolean;
  19396. /** defines a callback to call when animation ends if it is not looping */
  19397. onAnimationEnd?: (() => void) | null | undefined;
  19398. /** defines a callback to call when animation loops */
  19399. onAnimationLoop?: (() => void) | null | undefined;
  19400. private _localDelayOffset;
  19401. private _pausedDelay;
  19402. private _runtimeAnimations;
  19403. private _paused;
  19404. private _scene;
  19405. private _speedRatio;
  19406. private _weight;
  19407. private _syncRoot;
  19408. /**
  19409. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19410. * This will only apply for non looping animation (default is true)
  19411. */
  19412. disposeOnEnd: boolean;
  19413. /**
  19414. * Gets a boolean indicating if the animation has started
  19415. */
  19416. animationStarted: boolean;
  19417. /**
  19418. * Observer raised when the animation ends
  19419. */
  19420. onAnimationEndObservable: Observable<Animatable>;
  19421. /**
  19422. * Observer raised when the animation loops
  19423. */
  19424. onAnimationLoopObservable: Observable<Animatable>;
  19425. /**
  19426. * Gets the root Animatable used to synchronize and normalize animations
  19427. */
  19428. readonly syncRoot: Nullable<Animatable>;
  19429. /**
  19430. * Gets the current frame of the first RuntimeAnimation
  19431. * Used to synchronize Animatables
  19432. */
  19433. readonly masterFrame: number;
  19434. /**
  19435. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19436. */
  19437. weight: number;
  19438. /**
  19439. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19440. */
  19441. speedRatio: number;
  19442. /**
  19443. * Creates a new Animatable
  19444. * @param scene defines the hosting scene
  19445. * @param target defines the target object
  19446. * @param fromFrame defines the starting frame number (default is 0)
  19447. * @param toFrame defines the ending frame number (default is 100)
  19448. * @param loopAnimation defines if the animation must loop (default is false)
  19449. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19450. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19451. * @param animations defines a group of animation to add to the new Animatable
  19452. * @param onAnimationLoop defines a callback to call when animation loops
  19453. */
  19454. constructor(scene: Scene,
  19455. /** defines the target object */
  19456. target: any,
  19457. /** defines the starting frame number (default is 0) */
  19458. fromFrame?: number,
  19459. /** defines the ending frame number (default is 100) */
  19460. toFrame?: number,
  19461. /** defines if the animation must loop (default is false) */
  19462. loopAnimation?: boolean, speedRatio?: number,
  19463. /** defines a callback to call when animation ends if it is not looping */
  19464. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19465. /** defines a callback to call when animation loops */
  19466. onAnimationLoop?: (() => void) | null | undefined);
  19467. /**
  19468. * Synchronize and normalize current Animatable with a source Animatable
  19469. * This is useful when using animation weights and when animations are not of the same length
  19470. * @param root defines the root Animatable to synchronize with
  19471. * @returns the current Animatable
  19472. */
  19473. syncWith(root: Animatable): Animatable;
  19474. /**
  19475. * Gets the list of runtime animations
  19476. * @returns an array of RuntimeAnimation
  19477. */
  19478. getAnimations(): RuntimeAnimation[];
  19479. /**
  19480. * Adds more animations to the current animatable
  19481. * @param target defines the target of the animations
  19482. * @param animations defines the new animations to add
  19483. */
  19484. appendAnimations(target: any, animations: Animation[]): void;
  19485. /**
  19486. * Gets the source animation for a specific property
  19487. * @param property defines the propertyu to look for
  19488. * @returns null or the source animation for the given property
  19489. */
  19490. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19491. /**
  19492. * Gets the runtime animation for a specific property
  19493. * @param property defines the propertyu to look for
  19494. * @returns null or the runtime animation for the given property
  19495. */
  19496. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19497. /**
  19498. * Resets the animatable to its original state
  19499. */
  19500. reset(): void;
  19501. /**
  19502. * Allows the animatable to blend with current running animations
  19503. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19504. * @param blendingSpeed defines the blending speed to use
  19505. */
  19506. enableBlending(blendingSpeed: number): void;
  19507. /**
  19508. * Disable animation blending
  19509. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19510. */
  19511. disableBlending(): void;
  19512. /**
  19513. * Jump directly to a given frame
  19514. * @param frame defines the frame to jump to
  19515. */
  19516. goToFrame(frame: number): void;
  19517. /**
  19518. * Pause the animation
  19519. */
  19520. pause(): void;
  19521. /**
  19522. * Restart the animation
  19523. */
  19524. restart(): void;
  19525. private _raiseOnAnimationEnd;
  19526. /**
  19527. * Stop and delete the current animation
  19528. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19529. * @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)
  19530. */
  19531. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19532. /**
  19533. * Wait asynchronously for the animation to end
  19534. * @returns a promise which will be fullfilled when the animation ends
  19535. */
  19536. waitAsync(): Promise<Animatable>;
  19537. /** @hidden */
  19538. _animate(delay: number): boolean;
  19539. }
  19540. module "babylonjs/scene" {
  19541. interface Scene {
  19542. /** @hidden */
  19543. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19544. /** @hidden */
  19545. _processLateAnimationBindingsForMatrices(holder: {
  19546. totalWeight: number;
  19547. animations: RuntimeAnimation[];
  19548. originalValue: Matrix;
  19549. }): any;
  19550. /** @hidden */
  19551. _processLateAnimationBindingsForQuaternions(holder: {
  19552. totalWeight: number;
  19553. animations: RuntimeAnimation[];
  19554. originalValue: Quaternion;
  19555. }, refQuaternion: Quaternion): Quaternion;
  19556. /** @hidden */
  19557. _processLateAnimationBindings(): void;
  19558. /**
  19559. * Will start the animation sequence of a given target
  19560. * @param target defines the target
  19561. * @param from defines from which frame should animation start
  19562. * @param to defines until which frame should animation run.
  19563. * @param weight defines the weight to apply to the animation (1.0 by default)
  19564. * @param loop defines if the animation loops
  19565. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19566. * @param onAnimationEnd defines the function to be executed when the animation ends
  19567. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19568. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19569. * @param onAnimationLoop defines the callback to call when an animation loops
  19570. * @returns the animatable object created for this animation
  19571. */
  19572. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19573. /**
  19574. * Will start the animation sequence of a given target
  19575. * @param target defines the target
  19576. * @param from defines from which frame should animation start
  19577. * @param to defines until which frame should animation run.
  19578. * @param loop defines if the animation loops
  19579. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19580. * @param onAnimationEnd defines the function to be executed when the animation ends
  19581. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19582. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19583. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19584. * @param onAnimationLoop defines the callback to call when an animation loops
  19585. * @returns the animatable object created for this animation
  19586. */
  19587. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19588. /**
  19589. * Will start the animation sequence of a given target and its hierarchy
  19590. * @param target defines the target
  19591. * @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.
  19592. * @param from defines from which frame should animation start
  19593. * @param to defines until which frame should animation run.
  19594. * @param loop defines if the animation loops
  19595. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19596. * @param onAnimationEnd defines the function to be executed when the animation ends
  19597. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19598. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19599. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19600. * @param onAnimationLoop defines the callback to call when an animation loops
  19601. * @returns the list of created animatables
  19602. */
  19603. 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[];
  19604. /**
  19605. * Begin a new animation on a given node
  19606. * @param target defines the target where the animation will take place
  19607. * @param animations defines the list of animations to start
  19608. * @param from defines the initial value
  19609. * @param to defines the final value
  19610. * @param loop defines if you want animation to loop (off by default)
  19611. * @param speedRatio defines the speed ratio to apply to all animations
  19612. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19613. * @param onAnimationLoop defines the callback to call when an animation loops
  19614. * @returns the list of created animatables
  19615. */
  19616. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19617. /**
  19618. * Begin a new animation on a given node and its hierarchy
  19619. * @param target defines the root node where the animation will take place
  19620. * @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.
  19621. * @param animations defines the list of animations to start
  19622. * @param from defines the initial value
  19623. * @param to defines the final value
  19624. * @param loop defines if you want animation to loop (off by default)
  19625. * @param speedRatio defines the speed ratio to apply to all animations
  19626. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19627. * @param onAnimationLoop defines the callback to call when an animation loops
  19628. * @returns the list of animatables created for all nodes
  19629. */
  19630. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19631. /**
  19632. * Gets the animatable associated with a specific target
  19633. * @param target defines the target of the animatable
  19634. * @returns the required animatable if found
  19635. */
  19636. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19637. /**
  19638. * Gets all animatables associated with a given target
  19639. * @param target defines the target to look animatables for
  19640. * @returns an array of Animatables
  19641. */
  19642. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19643. /**
  19644. * Stops and removes all animations that have been applied to the scene
  19645. */
  19646. stopAllAnimations(): void;
  19647. }
  19648. }
  19649. module "babylonjs/Bones/bone" {
  19650. interface Bone {
  19651. /**
  19652. * Copy an animation range from another bone
  19653. * @param source defines the source bone
  19654. * @param rangeName defines the range name to copy
  19655. * @param frameOffset defines the frame offset
  19656. * @param rescaleAsRequired defines if rescaling must be applied if required
  19657. * @param skelDimensionsRatio defines the scaling ratio
  19658. * @returns true if operation was successful
  19659. */
  19660. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19661. }
  19662. }
  19663. }
  19664. declare module "babylonjs/Bones/skeleton" {
  19665. import { Bone } from "babylonjs/Bones/bone";
  19666. import { IAnimatable } from "babylonjs/Misc/tools";
  19667. import { Observable } from "babylonjs/Misc/observable";
  19668. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19669. import { Scene } from "babylonjs/scene";
  19670. import { Nullable } from "babylonjs/types";
  19671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19672. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19673. import { Animatable } from "babylonjs/Animations/animatable";
  19674. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19675. import { Animation } from "babylonjs/Animations/animation";
  19676. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19677. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19678. /**
  19679. * Class used to handle skinning animations
  19680. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19681. */
  19682. export class Skeleton implements IAnimatable {
  19683. /** defines the skeleton name */
  19684. name: string;
  19685. /** defines the skeleton Id */
  19686. id: string;
  19687. /**
  19688. * Defines the list of child bones
  19689. */
  19690. bones: Bone[];
  19691. /**
  19692. * Defines an estimate of the dimension of the skeleton at rest
  19693. */
  19694. dimensionsAtRest: Vector3;
  19695. /**
  19696. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19697. */
  19698. needInitialSkinMatrix: boolean;
  19699. /**
  19700. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19701. */
  19702. overrideMesh: Nullable<AbstractMesh>;
  19703. /**
  19704. * Gets the list of animations attached to this skeleton
  19705. */
  19706. animations: Array<Animation>;
  19707. private _scene;
  19708. private _isDirty;
  19709. private _transformMatrices;
  19710. private _transformMatrixTexture;
  19711. private _meshesWithPoseMatrix;
  19712. private _animatables;
  19713. private _identity;
  19714. private _synchronizedWithMesh;
  19715. private _ranges;
  19716. private _lastAbsoluteTransformsUpdateId;
  19717. private _canUseTextureForBones;
  19718. private _uniqueId;
  19719. /** @hidden */
  19720. _numBonesWithLinkedTransformNode: number;
  19721. /**
  19722. * Specifies if the skeleton should be serialized
  19723. */
  19724. doNotSerialize: boolean;
  19725. private _useTextureToStoreBoneMatrices;
  19726. /**
  19727. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19728. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19729. */
  19730. useTextureToStoreBoneMatrices: boolean;
  19731. private _animationPropertiesOverride;
  19732. /**
  19733. * Gets or sets the animation properties override
  19734. */
  19735. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19736. /**
  19737. * List of inspectable custom properties (used by the Inspector)
  19738. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19739. */
  19740. inspectableCustomProperties: IInspectable[];
  19741. /**
  19742. * An observable triggered before computing the skeleton's matrices
  19743. */
  19744. onBeforeComputeObservable: Observable<Skeleton>;
  19745. /**
  19746. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19747. */
  19748. readonly isUsingTextureForMatrices: boolean;
  19749. /**
  19750. * Gets the unique ID of this skeleton
  19751. */
  19752. readonly uniqueId: number;
  19753. /**
  19754. * Creates a new skeleton
  19755. * @param name defines the skeleton name
  19756. * @param id defines the skeleton Id
  19757. * @param scene defines the hosting scene
  19758. */
  19759. constructor(
  19760. /** defines the skeleton name */
  19761. name: string,
  19762. /** defines the skeleton Id */
  19763. id: string, scene: Scene);
  19764. /**
  19765. * Gets the current object class name.
  19766. * @return the class name
  19767. */
  19768. getClassName(): string;
  19769. /**
  19770. * Returns an array containing the root bones
  19771. * @returns an array containing the root bones
  19772. */
  19773. getChildren(): Array<Bone>;
  19774. /**
  19775. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19776. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19777. * @returns a Float32Array containing matrices data
  19778. */
  19779. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19780. /**
  19781. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19782. * @returns a raw texture containing the data
  19783. */
  19784. getTransformMatrixTexture(): Nullable<RawTexture>;
  19785. /**
  19786. * Gets the current hosting scene
  19787. * @returns a scene object
  19788. */
  19789. getScene(): Scene;
  19790. /**
  19791. * Gets a string representing the current skeleton data
  19792. * @param fullDetails defines a boolean indicating if we want a verbose version
  19793. * @returns a string representing the current skeleton data
  19794. */
  19795. toString(fullDetails?: boolean): string;
  19796. /**
  19797. * Get bone's index searching by name
  19798. * @param name defines bone's name to search for
  19799. * @return the indice of the bone. Returns -1 if not found
  19800. */
  19801. getBoneIndexByName(name: string): number;
  19802. /**
  19803. * Creater a new animation range
  19804. * @param name defines the name of the range
  19805. * @param from defines the start key
  19806. * @param to defines the end key
  19807. */
  19808. createAnimationRange(name: string, from: number, to: number): void;
  19809. /**
  19810. * Delete a specific animation range
  19811. * @param name defines the name of the range
  19812. * @param deleteFrames defines if frames must be removed as well
  19813. */
  19814. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19815. /**
  19816. * Gets a specific animation range
  19817. * @param name defines the name of the range to look for
  19818. * @returns the requested animation range or null if not found
  19819. */
  19820. getAnimationRange(name: string): Nullable<AnimationRange>;
  19821. /**
  19822. * Gets the list of all animation ranges defined on this skeleton
  19823. * @returns an array
  19824. */
  19825. getAnimationRanges(): Nullable<AnimationRange>[];
  19826. /**
  19827. * Copy animation range from a source skeleton.
  19828. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19829. * @param source defines the source skeleton
  19830. * @param name defines the name of the range to copy
  19831. * @param rescaleAsRequired defines if rescaling must be applied if required
  19832. * @returns true if operation was successful
  19833. */
  19834. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19835. /**
  19836. * Forces the skeleton to go to rest pose
  19837. */
  19838. returnToRest(): void;
  19839. private _getHighestAnimationFrame;
  19840. /**
  19841. * Begin a specific animation range
  19842. * @param name defines the name of the range to start
  19843. * @param loop defines if looping must be turned on (false by default)
  19844. * @param speedRatio defines the speed ratio to apply (1 by default)
  19845. * @param onAnimationEnd defines a callback which will be called when animation will end
  19846. * @returns a new animatable
  19847. */
  19848. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19849. /** @hidden */
  19850. _markAsDirty(): void;
  19851. /** @hidden */
  19852. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19853. /** @hidden */
  19854. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19855. private _computeTransformMatrices;
  19856. /**
  19857. * Build all resources required to render a skeleton
  19858. */
  19859. prepare(): void;
  19860. /**
  19861. * Gets the list of animatables currently running for this skeleton
  19862. * @returns an array of animatables
  19863. */
  19864. getAnimatables(): IAnimatable[];
  19865. /**
  19866. * Clone the current skeleton
  19867. * @param name defines the name of the new skeleton
  19868. * @param id defines the id of the new skeleton
  19869. * @returns the new skeleton
  19870. */
  19871. clone(name: string, id: string): Skeleton;
  19872. /**
  19873. * Enable animation blending for this skeleton
  19874. * @param blendingSpeed defines the blending speed to apply
  19875. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19876. */
  19877. enableBlending(blendingSpeed?: number): void;
  19878. /**
  19879. * Releases all resources associated with the current skeleton
  19880. */
  19881. dispose(): void;
  19882. /**
  19883. * Serialize the skeleton in a JSON object
  19884. * @returns a JSON object
  19885. */
  19886. serialize(): any;
  19887. /**
  19888. * Creates a new skeleton from serialized data
  19889. * @param parsedSkeleton defines the serialized data
  19890. * @param scene defines the hosting scene
  19891. * @returns a new skeleton
  19892. */
  19893. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19894. /**
  19895. * Compute all node absolute transforms
  19896. * @param forceUpdate defines if computation must be done even if cache is up to date
  19897. */
  19898. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19899. /**
  19900. * Gets the root pose matrix
  19901. * @returns a matrix
  19902. */
  19903. getPoseMatrix(): Nullable<Matrix>;
  19904. /**
  19905. * Sorts bones per internal index
  19906. */
  19907. sortBones(): void;
  19908. private _sortBones;
  19909. }
  19910. }
  19911. declare module "babylonjs/Morph/morphTarget" {
  19912. import { IAnimatable } from "babylonjs/Misc/tools";
  19913. import { Observable } from "babylonjs/Misc/observable";
  19914. import { Nullable, FloatArray } from "babylonjs/types";
  19915. import { Scene } from "babylonjs/scene";
  19916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19917. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19918. /**
  19919. * Defines a target to use with MorphTargetManager
  19920. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19921. */
  19922. export class MorphTarget implements IAnimatable {
  19923. /** defines the name of the target */
  19924. name: string;
  19925. /**
  19926. * Gets or sets the list of animations
  19927. */
  19928. animations: import("babylonjs/Animations/animation").Animation[];
  19929. private _scene;
  19930. private _positions;
  19931. private _normals;
  19932. private _tangents;
  19933. private _influence;
  19934. /**
  19935. * Observable raised when the influence changes
  19936. */
  19937. onInfluenceChanged: Observable<boolean>;
  19938. /** @hidden */
  19939. _onDataLayoutChanged: Observable<void>;
  19940. /**
  19941. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19942. */
  19943. influence: number;
  19944. /**
  19945. * Gets or sets the id of the morph Target
  19946. */
  19947. id: string;
  19948. private _animationPropertiesOverride;
  19949. /**
  19950. * Gets or sets the animation properties override
  19951. */
  19952. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19953. /**
  19954. * Creates a new MorphTarget
  19955. * @param name defines the name of the target
  19956. * @param influence defines the influence to use
  19957. * @param scene defines the scene the morphtarget belongs to
  19958. */
  19959. constructor(
  19960. /** defines the name of the target */
  19961. name: string, influence?: number, scene?: Nullable<Scene>);
  19962. /**
  19963. * Gets a boolean defining if the target contains position data
  19964. */
  19965. readonly hasPositions: boolean;
  19966. /**
  19967. * Gets a boolean defining if the target contains normal data
  19968. */
  19969. readonly hasNormals: boolean;
  19970. /**
  19971. * Gets a boolean defining if the target contains tangent data
  19972. */
  19973. readonly hasTangents: boolean;
  19974. /**
  19975. * Affects position data to this target
  19976. * @param data defines the position data to use
  19977. */
  19978. setPositions(data: Nullable<FloatArray>): void;
  19979. /**
  19980. * Gets the position data stored in this target
  19981. * @returns a FloatArray containing the position data (or null if not present)
  19982. */
  19983. getPositions(): Nullable<FloatArray>;
  19984. /**
  19985. * Affects normal data to this target
  19986. * @param data defines the normal data to use
  19987. */
  19988. setNormals(data: Nullable<FloatArray>): void;
  19989. /**
  19990. * Gets the normal data stored in this target
  19991. * @returns a FloatArray containing the normal data (or null if not present)
  19992. */
  19993. getNormals(): Nullable<FloatArray>;
  19994. /**
  19995. * Affects tangent data to this target
  19996. * @param data defines the tangent data to use
  19997. */
  19998. setTangents(data: Nullable<FloatArray>): void;
  19999. /**
  20000. * Gets the tangent data stored in this target
  20001. * @returns a FloatArray containing the tangent data (or null if not present)
  20002. */
  20003. getTangents(): Nullable<FloatArray>;
  20004. /**
  20005. * Serializes the current target into a Serialization object
  20006. * @returns the serialized object
  20007. */
  20008. serialize(): any;
  20009. /**
  20010. * Returns the string "MorphTarget"
  20011. * @returns "MorphTarget"
  20012. */
  20013. getClassName(): string;
  20014. /**
  20015. * Creates a new target from serialized data
  20016. * @param serializationObject defines the serialized data to use
  20017. * @returns a new MorphTarget
  20018. */
  20019. static Parse(serializationObject: any): MorphTarget;
  20020. /**
  20021. * Creates a MorphTarget from mesh data
  20022. * @param mesh defines the source mesh
  20023. * @param name defines the name to use for the new target
  20024. * @param influence defines the influence to attach to the target
  20025. * @returns a new MorphTarget
  20026. */
  20027. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20028. }
  20029. }
  20030. declare module "babylonjs/Morph/morphTargetManager" {
  20031. import { Nullable } from "babylonjs/types";
  20032. import { Scene } from "babylonjs/scene";
  20033. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20034. /**
  20035. * This class is used to deform meshes using morphing between different targets
  20036. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20037. */
  20038. export class MorphTargetManager {
  20039. private _targets;
  20040. private _targetInfluenceChangedObservers;
  20041. private _targetDataLayoutChangedObservers;
  20042. private _activeTargets;
  20043. private _scene;
  20044. private _influences;
  20045. private _supportsNormals;
  20046. private _supportsTangents;
  20047. private _vertexCount;
  20048. private _uniqueId;
  20049. private _tempInfluences;
  20050. /**
  20051. * Creates a new MorphTargetManager
  20052. * @param scene defines the current scene
  20053. */
  20054. constructor(scene?: Nullable<Scene>);
  20055. /**
  20056. * Gets the unique ID of this manager
  20057. */
  20058. readonly uniqueId: number;
  20059. /**
  20060. * Gets the number of vertices handled by this manager
  20061. */
  20062. readonly vertexCount: number;
  20063. /**
  20064. * Gets a boolean indicating if this manager supports morphing of normals
  20065. */
  20066. readonly supportsNormals: boolean;
  20067. /**
  20068. * Gets a boolean indicating if this manager supports morphing of tangents
  20069. */
  20070. readonly supportsTangents: boolean;
  20071. /**
  20072. * Gets the number of targets stored in this manager
  20073. */
  20074. readonly numTargets: number;
  20075. /**
  20076. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20077. */
  20078. readonly numInfluencers: number;
  20079. /**
  20080. * Gets the list of influences (one per target)
  20081. */
  20082. readonly influences: Float32Array;
  20083. /**
  20084. * Gets the active target at specified index. An active target is a target with an influence > 0
  20085. * @param index defines the index to check
  20086. * @returns the requested target
  20087. */
  20088. getActiveTarget(index: number): MorphTarget;
  20089. /**
  20090. * Gets the target at specified index
  20091. * @param index defines the index to check
  20092. * @returns the requested target
  20093. */
  20094. getTarget(index: number): MorphTarget;
  20095. /**
  20096. * Add a new target to this manager
  20097. * @param target defines the target to add
  20098. */
  20099. addTarget(target: MorphTarget): void;
  20100. /**
  20101. * Removes a target from the manager
  20102. * @param target defines the target to remove
  20103. */
  20104. removeTarget(target: MorphTarget): void;
  20105. /**
  20106. * Serializes the current manager into a Serialization object
  20107. * @returns the serialized object
  20108. */
  20109. serialize(): any;
  20110. private _syncActiveTargets;
  20111. /**
  20112. * Syncrhonize the targets with all the meshes using this morph target manager
  20113. */
  20114. synchronize(): void;
  20115. /**
  20116. * Creates a new MorphTargetManager from serialized data
  20117. * @param serializationObject defines the serialized data
  20118. * @param scene defines the hosting scene
  20119. * @returns the new MorphTargetManager
  20120. */
  20121. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20122. }
  20123. }
  20124. declare module "babylonjs/Meshes/meshLODLevel" {
  20125. import { Mesh } from "babylonjs/Meshes/mesh";
  20126. import { Nullable } from "babylonjs/types";
  20127. /**
  20128. * Class used to represent a specific level of detail of a mesh
  20129. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20130. */
  20131. export class MeshLODLevel {
  20132. /** Defines the distance where this level should star being displayed */
  20133. distance: number;
  20134. /** Defines the mesh to use to render this level */
  20135. mesh: Nullable<Mesh>;
  20136. /**
  20137. * Creates a new LOD level
  20138. * @param distance defines the distance where this level should star being displayed
  20139. * @param mesh defines the mesh to use to render this level
  20140. */
  20141. constructor(
  20142. /** Defines the distance where this level should star being displayed */
  20143. distance: number,
  20144. /** Defines the mesh to use to render this level */
  20145. mesh: Nullable<Mesh>);
  20146. }
  20147. }
  20148. declare module "babylonjs/Meshes/groundMesh" {
  20149. import { Scene } from "babylonjs/scene";
  20150. import { Vector3 } from "babylonjs/Maths/math";
  20151. import { Mesh } from "babylonjs/Meshes/mesh";
  20152. /**
  20153. * Mesh representing the gorund
  20154. */
  20155. export class GroundMesh extends Mesh {
  20156. /** If octree should be generated */
  20157. generateOctree: boolean;
  20158. private _heightQuads;
  20159. /** @hidden */
  20160. _subdivisionsX: number;
  20161. /** @hidden */
  20162. _subdivisionsY: number;
  20163. /** @hidden */
  20164. _width: number;
  20165. /** @hidden */
  20166. _height: number;
  20167. /** @hidden */
  20168. _minX: number;
  20169. /** @hidden */
  20170. _maxX: number;
  20171. /** @hidden */
  20172. _minZ: number;
  20173. /** @hidden */
  20174. _maxZ: number;
  20175. constructor(name: string, scene: Scene);
  20176. /**
  20177. * "GroundMesh"
  20178. * @returns "GroundMesh"
  20179. */
  20180. getClassName(): string;
  20181. /**
  20182. * The minimum of x and y subdivisions
  20183. */
  20184. readonly subdivisions: number;
  20185. /**
  20186. * X subdivisions
  20187. */
  20188. readonly subdivisionsX: number;
  20189. /**
  20190. * Y subdivisions
  20191. */
  20192. readonly subdivisionsY: number;
  20193. /**
  20194. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20195. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20196. * @param chunksCount the number of subdivisions for x and y
  20197. * @param octreeBlocksSize (Default: 32)
  20198. */
  20199. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20200. /**
  20201. * Returns a height (y) value in the Worl system :
  20202. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20203. * @param x x coordinate
  20204. * @param z z coordinate
  20205. * @returns the ground y position if (x, z) are outside the ground surface.
  20206. */
  20207. getHeightAtCoordinates(x: number, z: number): number;
  20208. /**
  20209. * Returns a normalized vector (Vector3) orthogonal to the ground
  20210. * at the ground coordinates (x, z) expressed in the World system.
  20211. * @param x x coordinate
  20212. * @param z z coordinate
  20213. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20214. */
  20215. getNormalAtCoordinates(x: number, z: number): Vector3;
  20216. /**
  20217. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20218. * at the ground coordinates (x, z) expressed in the World system.
  20219. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20220. * @param x x coordinate
  20221. * @param z z coordinate
  20222. * @param ref vector to store the result
  20223. * @returns the GroundMesh.
  20224. */
  20225. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20226. /**
  20227. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20228. * if the ground has been updated.
  20229. * This can be used in the render loop.
  20230. * @returns the GroundMesh.
  20231. */
  20232. updateCoordinateHeights(): GroundMesh;
  20233. private _getFacetAt;
  20234. private _initHeightQuads;
  20235. private _computeHeightQuads;
  20236. /**
  20237. * Serializes this ground mesh
  20238. * @param serializationObject object to write serialization to
  20239. */
  20240. serialize(serializationObject: any): void;
  20241. /**
  20242. * Parses a serialized ground mesh
  20243. * @param parsedMesh the serialized mesh
  20244. * @param scene the scene to create the ground mesh in
  20245. * @returns the created ground mesh
  20246. */
  20247. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20248. }
  20249. }
  20250. declare module "babylonjs/Physics/physicsJoint" {
  20251. import { Vector3 } from "babylonjs/Maths/math";
  20252. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20253. /**
  20254. * Interface for Physics-Joint data
  20255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20256. */
  20257. export interface PhysicsJointData {
  20258. /**
  20259. * The main pivot of the joint
  20260. */
  20261. mainPivot?: Vector3;
  20262. /**
  20263. * The connected pivot of the joint
  20264. */
  20265. connectedPivot?: Vector3;
  20266. /**
  20267. * The main axis of the joint
  20268. */
  20269. mainAxis?: Vector3;
  20270. /**
  20271. * The connected axis of the joint
  20272. */
  20273. connectedAxis?: Vector3;
  20274. /**
  20275. * The collision of the joint
  20276. */
  20277. collision?: boolean;
  20278. /**
  20279. * Native Oimo/Cannon/Energy data
  20280. */
  20281. nativeParams?: any;
  20282. }
  20283. /**
  20284. * This is a holder class for the physics joint created by the physics plugin
  20285. * It holds a set of functions to control the underlying joint
  20286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20287. */
  20288. export class PhysicsJoint {
  20289. /**
  20290. * The type of the physics joint
  20291. */
  20292. type: number;
  20293. /**
  20294. * The data for the physics joint
  20295. */
  20296. jointData: PhysicsJointData;
  20297. private _physicsJoint;
  20298. protected _physicsPlugin: IPhysicsEnginePlugin;
  20299. /**
  20300. * Initializes the physics joint
  20301. * @param type The type of the physics joint
  20302. * @param jointData The data for the physics joint
  20303. */
  20304. constructor(
  20305. /**
  20306. * The type of the physics joint
  20307. */
  20308. type: number,
  20309. /**
  20310. * The data for the physics joint
  20311. */
  20312. jointData: PhysicsJointData);
  20313. /**
  20314. * Gets the physics joint
  20315. */
  20316. /**
  20317. * Sets the physics joint
  20318. */
  20319. physicsJoint: any;
  20320. /**
  20321. * Sets the physics plugin
  20322. */
  20323. physicsPlugin: IPhysicsEnginePlugin;
  20324. /**
  20325. * Execute a function that is physics-plugin specific.
  20326. * @param {Function} func the function that will be executed.
  20327. * It accepts two parameters: the physics world and the physics joint
  20328. */
  20329. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20330. /**
  20331. * Distance-Joint type
  20332. */
  20333. static DistanceJoint: number;
  20334. /**
  20335. * Hinge-Joint type
  20336. */
  20337. static HingeJoint: number;
  20338. /**
  20339. * Ball-and-Socket joint type
  20340. */
  20341. static BallAndSocketJoint: number;
  20342. /**
  20343. * Wheel-Joint type
  20344. */
  20345. static WheelJoint: number;
  20346. /**
  20347. * Slider-Joint type
  20348. */
  20349. static SliderJoint: number;
  20350. /**
  20351. * Prismatic-Joint type
  20352. */
  20353. static PrismaticJoint: number;
  20354. /**
  20355. * Universal-Joint type
  20356. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20357. */
  20358. static UniversalJoint: number;
  20359. /**
  20360. * Hinge-Joint 2 type
  20361. */
  20362. static Hinge2Joint: number;
  20363. /**
  20364. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20365. */
  20366. static PointToPointJoint: number;
  20367. /**
  20368. * Spring-Joint type
  20369. */
  20370. static SpringJoint: number;
  20371. /**
  20372. * Lock-Joint type
  20373. */
  20374. static LockJoint: number;
  20375. }
  20376. /**
  20377. * A class representing a physics distance joint
  20378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20379. */
  20380. export class DistanceJoint extends PhysicsJoint {
  20381. /**
  20382. *
  20383. * @param jointData The data for the Distance-Joint
  20384. */
  20385. constructor(jointData: DistanceJointData);
  20386. /**
  20387. * Update the predefined distance.
  20388. * @param maxDistance The maximum preferred distance
  20389. * @param minDistance The minimum preferred distance
  20390. */
  20391. updateDistance(maxDistance: number, minDistance?: number): void;
  20392. }
  20393. /**
  20394. * Represents a Motor-Enabled Joint
  20395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20396. */
  20397. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20398. /**
  20399. * Initializes the Motor-Enabled Joint
  20400. * @param type The type of the joint
  20401. * @param jointData The physica joint data for the joint
  20402. */
  20403. constructor(type: number, jointData: PhysicsJointData);
  20404. /**
  20405. * Set the motor values.
  20406. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20407. * @param force the force to apply
  20408. * @param maxForce max force for this motor.
  20409. */
  20410. setMotor(force?: number, maxForce?: number): void;
  20411. /**
  20412. * Set the motor's limits.
  20413. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20414. * @param upperLimit The upper limit of the motor
  20415. * @param lowerLimit The lower limit of the motor
  20416. */
  20417. setLimit(upperLimit: number, lowerLimit?: number): void;
  20418. }
  20419. /**
  20420. * This class represents a single physics Hinge-Joint
  20421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20422. */
  20423. export class HingeJoint extends MotorEnabledJoint {
  20424. /**
  20425. * Initializes the Hinge-Joint
  20426. * @param jointData The joint data for the Hinge-Joint
  20427. */
  20428. constructor(jointData: PhysicsJointData);
  20429. /**
  20430. * Set the motor values.
  20431. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20432. * @param {number} force the force to apply
  20433. * @param {number} maxForce max force for this motor.
  20434. */
  20435. setMotor(force?: number, maxForce?: number): void;
  20436. /**
  20437. * Set the motor's limits.
  20438. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20439. * @param upperLimit The upper limit of the motor
  20440. * @param lowerLimit The lower limit of the motor
  20441. */
  20442. setLimit(upperLimit: number, lowerLimit?: number): void;
  20443. }
  20444. /**
  20445. * This class represents a dual hinge physics joint (same as wheel joint)
  20446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20447. */
  20448. export class Hinge2Joint extends MotorEnabledJoint {
  20449. /**
  20450. * Initializes the Hinge2-Joint
  20451. * @param jointData The joint data for the Hinge2-Joint
  20452. */
  20453. constructor(jointData: PhysicsJointData);
  20454. /**
  20455. * Set the motor values.
  20456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20457. * @param {number} targetSpeed the speed the motor is to reach
  20458. * @param {number} maxForce max force for this motor.
  20459. * @param {motorIndex} the motor's index, 0 or 1.
  20460. */
  20461. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20462. /**
  20463. * Set the motor limits.
  20464. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20465. * @param {number} upperLimit the upper limit
  20466. * @param {number} lowerLimit lower limit
  20467. * @param {motorIndex} the motor's index, 0 or 1.
  20468. */
  20469. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20470. }
  20471. /**
  20472. * Interface for a motor enabled joint
  20473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20474. */
  20475. export interface IMotorEnabledJoint {
  20476. /**
  20477. * Physics joint
  20478. */
  20479. physicsJoint: any;
  20480. /**
  20481. * Sets the motor of the motor-enabled joint
  20482. * @param force The force of the motor
  20483. * @param maxForce The maximum force of the motor
  20484. * @param motorIndex The index of the motor
  20485. */
  20486. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20487. /**
  20488. * Sets the limit of the motor
  20489. * @param upperLimit The upper limit of the motor
  20490. * @param lowerLimit The lower limit of the motor
  20491. * @param motorIndex The index of the motor
  20492. */
  20493. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20494. }
  20495. /**
  20496. * Joint data for a Distance-Joint
  20497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20498. */
  20499. export interface DistanceJointData extends PhysicsJointData {
  20500. /**
  20501. * Max distance the 2 joint objects can be apart
  20502. */
  20503. maxDistance: number;
  20504. }
  20505. /**
  20506. * Joint data from a spring joint
  20507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20508. */
  20509. export interface SpringJointData extends PhysicsJointData {
  20510. /**
  20511. * Length of the spring
  20512. */
  20513. length: number;
  20514. /**
  20515. * Stiffness of the spring
  20516. */
  20517. stiffness: number;
  20518. /**
  20519. * Damping of the spring
  20520. */
  20521. damping: number;
  20522. /** this callback will be called when applying the force to the impostors. */
  20523. forceApplicationCallback: () => void;
  20524. }
  20525. }
  20526. declare module "babylonjs/Physics/physicsRaycastResult" {
  20527. import { Vector3 } from "babylonjs/Maths/math";
  20528. /**
  20529. * Holds the data for the raycast result
  20530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20531. */
  20532. export class PhysicsRaycastResult {
  20533. private _hasHit;
  20534. private _hitDistance;
  20535. private _hitNormalWorld;
  20536. private _hitPointWorld;
  20537. private _rayFromWorld;
  20538. private _rayToWorld;
  20539. /**
  20540. * Gets if there was a hit
  20541. */
  20542. readonly hasHit: boolean;
  20543. /**
  20544. * Gets the distance from the hit
  20545. */
  20546. readonly hitDistance: number;
  20547. /**
  20548. * Gets the hit normal/direction in the world
  20549. */
  20550. readonly hitNormalWorld: Vector3;
  20551. /**
  20552. * Gets the hit point in the world
  20553. */
  20554. readonly hitPointWorld: Vector3;
  20555. /**
  20556. * Gets the ray "start point" of the ray in the world
  20557. */
  20558. readonly rayFromWorld: Vector3;
  20559. /**
  20560. * Gets the ray "end point" of the ray in the world
  20561. */
  20562. readonly rayToWorld: Vector3;
  20563. /**
  20564. * Sets the hit data (normal & point in world space)
  20565. * @param hitNormalWorld defines the normal in world space
  20566. * @param hitPointWorld defines the point in world space
  20567. */
  20568. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20569. /**
  20570. * Sets the distance from the start point to the hit point
  20571. * @param distance
  20572. */
  20573. setHitDistance(distance: number): void;
  20574. /**
  20575. * Calculates the distance manually
  20576. */
  20577. calculateHitDistance(): void;
  20578. /**
  20579. * Resets all the values to default
  20580. * @param from The from point on world space
  20581. * @param to The to point on world space
  20582. */
  20583. reset(from?: Vector3, to?: Vector3): void;
  20584. }
  20585. /**
  20586. * Interface for the size containing width and height
  20587. */
  20588. interface IXYZ {
  20589. /**
  20590. * X
  20591. */
  20592. x: number;
  20593. /**
  20594. * Y
  20595. */
  20596. y: number;
  20597. /**
  20598. * Z
  20599. */
  20600. z: number;
  20601. }
  20602. }
  20603. declare module "babylonjs/Physics/IPhysicsEngine" {
  20604. import { Nullable } from "babylonjs/types";
  20605. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20607. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20608. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20609. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20610. /**
  20611. * Interface used to describe a physics joint
  20612. */
  20613. export interface PhysicsImpostorJoint {
  20614. /** Defines the main impostor to which the joint is linked */
  20615. mainImpostor: PhysicsImpostor;
  20616. /** Defines the impostor that is connected to the main impostor using this joint */
  20617. connectedImpostor: PhysicsImpostor;
  20618. /** Defines the joint itself */
  20619. joint: PhysicsJoint;
  20620. }
  20621. /** @hidden */
  20622. export interface IPhysicsEnginePlugin {
  20623. world: any;
  20624. name: string;
  20625. setGravity(gravity: Vector3): void;
  20626. setTimeStep(timeStep: number): void;
  20627. getTimeStep(): number;
  20628. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20629. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20630. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20631. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20632. removePhysicsBody(impostor: PhysicsImpostor): void;
  20633. generateJoint(joint: PhysicsImpostorJoint): void;
  20634. removeJoint(joint: PhysicsImpostorJoint): void;
  20635. isSupported(): boolean;
  20636. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20637. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20638. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20639. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20640. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20641. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20642. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20643. getBodyMass(impostor: PhysicsImpostor): number;
  20644. getBodyFriction(impostor: PhysicsImpostor): number;
  20645. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20646. getBodyRestitution(impostor: PhysicsImpostor): number;
  20647. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20648. getBodyPressure?(impostor: PhysicsImpostor): number;
  20649. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20650. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20651. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20652. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20653. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20654. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20655. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20656. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20657. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20658. sleepBody(impostor: PhysicsImpostor): void;
  20659. wakeUpBody(impostor: PhysicsImpostor): void;
  20660. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20661. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20662. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20663. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20664. getRadius(impostor: PhysicsImpostor): number;
  20665. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20666. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20667. dispose(): void;
  20668. }
  20669. /**
  20670. * Interface used to define a physics engine
  20671. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20672. */
  20673. export interface IPhysicsEngine {
  20674. /**
  20675. * Gets the gravity vector used by the simulation
  20676. */
  20677. gravity: Vector3;
  20678. /**
  20679. * Sets the gravity vector used by the simulation
  20680. * @param gravity defines the gravity vector to use
  20681. */
  20682. setGravity(gravity: Vector3): void;
  20683. /**
  20684. * Set the time step of the physics engine.
  20685. * Default is 1/60.
  20686. * To slow it down, enter 1/600 for example.
  20687. * To speed it up, 1/30
  20688. * @param newTimeStep the new timestep to apply to this world.
  20689. */
  20690. setTimeStep(newTimeStep: number): void;
  20691. /**
  20692. * Get the time step of the physics engine.
  20693. * @returns the current time step
  20694. */
  20695. getTimeStep(): number;
  20696. /**
  20697. * Release all resources
  20698. */
  20699. dispose(): void;
  20700. /**
  20701. * Gets the name of the current physics plugin
  20702. * @returns the name of the plugin
  20703. */
  20704. getPhysicsPluginName(): string;
  20705. /**
  20706. * Adding a new impostor for the impostor tracking.
  20707. * This will be done by the impostor itself.
  20708. * @param impostor the impostor to add
  20709. */
  20710. addImpostor(impostor: PhysicsImpostor): void;
  20711. /**
  20712. * Remove an impostor from the engine.
  20713. * This impostor and its mesh will not longer be updated by the physics engine.
  20714. * @param impostor the impostor to remove
  20715. */
  20716. removeImpostor(impostor: PhysicsImpostor): void;
  20717. /**
  20718. * Add a joint to the physics engine
  20719. * @param mainImpostor defines the main impostor to which the joint is added.
  20720. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20721. * @param joint defines the joint that will connect both impostors.
  20722. */
  20723. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20724. /**
  20725. * Removes a joint from the simulation
  20726. * @param mainImpostor defines the impostor used with the joint
  20727. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20728. * @param joint defines the joint to remove
  20729. */
  20730. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20731. /**
  20732. * Gets the current plugin used to run the simulation
  20733. * @returns current plugin
  20734. */
  20735. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20736. /**
  20737. * Gets the list of physic impostors
  20738. * @returns an array of PhysicsImpostor
  20739. */
  20740. getImpostors(): Array<PhysicsImpostor>;
  20741. /**
  20742. * Gets the impostor for a physics enabled object
  20743. * @param object defines the object impersonated by the impostor
  20744. * @returns the PhysicsImpostor or null if not found
  20745. */
  20746. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20747. /**
  20748. * Gets the impostor for a physics body object
  20749. * @param body defines physics body used by the impostor
  20750. * @returns the PhysicsImpostor or null if not found
  20751. */
  20752. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20753. /**
  20754. * Does a raycast in the physics world
  20755. * @param from when should the ray start?
  20756. * @param to when should the ray end?
  20757. * @returns PhysicsRaycastResult
  20758. */
  20759. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20760. /**
  20761. * Called by the scene. No need to call it.
  20762. * @param delta defines the timespam between frames
  20763. */
  20764. _step(delta: number): void;
  20765. }
  20766. }
  20767. declare module "babylonjs/Physics/physicsImpostor" {
  20768. import { Nullable, IndicesArray } from "babylonjs/types";
  20769. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20772. import { Scene } from "babylonjs/scene";
  20773. import { Bone } from "babylonjs/Bones/bone";
  20774. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20775. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20776. /**
  20777. * The interface for the physics imposter parameters
  20778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20779. */
  20780. export interface PhysicsImpostorParameters {
  20781. /**
  20782. * The mass of the physics imposter
  20783. */
  20784. mass: number;
  20785. /**
  20786. * The friction of the physics imposter
  20787. */
  20788. friction?: number;
  20789. /**
  20790. * The coefficient of restitution of the physics imposter
  20791. */
  20792. restitution?: number;
  20793. /**
  20794. * The native options of the physics imposter
  20795. */
  20796. nativeOptions?: any;
  20797. /**
  20798. * Specifies if the parent should be ignored
  20799. */
  20800. ignoreParent?: boolean;
  20801. /**
  20802. * Specifies if bi-directional transformations should be disabled
  20803. */
  20804. disableBidirectionalTransformation?: boolean;
  20805. /**
  20806. * The pressure inside the physics imposter, soft object only
  20807. */
  20808. pressure?: number;
  20809. /**
  20810. * The stiffness the physics imposter, soft object only
  20811. */
  20812. stiffness?: number;
  20813. /**
  20814. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20815. */
  20816. velocityIterations?: number;
  20817. /**
  20818. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20819. */
  20820. positionIterations?: number;
  20821. /**
  20822. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20823. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20824. * Add to fix multiple points
  20825. */
  20826. fixedPoints?: number;
  20827. /**
  20828. * The collision margin around a soft object
  20829. */
  20830. margin?: number;
  20831. /**
  20832. * The collision margin around a soft object
  20833. */
  20834. damping?: number;
  20835. /**
  20836. * The path for a rope based on an extrusion
  20837. */
  20838. path?: any;
  20839. /**
  20840. * The shape of an extrusion used for a rope based on an extrusion
  20841. */
  20842. shape?: any;
  20843. }
  20844. /**
  20845. * Interface for a physics-enabled object
  20846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20847. */
  20848. export interface IPhysicsEnabledObject {
  20849. /**
  20850. * The position of the physics-enabled object
  20851. */
  20852. position: Vector3;
  20853. /**
  20854. * The rotation of the physics-enabled object
  20855. */
  20856. rotationQuaternion: Nullable<Quaternion>;
  20857. /**
  20858. * The scale of the physics-enabled object
  20859. */
  20860. scaling: Vector3;
  20861. /**
  20862. * The rotation of the physics-enabled object
  20863. */
  20864. rotation?: Vector3;
  20865. /**
  20866. * The parent of the physics-enabled object
  20867. */
  20868. parent?: any;
  20869. /**
  20870. * The bounding info of the physics-enabled object
  20871. * @returns The bounding info of the physics-enabled object
  20872. */
  20873. getBoundingInfo(): BoundingInfo;
  20874. /**
  20875. * Computes the world matrix
  20876. * @param force Specifies if the world matrix should be computed by force
  20877. * @returns A world matrix
  20878. */
  20879. computeWorldMatrix(force: boolean): Matrix;
  20880. /**
  20881. * Gets the world matrix
  20882. * @returns A world matrix
  20883. */
  20884. getWorldMatrix?(): Matrix;
  20885. /**
  20886. * Gets the child meshes
  20887. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20888. * @returns An array of abstract meshes
  20889. */
  20890. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20891. /**
  20892. * Gets the vertex data
  20893. * @param kind The type of vertex data
  20894. * @returns A nullable array of numbers, or a float32 array
  20895. */
  20896. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20897. /**
  20898. * Gets the indices from the mesh
  20899. * @returns A nullable array of index arrays
  20900. */
  20901. getIndices?(): Nullable<IndicesArray>;
  20902. /**
  20903. * Gets the scene from the mesh
  20904. * @returns the indices array or null
  20905. */
  20906. getScene?(): Scene;
  20907. /**
  20908. * Gets the absolute position from the mesh
  20909. * @returns the absolute position
  20910. */
  20911. getAbsolutePosition(): Vector3;
  20912. /**
  20913. * Gets the absolute pivot point from the mesh
  20914. * @returns the absolute pivot point
  20915. */
  20916. getAbsolutePivotPoint(): Vector3;
  20917. /**
  20918. * Rotates the mesh
  20919. * @param axis The axis of rotation
  20920. * @param amount The amount of rotation
  20921. * @param space The space of the rotation
  20922. * @returns The rotation transform node
  20923. */
  20924. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20925. /**
  20926. * Translates the mesh
  20927. * @param axis The axis of translation
  20928. * @param distance The distance of translation
  20929. * @param space The space of the translation
  20930. * @returns The transform node
  20931. */
  20932. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20933. /**
  20934. * Sets the absolute position of the mesh
  20935. * @param absolutePosition The absolute position of the mesh
  20936. * @returns The transform node
  20937. */
  20938. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20939. /**
  20940. * Gets the class name of the mesh
  20941. * @returns The class name
  20942. */
  20943. getClassName(): string;
  20944. }
  20945. /**
  20946. * Represents a physics imposter
  20947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20948. */
  20949. export class PhysicsImpostor {
  20950. /**
  20951. * The physics-enabled object used as the physics imposter
  20952. */
  20953. object: IPhysicsEnabledObject;
  20954. /**
  20955. * The type of the physics imposter
  20956. */
  20957. type: number;
  20958. private _options;
  20959. private _scene?;
  20960. /**
  20961. * The default object size of the imposter
  20962. */
  20963. static DEFAULT_OBJECT_SIZE: Vector3;
  20964. /**
  20965. * The identity quaternion of the imposter
  20966. */
  20967. static IDENTITY_QUATERNION: Quaternion;
  20968. /** @hidden */
  20969. _pluginData: any;
  20970. private _physicsEngine;
  20971. private _physicsBody;
  20972. private _bodyUpdateRequired;
  20973. private _onBeforePhysicsStepCallbacks;
  20974. private _onAfterPhysicsStepCallbacks;
  20975. /** @hidden */
  20976. _onPhysicsCollideCallbacks: Array<{
  20977. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20978. otherImpostors: Array<PhysicsImpostor>;
  20979. }>;
  20980. private _deltaPosition;
  20981. private _deltaRotation;
  20982. private _deltaRotationConjugated;
  20983. /** hidden */
  20984. _isFromLine: boolean;
  20985. private _parent;
  20986. private _isDisposed;
  20987. private static _tmpVecs;
  20988. private static _tmpQuat;
  20989. /**
  20990. * Specifies if the physics imposter is disposed
  20991. */
  20992. readonly isDisposed: boolean;
  20993. /**
  20994. * Gets the mass of the physics imposter
  20995. */
  20996. mass: number;
  20997. /**
  20998. * Gets the coefficient of friction
  20999. */
  21000. /**
  21001. * Sets the coefficient of friction
  21002. */
  21003. friction: number;
  21004. /**
  21005. * Gets the coefficient of restitution
  21006. */
  21007. /**
  21008. * Sets the coefficient of restitution
  21009. */
  21010. restitution: number;
  21011. /**
  21012. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21013. */
  21014. /**
  21015. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21016. */
  21017. pressure: number;
  21018. /**
  21019. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21020. */
  21021. /**
  21022. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21023. */
  21024. stiffness: number;
  21025. /**
  21026. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21027. */
  21028. /**
  21029. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21030. */
  21031. velocityIterations: number;
  21032. /**
  21033. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21034. */
  21035. /**
  21036. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21037. */
  21038. positionIterations: number;
  21039. /**
  21040. * The unique id of the physics imposter
  21041. * set by the physics engine when adding this impostor to the array
  21042. */
  21043. uniqueId: number;
  21044. /**
  21045. * @hidden
  21046. */
  21047. soft: boolean;
  21048. /**
  21049. * @hidden
  21050. */
  21051. segments: number;
  21052. private _joints;
  21053. /**
  21054. * Initializes the physics imposter
  21055. * @param object The physics-enabled object used as the physics imposter
  21056. * @param type The type of the physics imposter
  21057. * @param _options The options for the physics imposter
  21058. * @param _scene The Babylon scene
  21059. */
  21060. constructor(
  21061. /**
  21062. * The physics-enabled object used as the physics imposter
  21063. */
  21064. object: IPhysicsEnabledObject,
  21065. /**
  21066. * The type of the physics imposter
  21067. */
  21068. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21069. /**
  21070. * This function will completly initialize this impostor.
  21071. * It will create a new body - but only if this mesh has no parent.
  21072. * If it has, this impostor will not be used other than to define the impostor
  21073. * of the child mesh.
  21074. * @hidden
  21075. */
  21076. _init(): void;
  21077. private _getPhysicsParent;
  21078. /**
  21079. * Should a new body be generated.
  21080. * @returns boolean specifying if body initialization is required
  21081. */
  21082. isBodyInitRequired(): boolean;
  21083. /**
  21084. * Sets the updated scaling
  21085. * @param updated Specifies if the scaling is updated
  21086. */
  21087. setScalingUpdated(): void;
  21088. /**
  21089. * Force a regeneration of this or the parent's impostor's body.
  21090. * Use under cautious - This will remove all joints already implemented.
  21091. */
  21092. forceUpdate(): void;
  21093. /**
  21094. * Gets the body that holds this impostor. Either its own, or its parent.
  21095. */
  21096. /**
  21097. * Set the physics body. Used mainly by the physics engine/plugin
  21098. */
  21099. physicsBody: any;
  21100. /**
  21101. * Get the parent of the physics imposter
  21102. * @returns Physics imposter or null
  21103. */
  21104. /**
  21105. * Sets the parent of the physics imposter
  21106. */
  21107. parent: Nullable<PhysicsImpostor>;
  21108. /**
  21109. * Resets the update flags
  21110. */
  21111. resetUpdateFlags(): void;
  21112. /**
  21113. * Gets the object extend size
  21114. * @returns the object extend size
  21115. */
  21116. getObjectExtendSize(): Vector3;
  21117. /**
  21118. * Gets the object center
  21119. * @returns The object center
  21120. */
  21121. getObjectCenter(): Vector3;
  21122. /**
  21123. * Get a specific parametes from the options parameter
  21124. * @param paramName The object parameter name
  21125. * @returns The object parameter
  21126. */
  21127. getParam(paramName: string): any;
  21128. /**
  21129. * Sets a specific parameter in the options given to the physics plugin
  21130. * @param paramName The parameter name
  21131. * @param value The value of the parameter
  21132. */
  21133. setParam(paramName: string, value: number): void;
  21134. /**
  21135. * Specifically change the body's mass option. Won't recreate the physics body object
  21136. * @param mass The mass of the physics imposter
  21137. */
  21138. setMass(mass: number): void;
  21139. /**
  21140. * Gets the linear velocity
  21141. * @returns linear velocity or null
  21142. */
  21143. getLinearVelocity(): Nullable<Vector3>;
  21144. /**
  21145. * Sets the linear velocity
  21146. * @param velocity linear velocity or null
  21147. */
  21148. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21149. /**
  21150. * Gets the angular velocity
  21151. * @returns angular velocity or null
  21152. */
  21153. getAngularVelocity(): Nullable<Vector3>;
  21154. /**
  21155. * Sets the angular velocity
  21156. * @param velocity The velocity or null
  21157. */
  21158. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21159. /**
  21160. * Execute a function with the physics plugin native code
  21161. * Provide a function the will have two variables - the world object and the physics body object
  21162. * @param func The function to execute with the physics plugin native code
  21163. */
  21164. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21165. /**
  21166. * Register a function that will be executed before the physics world is stepping forward
  21167. * @param func The function to execute before the physics world is stepped forward
  21168. */
  21169. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21170. /**
  21171. * Unregister a function that will be executed before the physics world is stepping forward
  21172. * @param func The function to execute before the physics world is stepped forward
  21173. */
  21174. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21175. /**
  21176. * Register a function that will be executed after the physics step
  21177. * @param func The function to execute after physics step
  21178. */
  21179. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21180. /**
  21181. * Unregisters a function that will be executed after the physics step
  21182. * @param func The function to execute after physics step
  21183. */
  21184. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21185. /**
  21186. * register a function that will be executed when this impostor collides against a different body
  21187. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21188. * @param func Callback that is executed on collision
  21189. */
  21190. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21191. /**
  21192. * Unregisters the physics imposter on contact
  21193. * @param collideAgainst The physics object to collide against
  21194. * @param func Callback to execute on collision
  21195. */
  21196. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21197. private _tmpQuat;
  21198. private _tmpQuat2;
  21199. /**
  21200. * Get the parent rotation
  21201. * @returns The parent rotation
  21202. */
  21203. getParentsRotation(): Quaternion;
  21204. /**
  21205. * this function is executed by the physics engine.
  21206. */
  21207. beforeStep: () => void;
  21208. /**
  21209. * this function is executed by the physics engine
  21210. */
  21211. afterStep: () => void;
  21212. /**
  21213. * Legacy collision detection event support
  21214. */
  21215. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21216. /**
  21217. * event and body object due to cannon's event-based architecture.
  21218. */
  21219. onCollide: (e: {
  21220. body: any;
  21221. }) => void;
  21222. /**
  21223. * Apply a force
  21224. * @param force The force to apply
  21225. * @param contactPoint The contact point for the force
  21226. * @returns The physics imposter
  21227. */
  21228. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21229. /**
  21230. * Apply an impulse
  21231. * @param force The impulse force
  21232. * @param contactPoint The contact point for the impulse force
  21233. * @returns The physics imposter
  21234. */
  21235. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21236. /**
  21237. * A help function to create a joint
  21238. * @param otherImpostor A physics imposter used to create a joint
  21239. * @param jointType The type of joint
  21240. * @param jointData The data for the joint
  21241. * @returns The physics imposter
  21242. */
  21243. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21244. /**
  21245. * Add a joint to this impostor with a different impostor
  21246. * @param otherImpostor A physics imposter used to add a joint
  21247. * @param joint The joint to add
  21248. * @returns The physics imposter
  21249. */
  21250. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21251. /**
  21252. * Add an anchor to a cloth impostor
  21253. * @param otherImpostor rigid impostor to anchor to
  21254. * @param width ratio across width from 0 to 1
  21255. * @param height ratio up height from 0 to 1
  21256. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21257. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21258. * @returns impostor the soft imposter
  21259. */
  21260. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21261. /**
  21262. * Add a hook to a rope impostor
  21263. * @param otherImpostor rigid impostor to anchor to
  21264. * @param length ratio across rope from 0 to 1
  21265. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21266. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21267. * @returns impostor the rope imposter
  21268. */
  21269. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21270. /**
  21271. * Will keep this body still, in a sleep mode.
  21272. * @returns the physics imposter
  21273. */
  21274. sleep(): PhysicsImpostor;
  21275. /**
  21276. * Wake the body up.
  21277. * @returns The physics imposter
  21278. */
  21279. wakeUp(): PhysicsImpostor;
  21280. /**
  21281. * Clones the physics imposter
  21282. * @param newObject The physics imposter clones to this physics-enabled object
  21283. * @returns A nullable physics imposter
  21284. */
  21285. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21286. /**
  21287. * Disposes the physics imposter
  21288. */
  21289. dispose(): void;
  21290. /**
  21291. * Sets the delta position
  21292. * @param position The delta position amount
  21293. */
  21294. setDeltaPosition(position: Vector3): void;
  21295. /**
  21296. * Sets the delta rotation
  21297. * @param rotation The delta rotation amount
  21298. */
  21299. setDeltaRotation(rotation: Quaternion): void;
  21300. /**
  21301. * Gets the box size of the physics imposter and stores the result in the input parameter
  21302. * @param result Stores the box size
  21303. * @returns The physics imposter
  21304. */
  21305. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21306. /**
  21307. * Gets the radius of the physics imposter
  21308. * @returns Radius of the physics imposter
  21309. */
  21310. getRadius(): number;
  21311. /**
  21312. * Sync a bone with this impostor
  21313. * @param bone The bone to sync to the impostor.
  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. */
  21319. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21320. /**
  21321. * Sync impostor to a bone
  21322. * @param bone The bone that the impostor will be synced to.
  21323. * @param boneMesh The mesh that the bone is influencing.
  21324. * @param jointPivot The pivot of the joint / bone in local space.
  21325. * @param distToJoint Optional distance from the impostor to the joint.
  21326. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21327. * @param boneAxis Optional vector3 axis the bone is aligned with
  21328. */
  21329. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21330. /**
  21331. * No-Imposter type
  21332. */
  21333. static NoImpostor: number;
  21334. /**
  21335. * Sphere-Imposter type
  21336. */
  21337. static SphereImpostor: number;
  21338. /**
  21339. * Box-Imposter type
  21340. */
  21341. static BoxImpostor: number;
  21342. /**
  21343. * Plane-Imposter type
  21344. */
  21345. static PlaneImpostor: number;
  21346. /**
  21347. * Mesh-imposter type
  21348. */
  21349. static MeshImpostor: number;
  21350. /**
  21351. * Cylinder-Imposter type
  21352. */
  21353. static CylinderImpostor: number;
  21354. /**
  21355. * Particle-Imposter type
  21356. */
  21357. static ParticleImpostor: number;
  21358. /**
  21359. * Heightmap-Imposter type
  21360. */
  21361. static HeightmapImpostor: number;
  21362. /**
  21363. * ConvexHull-Impostor type (Ammo.js plugin only)
  21364. */
  21365. static ConvexHullImpostor: number;
  21366. /**
  21367. * Rope-Imposter type
  21368. */
  21369. static RopeImpostor: number;
  21370. /**
  21371. * Cloth-Imposter type
  21372. */
  21373. static ClothImpostor: number;
  21374. /**
  21375. * Softbody-Imposter type
  21376. */
  21377. static SoftbodyImpostor: number;
  21378. }
  21379. }
  21380. declare module "babylonjs/Meshes/mesh" {
  21381. import { Observable } from "babylonjs/Misc/observable";
  21382. import { IAnimatable } from "babylonjs/Misc/tools";
  21383. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21384. import { Camera } from "babylonjs/Cameras/camera";
  21385. import { Scene } from "babylonjs/scene";
  21386. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21387. import { Engine } from "babylonjs/Engines/engine";
  21388. import { Node } from "babylonjs/node";
  21389. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21390. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21391. import { Buffer } from "babylonjs/Meshes/buffer";
  21392. import { Geometry } from "babylonjs/Meshes/geometry";
  21393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21394. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21395. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21396. import { Effect } from "babylonjs/Materials/effect";
  21397. import { Material } from "babylonjs/Materials/material";
  21398. import { Skeleton } from "babylonjs/Bones/skeleton";
  21399. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21400. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21401. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21402. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21403. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21404. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21405. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21406. /**
  21407. * @hidden
  21408. **/
  21409. export class _CreationDataStorage {
  21410. closePath?: boolean;
  21411. closeArray?: boolean;
  21412. idx: number[];
  21413. dashSize: number;
  21414. gapSize: number;
  21415. path3D: Path3D;
  21416. pathArray: Vector3[][];
  21417. arc: number;
  21418. radius: number;
  21419. cap: number;
  21420. tessellation: number;
  21421. }
  21422. /**
  21423. * @hidden
  21424. **/
  21425. class _InstanceDataStorage {
  21426. visibleInstances: any;
  21427. batchCache: _InstancesBatch;
  21428. instancesBufferSize: number;
  21429. instancesBuffer: Nullable<Buffer>;
  21430. instancesData: Float32Array;
  21431. overridenInstanceCount: number;
  21432. isFrozen: boolean;
  21433. previousBatch: _InstancesBatch;
  21434. hardwareInstancedRendering: boolean;
  21435. sideOrientation: number;
  21436. }
  21437. /**
  21438. * @hidden
  21439. **/
  21440. export class _InstancesBatch {
  21441. mustReturn: boolean;
  21442. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21443. renderSelf: boolean[];
  21444. hardwareInstancedRendering: boolean[];
  21445. }
  21446. /**
  21447. * Class used to represent renderable models
  21448. */
  21449. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21450. /**
  21451. * Mesh side orientation : usually the external or front surface
  21452. */
  21453. static readonly FRONTSIDE: number;
  21454. /**
  21455. * Mesh side orientation : usually the internal or back surface
  21456. */
  21457. static readonly BACKSIDE: number;
  21458. /**
  21459. * Mesh side orientation : both internal and external or front and back surfaces
  21460. */
  21461. static readonly DOUBLESIDE: number;
  21462. /**
  21463. * Mesh side orientation : by default, `FRONTSIDE`
  21464. */
  21465. static readonly DEFAULTSIDE: number;
  21466. /**
  21467. * Mesh cap setting : no cap
  21468. */
  21469. static readonly NO_CAP: number;
  21470. /**
  21471. * Mesh cap setting : one cap at the beginning of the mesh
  21472. */
  21473. static readonly CAP_START: number;
  21474. /**
  21475. * Mesh cap setting : one cap at the end of the mesh
  21476. */
  21477. static readonly CAP_END: number;
  21478. /**
  21479. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21480. */
  21481. static readonly CAP_ALL: number;
  21482. /**
  21483. * Gets the default side orientation.
  21484. * @param orientation the orientation to value to attempt to get
  21485. * @returns the default orientation
  21486. * @hidden
  21487. */
  21488. static _GetDefaultSideOrientation(orientation?: number): number;
  21489. private _onBeforeRenderObservable;
  21490. private _onBeforeBindObservable;
  21491. private _onAfterRenderObservable;
  21492. private _onBeforeDrawObservable;
  21493. /**
  21494. * An event triggered before rendering the mesh
  21495. */
  21496. readonly onBeforeRenderObservable: Observable<Mesh>;
  21497. /**
  21498. * An event triggered before binding the mesh
  21499. */
  21500. readonly onBeforeBindObservable: Observable<Mesh>;
  21501. /**
  21502. * An event triggered after rendering the mesh
  21503. */
  21504. readonly onAfterRenderObservable: Observable<Mesh>;
  21505. /**
  21506. * An event triggered before drawing the mesh
  21507. */
  21508. readonly onBeforeDrawObservable: Observable<Mesh>;
  21509. private _onBeforeDrawObserver;
  21510. /**
  21511. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21512. */
  21513. onBeforeDraw: () => void;
  21514. /**
  21515. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21516. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21517. */
  21518. delayLoadState: number;
  21519. /**
  21520. * Gets the list of instances created from this mesh
  21521. * it is not supposed to be modified manually.
  21522. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21523. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21524. */
  21525. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21526. /**
  21527. * Gets the file containing delay loading data for this mesh
  21528. */
  21529. delayLoadingFile: string;
  21530. /** @hidden */
  21531. _binaryInfo: any;
  21532. private _LODLevels;
  21533. /**
  21534. * User defined function used to change how LOD level selection is done
  21535. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21536. */
  21537. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21538. private _morphTargetManager;
  21539. /**
  21540. * Gets or sets the morph target manager
  21541. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21542. */
  21543. morphTargetManager: Nullable<MorphTargetManager>;
  21544. /** @hidden */
  21545. _creationDataStorage: Nullable<_CreationDataStorage>;
  21546. /** @hidden */
  21547. _geometry: Nullable<Geometry>;
  21548. /** @hidden */
  21549. _delayInfo: Array<string>;
  21550. /** @hidden */
  21551. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21552. /** @hidden */
  21553. _instanceDataStorage: _InstanceDataStorage;
  21554. private _effectiveMaterial;
  21555. /** @hidden */
  21556. _shouldGenerateFlatShading: boolean;
  21557. private _preActivateId;
  21558. /** @hidden */
  21559. _originalBuilderSideOrientation: number;
  21560. /**
  21561. * Use this property to change the original side orientation defined at construction time
  21562. */
  21563. overrideMaterialSideOrientation: Nullable<number>;
  21564. private _areNormalsFrozen;
  21565. private _sourcePositions;
  21566. private _sourceNormals;
  21567. private _source;
  21568. private meshMap;
  21569. /**
  21570. * Gets the source mesh (the one used to clone this one from)
  21571. */
  21572. readonly source: Nullable<Mesh>;
  21573. /**
  21574. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21575. */
  21576. isUnIndexed: boolean;
  21577. /**
  21578. * @constructor
  21579. * @param name The value used by scene.getMeshByName() to do a lookup.
  21580. * @param scene The scene to add this mesh to.
  21581. * @param parent The parent of this mesh, if it has one
  21582. * @param source An optional Mesh from which geometry is shared, cloned.
  21583. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21584. * When false, achieved by calling a clone(), also passing False.
  21585. * This will make creation of children, recursive.
  21586. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21587. */
  21588. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21589. /**
  21590. * Gets the class name
  21591. * @returns the string "Mesh".
  21592. */
  21593. getClassName(): string;
  21594. /** @hidden */
  21595. readonly _isMesh: boolean;
  21596. /**
  21597. * Returns a description of this mesh
  21598. * @param fullDetails define if full details about this mesh must be used
  21599. * @returns a descriptive string representing this mesh
  21600. */
  21601. toString(fullDetails?: boolean): string;
  21602. /** @hidden */
  21603. _unBindEffect(): void;
  21604. /**
  21605. * Gets a boolean indicating if this mesh has LOD
  21606. */
  21607. readonly hasLODLevels: boolean;
  21608. /**
  21609. * Gets the list of MeshLODLevel associated with the current mesh
  21610. * @returns an array of MeshLODLevel
  21611. */
  21612. getLODLevels(): MeshLODLevel[];
  21613. private _sortLODLevels;
  21614. /**
  21615. * Add a mesh as LOD level triggered at the given distance.
  21616. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21617. * @param distance The distance from the center of the object to show this level
  21618. * @param mesh The mesh to be added as LOD level (can be null)
  21619. * @return This mesh (for chaining)
  21620. */
  21621. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21622. /**
  21623. * Returns the LOD level mesh at the passed distance or null if not found.
  21624. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21625. * @param distance The distance from the center of the object to show this level
  21626. * @returns a Mesh or `null`
  21627. */
  21628. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21629. /**
  21630. * Remove a mesh from the LOD array
  21631. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21632. * @param mesh defines the mesh to be removed
  21633. * @return This mesh (for chaining)
  21634. */
  21635. removeLODLevel(mesh: Mesh): Mesh;
  21636. /**
  21637. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21638. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21639. * @param camera defines the camera to use to compute distance
  21640. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21641. * @return This mesh (for chaining)
  21642. */
  21643. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21644. /**
  21645. * Gets the mesh internal Geometry object
  21646. */
  21647. readonly geometry: Nullable<Geometry>;
  21648. /**
  21649. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21650. * @returns the total number of vertices
  21651. */
  21652. getTotalVertices(): number;
  21653. /**
  21654. * Returns the content of an associated vertex buffer
  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. * @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
  21669. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21670. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21671. */
  21672. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21673. /**
  21674. * Returns the mesh VertexBuffer object from the requested `kind`
  21675. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21676. * - VertexBuffer.PositionKind
  21677. * - VertexBuffer.UVKind
  21678. * - VertexBuffer.UV2Kind
  21679. * - VertexBuffer.UV3Kind
  21680. * - VertexBuffer.UV4Kind
  21681. * - VertexBuffer.UV5Kind
  21682. * - VertexBuffer.UV6Kind
  21683. * - VertexBuffer.ColorKind
  21684. * - VertexBuffer.MatricesIndicesKind
  21685. * - VertexBuffer.MatricesIndicesExtraKind
  21686. * - VertexBuffer.MatricesWeightsKind
  21687. * - VertexBuffer.MatricesWeightsExtraKind
  21688. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21689. */
  21690. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21691. /**
  21692. * Tests if a specific vertex buffer is associated with this mesh
  21693. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21694. * - VertexBuffer.PositionKind
  21695. * - VertexBuffer.UVKind
  21696. * - VertexBuffer.UV2Kind
  21697. * - VertexBuffer.UV3Kind
  21698. * - VertexBuffer.UV4Kind
  21699. * - VertexBuffer.UV5Kind
  21700. * - VertexBuffer.UV6Kind
  21701. * - VertexBuffer.ColorKind
  21702. * - VertexBuffer.MatricesIndicesKind
  21703. * - VertexBuffer.MatricesIndicesExtraKind
  21704. * - VertexBuffer.MatricesWeightsKind
  21705. * - VertexBuffer.MatricesWeightsExtraKind
  21706. * @returns a boolean
  21707. */
  21708. isVerticesDataPresent(kind: string): boolean;
  21709. /**
  21710. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21711. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21712. * - VertexBuffer.PositionKind
  21713. * - VertexBuffer.UVKind
  21714. * - VertexBuffer.UV2Kind
  21715. * - VertexBuffer.UV3Kind
  21716. * - VertexBuffer.UV4Kind
  21717. * - VertexBuffer.UV5Kind
  21718. * - VertexBuffer.UV6Kind
  21719. * - VertexBuffer.ColorKind
  21720. * - VertexBuffer.MatricesIndicesKind
  21721. * - VertexBuffer.MatricesIndicesExtraKind
  21722. * - VertexBuffer.MatricesWeightsKind
  21723. * - VertexBuffer.MatricesWeightsExtraKind
  21724. * @returns a boolean
  21725. */
  21726. isVertexBufferUpdatable(kind: string): boolean;
  21727. /**
  21728. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21729. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21730. * - VertexBuffer.PositionKind
  21731. * - VertexBuffer.UVKind
  21732. * - VertexBuffer.UV2Kind
  21733. * - VertexBuffer.UV3Kind
  21734. * - VertexBuffer.UV4Kind
  21735. * - VertexBuffer.UV5Kind
  21736. * - VertexBuffer.UV6Kind
  21737. * - VertexBuffer.ColorKind
  21738. * - VertexBuffer.MatricesIndicesKind
  21739. * - VertexBuffer.MatricesIndicesExtraKind
  21740. * - VertexBuffer.MatricesWeightsKind
  21741. * - VertexBuffer.MatricesWeightsExtraKind
  21742. * @returns an array of strings
  21743. */
  21744. getVerticesDataKinds(): string[];
  21745. /**
  21746. * Returns a positive integer : the total number of indices in this mesh geometry.
  21747. * @returns the numner of indices or zero if the mesh has no geometry.
  21748. */
  21749. getTotalIndices(): number;
  21750. /**
  21751. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21752. * @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.
  21753. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21754. * @returns the indices array or an empty array if the mesh has no geometry
  21755. */
  21756. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21757. readonly isBlocked: boolean;
  21758. /**
  21759. * Determine if the current mesh is ready to be rendered
  21760. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21761. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21762. * @returns true if all associated assets are ready (material, textures, shaders)
  21763. */
  21764. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21765. /**
  21766. * 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.
  21767. */
  21768. readonly areNormalsFrozen: boolean;
  21769. /**
  21770. * 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.
  21771. * @returns the current mesh
  21772. */
  21773. freezeNormals(): Mesh;
  21774. /**
  21775. * 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
  21776. * @returns the current mesh
  21777. */
  21778. unfreezeNormals(): Mesh;
  21779. /**
  21780. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21781. */
  21782. overridenInstanceCount: number;
  21783. /** @hidden */
  21784. _preActivate(): Mesh;
  21785. /** @hidden */
  21786. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21787. /** @hidden */
  21788. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21789. /**
  21790. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21791. * This means the mesh underlying bounding box and sphere are recomputed.
  21792. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21793. * @returns the current mesh
  21794. */
  21795. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21796. /** @hidden */
  21797. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21798. /**
  21799. * This function will subdivide the mesh into multiple submeshes
  21800. * @param count defines the expected number of submeshes
  21801. */
  21802. subdivide(count: number): void;
  21803. /**
  21804. * Copy a FloatArray into a specific associated vertex buffer
  21805. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21806. * - VertexBuffer.PositionKind
  21807. * - VertexBuffer.UVKind
  21808. * - VertexBuffer.UV2Kind
  21809. * - VertexBuffer.UV3Kind
  21810. * - VertexBuffer.UV4Kind
  21811. * - VertexBuffer.UV5Kind
  21812. * - VertexBuffer.UV6Kind
  21813. * - VertexBuffer.ColorKind
  21814. * - VertexBuffer.MatricesIndicesKind
  21815. * - VertexBuffer.MatricesIndicesExtraKind
  21816. * - VertexBuffer.MatricesWeightsKind
  21817. * - VertexBuffer.MatricesWeightsExtraKind
  21818. * @param data defines the data source
  21819. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21820. * @param stride defines the data stride size (can be null)
  21821. * @returns the current mesh
  21822. */
  21823. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21824. /**
  21825. * Flags an associated vertex buffer as updatable
  21826. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21827. * - VertexBuffer.PositionKind
  21828. * - VertexBuffer.UVKind
  21829. * - VertexBuffer.UV2Kind
  21830. * - VertexBuffer.UV3Kind
  21831. * - VertexBuffer.UV4Kind
  21832. * - VertexBuffer.UV5Kind
  21833. * - VertexBuffer.UV6Kind
  21834. * - VertexBuffer.ColorKind
  21835. * - VertexBuffer.MatricesIndicesKind
  21836. * - VertexBuffer.MatricesIndicesExtraKind
  21837. * - VertexBuffer.MatricesWeightsKind
  21838. * - VertexBuffer.MatricesWeightsExtraKind
  21839. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21840. */
  21841. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21842. /**
  21843. * Sets the mesh global Vertex Buffer
  21844. * @param buffer defines the buffer to use
  21845. * @returns the current mesh
  21846. */
  21847. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21848. /**
  21849. * Update a specific associated vertex buffer
  21850. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21851. * - VertexBuffer.PositionKind
  21852. * - VertexBuffer.UVKind
  21853. * - VertexBuffer.UV2Kind
  21854. * - VertexBuffer.UV3Kind
  21855. * - VertexBuffer.UV4Kind
  21856. * - VertexBuffer.UV5Kind
  21857. * - VertexBuffer.UV6Kind
  21858. * - VertexBuffer.ColorKind
  21859. * - VertexBuffer.MatricesIndicesKind
  21860. * - VertexBuffer.MatricesIndicesExtraKind
  21861. * - VertexBuffer.MatricesWeightsKind
  21862. * - VertexBuffer.MatricesWeightsExtraKind
  21863. * @param data defines the data source
  21864. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21865. * @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)
  21866. * @returns the current mesh
  21867. */
  21868. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21869. /**
  21870. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21871. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21872. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21873. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21874. * @returns the current mesh
  21875. */
  21876. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21877. /**
  21878. * Creates a un-shared specific occurence of the geometry for the mesh.
  21879. * @returns the current mesh
  21880. */
  21881. makeGeometryUnique(): Mesh;
  21882. /**
  21883. * Set the index buffer of this mesh
  21884. * @param indices defines the source data
  21885. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21886. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21887. * @returns the current mesh
  21888. */
  21889. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21890. /**
  21891. * Update the current index buffer
  21892. * @param indices defines the source data
  21893. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21894. * @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)
  21895. * @returns the current mesh
  21896. */
  21897. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21898. /**
  21899. * Invert the geometry to move from a right handed system to a left handed one.
  21900. * @returns the current mesh
  21901. */
  21902. toLeftHanded(): Mesh;
  21903. /** @hidden */
  21904. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21905. /** @hidden */
  21906. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21907. /**
  21908. * Registers for this mesh a javascript function called just before the rendering process
  21909. * @param func defines the function to call before rendering this mesh
  21910. * @returns the current mesh
  21911. */
  21912. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21913. /**
  21914. * Disposes a previously registered javascript function called before the rendering
  21915. * @param func defines the function to remove
  21916. * @returns the current mesh
  21917. */
  21918. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21919. /**
  21920. * Registers for this mesh a javascript function called just after the rendering is complete
  21921. * @param func defines the function to call after rendering this mesh
  21922. * @returns the current mesh
  21923. */
  21924. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21925. /**
  21926. * Disposes a previously registered javascript function called after the rendering.
  21927. * @param func defines the function to remove
  21928. * @returns the current mesh
  21929. */
  21930. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21931. /** @hidden */
  21932. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21933. /** @hidden */
  21934. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21935. /** @hidden */
  21936. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21937. /** @hidden */
  21938. _freeze(): void;
  21939. /** @hidden */
  21940. _unFreeze(): void;
  21941. /**
  21942. * 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
  21943. * @param subMesh defines the subMesh to render
  21944. * @param enableAlphaMode defines if alpha mode can be changed
  21945. * @returns the current mesh
  21946. */
  21947. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21948. private _onBeforeDraw;
  21949. /**
  21950. * Renormalize the mesh and patch it up if there are no weights
  21951. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21952. * However in the case of zero weights then we set just a single influence to 1.
  21953. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21954. */
  21955. cleanMatrixWeights(): void;
  21956. private normalizeSkinFourWeights;
  21957. private normalizeSkinWeightsAndExtra;
  21958. /**
  21959. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21960. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21961. * the user know there was an issue with importing the mesh
  21962. * @returns a validation object with skinned, valid and report string
  21963. */
  21964. validateSkinning(): {
  21965. skinned: boolean;
  21966. valid: boolean;
  21967. report: string;
  21968. };
  21969. /** @hidden */
  21970. _checkDelayState(): Mesh;
  21971. private _queueLoad;
  21972. /**
  21973. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21974. * A mesh is in the frustum if its bounding box intersects the frustum
  21975. * @param frustumPlanes defines the frustum to test
  21976. * @returns true if the mesh is in the frustum planes
  21977. */
  21978. isInFrustum(frustumPlanes: Plane[]): boolean;
  21979. /**
  21980. * Sets the mesh material by the material or multiMaterial `id` property
  21981. * @param id is a string identifying the material or the multiMaterial
  21982. * @returns the current mesh
  21983. */
  21984. setMaterialByID(id: string): Mesh;
  21985. /**
  21986. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21987. * @returns an array of IAnimatable
  21988. */
  21989. getAnimatables(): IAnimatable[];
  21990. /**
  21991. * Modifies the mesh geometry according to the passed transformation matrix.
  21992. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21993. * The mesh normals are modified using the same transformation.
  21994. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21995. * @param transform defines the transform matrix to use
  21996. * @see http://doc.babylonjs.com/resources/baking_transformations
  21997. * @returns the current mesh
  21998. */
  21999. bakeTransformIntoVertices(transform: Matrix): Mesh;
  22000. /**
  22001. * Modifies the mesh geometry according to its own current World Matrix.
  22002. * The mesh World Matrix is then reset.
  22003. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  22004. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22005. * @see http://doc.babylonjs.com/resources/baking_transformations
  22006. * @returns the current mesh
  22007. */
  22008. bakeCurrentTransformIntoVertices(): Mesh;
  22009. /** @hidden */
  22010. readonly _positions: Nullable<Vector3[]>;
  22011. /** @hidden */
  22012. _resetPointsArrayCache(): Mesh;
  22013. /** @hidden */
  22014. _generatePointsArray(): boolean;
  22015. /**
  22016. * Returns a new Mesh object generated from the current mesh properties.
  22017. * This method must not get confused with createInstance()
  22018. * @param name is a string, the name given to the new mesh
  22019. * @param newParent can be any Node object (default `null`)
  22020. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22021. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22022. * @returns a new mesh
  22023. */
  22024. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22025. /**
  22026. * Releases resources associated with this mesh.
  22027. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22028. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22029. */
  22030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22031. /**
  22032. * Modifies the mesh geometry according to a displacement map.
  22033. * 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.
  22034. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22035. * @param url is a string, the URL from the image file is to be downloaded.
  22036. * @param minHeight is the lower limit of the displacement.
  22037. * @param maxHeight is the upper limit of the displacement.
  22038. * @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.
  22039. * @param uvOffset is an optional vector2 used to offset UV.
  22040. * @param uvScale is an optional vector2 used to scale UV.
  22041. * @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.
  22042. * @returns the Mesh.
  22043. */
  22044. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22045. /**
  22046. * Modifies the mesh geometry according to a displacementMap buffer.
  22047. * 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.
  22048. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22049. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22050. * @param heightMapWidth is the width of the buffer image.
  22051. * @param heightMapHeight is the height of the buffer image.
  22052. * @param minHeight is the lower limit of the displacement.
  22053. * @param maxHeight is the upper limit of the displacement.
  22054. * @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.
  22055. * @param uvOffset is an optional vector2 used to offset UV.
  22056. * @param uvScale is an optional vector2 used to scale UV.
  22057. * @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.
  22058. * @returns the Mesh.
  22059. */
  22060. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22061. /**
  22062. * Modify the mesh to get a flat shading rendering.
  22063. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22064. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22065. * @returns current mesh
  22066. */
  22067. convertToFlatShadedMesh(): Mesh;
  22068. /**
  22069. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22070. * In other words, more vertices, no more indices and a single bigger VBO.
  22071. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22072. * @returns current mesh
  22073. */
  22074. convertToUnIndexedMesh(): Mesh;
  22075. /**
  22076. * Inverses facet orientations.
  22077. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22078. * @param flipNormals will also inverts the normals
  22079. * @returns current mesh
  22080. */
  22081. flipFaces(flipNormals?: boolean): Mesh;
  22082. /**
  22083. * Increase the number of facets and hence vertices in a mesh
  22084. * Vertex normals are interpolated from existing vertex normals
  22085. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22086. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22087. */
  22088. increaseVertices(numberPerEdge: number): void;
  22089. /**
  22090. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22091. * This will undo any application of covertToFlatShadedMesh
  22092. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22093. */
  22094. forceSharedVertices(): void;
  22095. /** @hidden */
  22096. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22097. /** @hidden */
  22098. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22099. /**
  22100. * Creates a new InstancedMesh object from the mesh model.
  22101. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22102. * @param name defines the name of the new instance
  22103. * @returns a new InstancedMesh
  22104. */
  22105. createInstance(name: string): InstancedMesh;
  22106. /**
  22107. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22108. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22109. * @returns the current mesh
  22110. */
  22111. synchronizeInstances(): Mesh;
  22112. /**
  22113. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22114. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22115. * This should be used together with the simplification to avoid disappearing triangles.
  22116. * @param successCallback an optional success callback to be called after the optimization finished.
  22117. * @returns the current mesh
  22118. */
  22119. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22120. /**
  22121. * Serialize current mesh
  22122. * @param serializationObject defines the object which will receive the serialization data
  22123. */
  22124. serialize(serializationObject: any): void;
  22125. /** @hidden */
  22126. _syncGeometryWithMorphTargetManager(): void;
  22127. /** @hidden */
  22128. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22129. /**
  22130. * Returns a new Mesh object parsed from the source provided.
  22131. * @param parsedMesh is the source
  22132. * @param scene defines the hosting scene
  22133. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22134. * @returns a new Mesh
  22135. */
  22136. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22137. /**
  22138. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22139. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22140. * @param name defines the name of the mesh to create
  22141. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22142. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22143. * @param closePath creates a seam between the first and the last points of each path of the path array
  22144. * @param offset is taken in account only if the `pathArray` is containing a single path
  22145. * @param scene defines the hosting scene
  22146. * @param updatable defines if the mesh must be flagged as updatable
  22147. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22148. * @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)
  22149. * @returns a new Mesh
  22150. */
  22151. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22152. /**
  22153. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22154. * @param name defines the name of the mesh to create
  22155. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22156. * @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
  22157. * @param scene defines the hosting scene
  22158. * @param updatable defines if the mesh must be flagged as updatable
  22159. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22160. * @returns a new Mesh
  22161. */
  22162. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22163. /**
  22164. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22165. * @param name defines the name of the mesh to create
  22166. * @param size sets the size (float) of each box side (default 1)
  22167. * @param scene defines the hosting scene
  22168. * @param updatable defines if the mesh must be flagged as updatable
  22169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22170. * @returns a new Mesh
  22171. */
  22172. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22173. /**
  22174. * Creates a sphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22177. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22178. * @param scene defines the hosting scene
  22179. * @param updatable defines if the mesh must be flagged as updatable
  22180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22181. * @returns a new Mesh
  22182. */
  22183. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22184. /**
  22185. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22186. * @param name defines the name of the mesh to create
  22187. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22188. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22189. * @param scene defines the hosting scene
  22190. * @returns a new Mesh
  22191. */
  22192. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22193. /**
  22194. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22195. * @param name defines the name of the mesh to create
  22196. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22197. * @param diameterTop set the top cap diameter (floats, default 1)
  22198. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22199. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22200. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22201. * @param scene defines the hosting scene
  22202. * @param updatable defines if the mesh must be flagged as updatable
  22203. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22204. * @returns a new Mesh
  22205. */
  22206. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22207. /**
  22208. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22209. * @param name defines the name of the mesh to create
  22210. * @param diameter sets the diameter size (float) of the torus (default 1)
  22211. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22212. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22213. * @param scene defines the hosting scene
  22214. * @param updatable defines if the mesh must be flagged as updatable
  22215. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22216. * @returns a new Mesh
  22217. */
  22218. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22219. /**
  22220. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22221. * @param name defines the name of the mesh to create
  22222. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22223. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22224. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22225. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22226. * @param p the number of windings on X axis (positive integers, default 2)
  22227. * @param q the number of windings on Y axis (positive integers, default 3)
  22228. * @param scene defines the hosting scene
  22229. * @param updatable defines if the mesh must be flagged as updatable
  22230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22231. * @returns a new Mesh
  22232. */
  22233. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22234. /**
  22235. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22236. * @param name defines the name of the mesh to create
  22237. * @param points is an array successive Vector3
  22238. * @param scene defines the hosting scene
  22239. * @param updatable defines if the mesh must be flagged as updatable
  22240. * @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).
  22241. * @returns a new Mesh
  22242. */
  22243. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22244. /**
  22245. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22246. * @param name defines the name of the mesh to create
  22247. * @param points is an array successive Vector3
  22248. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22249. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22250. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22251. * @param scene defines the hosting scene
  22252. * @param updatable defines if the mesh must be flagged as updatable
  22253. * @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)
  22254. * @returns a new Mesh
  22255. */
  22256. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22257. /**
  22258. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22259. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22260. * 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.
  22261. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22262. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22263. * Remember you can only change the shape positions, not their number when updating a polygon.
  22264. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22265. * @param name defines the name of the mesh to create
  22266. * @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
  22267. * @param scene defines the hosting scene
  22268. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22269. * @param updatable defines if the mesh must be flagged as updatable
  22270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22271. * @param earcutInjection can be used to inject your own earcut reference
  22272. * @returns a new Mesh
  22273. */
  22274. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22275. /**
  22276. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22277. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22278. * @param name defines the name of the mesh to create
  22279. * @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
  22280. * @param depth defines the height of extrusion
  22281. * @param scene defines the hosting scene
  22282. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22283. * @param updatable defines if the mesh must be flagged as updatable
  22284. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22285. * @param earcutInjection can be used to inject your own earcut reference
  22286. * @returns a new Mesh
  22287. */
  22288. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22289. /**
  22290. * Creates an extruded shape mesh.
  22291. * 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
  22292. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22293. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22294. * @param name defines the name of the mesh to create
  22295. * @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
  22296. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22297. * @param scale is the value to scale the shape
  22298. * @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
  22299. * @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
  22300. * @param scene defines the hosting scene
  22301. * @param updatable defines if the mesh must be flagged as updatable
  22302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22303. * @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)
  22304. * @returns a new Mesh
  22305. */
  22306. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22307. /**
  22308. * Creates an custom extruded shape mesh.
  22309. * The custom extrusion is a parametric shape.
  22310. * It has no predefined shape. Its final shape will depend on the input parameters.
  22311. * Please consider using the same method from the MeshBuilder class instead
  22312. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22313. * @param name defines the name of the mesh to create
  22314. * @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
  22315. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22316. * @param scaleFunction is a custom Javascript function called on each path point
  22317. * @param rotationFunction is a custom Javascript function called on each path point
  22318. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22319. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22320. * @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
  22321. * @param scene defines the hosting scene
  22322. * @param updatable defines if the mesh must be flagged as updatable
  22323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22324. * @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)
  22325. * @returns a new Mesh
  22326. */
  22327. 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;
  22328. /**
  22329. * Creates lathe mesh.
  22330. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22331. * Please consider using the same method from the MeshBuilder class instead
  22332. * @param name defines the name of the mesh to create
  22333. * @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
  22334. * @param radius is the radius value of the lathe
  22335. * @param tessellation is the side number of the lathe.
  22336. * @param scene defines the hosting scene
  22337. * @param updatable defines if the mesh must be flagged as updatable
  22338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22339. * @returns a new Mesh
  22340. */
  22341. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22342. /**
  22343. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22344. * @param name defines the name of the mesh to create
  22345. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22346. * @param scene defines the hosting scene
  22347. * @param updatable defines if the mesh must be flagged as updatable
  22348. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22349. * @returns a new Mesh
  22350. */
  22351. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22352. /**
  22353. * Creates a ground mesh.
  22354. * Please consider using the same method from the MeshBuilder class instead
  22355. * @param name defines the name of the mesh to create
  22356. * @param width set the width of the ground
  22357. * @param height set the height of the ground
  22358. * @param subdivisions sets the number of subdivisions per side
  22359. * @param scene defines the hosting scene
  22360. * @param updatable defines if the mesh must be flagged as updatable
  22361. * @returns a new Mesh
  22362. */
  22363. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22364. /**
  22365. * Creates a tiled ground mesh.
  22366. * Please consider using the same method from the MeshBuilder class instead
  22367. * @param name defines the name of the mesh to create
  22368. * @param xmin set the ground minimum X coordinate
  22369. * @param zmin set the ground minimum Y coordinate
  22370. * @param xmax set the ground maximum X coordinate
  22371. * @param zmax set the ground maximum Z coordinate
  22372. * @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
  22373. * @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
  22374. * @param scene defines the hosting scene
  22375. * @param updatable defines if the mesh must be flagged as updatable
  22376. * @returns a new Mesh
  22377. */
  22378. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22379. w: number;
  22380. h: number;
  22381. }, precision: {
  22382. w: number;
  22383. h: number;
  22384. }, scene: Scene, updatable?: boolean): Mesh;
  22385. /**
  22386. * Creates a ground mesh from a height map.
  22387. * Please consider using the same method from the MeshBuilder class instead
  22388. * @see http://doc.babylonjs.com/babylon101/height_map
  22389. * @param name defines the name of the mesh to create
  22390. * @param url sets the URL of the height map image resource
  22391. * @param width set the ground width size
  22392. * @param height set the ground height size
  22393. * @param subdivisions sets the number of subdivision per side
  22394. * @param minHeight is the minimum altitude on the ground
  22395. * @param maxHeight is the maximum altitude on the ground
  22396. * @param scene defines the hosting scene
  22397. * @param updatable defines if the mesh must be flagged as updatable
  22398. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22399. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22400. * @returns a new Mesh
  22401. */
  22402. 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;
  22403. /**
  22404. * Creates a tube mesh.
  22405. * The tube is a parametric shape.
  22406. * It has no predefined shape. Its final shape will depend on the input parameters.
  22407. * Please consider using the same method from the MeshBuilder class instead
  22408. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22409. * @param name defines the name of the mesh to create
  22410. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22411. * @param radius sets the tube radius size
  22412. * @param tessellation is the number of sides on the tubular surface
  22413. * @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
  22414. * @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
  22415. * @param scene defines the hosting scene
  22416. * @param updatable defines if the mesh must be flagged as updatable
  22417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22418. * @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)
  22419. * @returns a new Mesh
  22420. */
  22421. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22422. (i: number, distance: number): number;
  22423. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22424. /**
  22425. * Creates a polyhedron mesh.
  22426. * Please consider using the same method from the MeshBuilder class instead.
  22427. * * 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
  22428. * * The parameter `size` (positive float, default 1) sets the polygon size
  22429. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22430. * * 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`
  22431. * * 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
  22432. * * 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)`)
  22433. * * 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
  22434. * * 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
  22435. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22436. * * If you create a double-sided mesh, you can choose what parts of 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
  22437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22438. * @param name defines the name of the mesh to create
  22439. * @param options defines the options used to create the mesh
  22440. * @param scene defines the hosting scene
  22441. * @returns a new Mesh
  22442. */
  22443. static CreatePolyhedron(name: string, options: {
  22444. type?: number;
  22445. size?: number;
  22446. sizeX?: number;
  22447. sizeY?: number;
  22448. sizeZ?: number;
  22449. custom?: any;
  22450. faceUV?: Vector4[];
  22451. faceColors?: Color4[];
  22452. updatable?: boolean;
  22453. sideOrientation?: number;
  22454. }, scene: Scene): Mesh;
  22455. /**
  22456. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22457. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22458. * * 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`)
  22459. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22460. * * 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
  22461. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22462. * * If you create a double-sided mesh, you can choose what parts of 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
  22463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22464. * @param name defines the name of the mesh
  22465. * @param options defines the options used to create the mesh
  22466. * @param scene defines the hosting scene
  22467. * @returns a new Mesh
  22468. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22469. */
  22470. static CreateIcoSphere(name: string, options: {
  22471. radius?: number;
  22472. flat?: boolean;
  22473. subdivisions?: number;
  22474. sideOrientation?: number;
  22475. updatable?: boolean;
  22476. }, scene: Scene): Mesh;
  22477. /**
  22478. * Creates a decal mesh.
  22479. * Please consider using the same method from the MeshBuilder class instead.
  22480. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22481. * @param name defines the name of the mesh
  22482. * @param sourceMesh defines the mesh receiving the decal
  22483. * @param position sets the position of the decal in world coordinates
  22484. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22485. * @param size sets the decal scaling
  22486. * @param angle sets the angle to rotate the decal
  22487. * @returns a new Mesh
  22488. */
  22489. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22490. /**
  22491. * Prepare internal position array for software CPU skinning
  22492. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22493. */
  22494. setPositionsForCPUSkinning(): Float32Array;
  22495. /**
  22496. * Prepare internal normal array for software CPU skinning
  22497. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22498. */
  22499. setNormalsForCPUSkinning(): Float32Array;
  22500. /**
  22501. * Updates the vertex buffer by applying transformation from the bones
  22502. * @param skeleton defines the skeleton to apply to current mesh
  22503. * @returns the current mesh
  22504. */
  22505. applySkeleton(skeleton: Skeleton): Mesh;
  22506. /**
  22507. * 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
  22508. * @param meshes defines the list of meshes to scan
  22509. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22510. */
  22511. static MinMax(meshes: AbstractMesh[]): {
  22512. min: Vector3;
  22513. max: Vector3;
  22514. };
  22515. /**
  22516. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22517. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22518. * @returns a vector3
  22519. */
  22520. static Center(meshesOrMinMaxVector: {
  22521. min: Vector3;
  22522. max: Vector3;
  22523. } | AbstractMesh[]): Vector3;
  22524. /**
  22525. * Merge the array of meshes into a single mesh for performance reasons.
  22526. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22527. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22528. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22529. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22530. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22531. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22532. * @returns a new mesh
  22533. */
  22534. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22535. /** @hidden */
  22536. addInstance(instance: InstancedMesh): void;
  22537. /** @hidden */
  22538. removeInstance(instance: InstancedMesh): void;
  22539. }
  22540. }
  22541. declare module "babylonjs/Materials/material" {
  22542. import { IAnimatable } from "babylonjs/Misc/tools";
  22543. import { SmartArray } from "babylonjs/Misc/smartArray";
  22544. import { Observable } from "babylonjs/Misc/observable";
  22545. import { Nullable } from "babylonjs/types";
  22546. import { Scene } from "babylonjs/scene";
  22547. import { Matrix } from "babylonjs/Maths/math";
  22548. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22550. import { Mesh } from "babylonjs/Meshes/mesh";
  22551. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22552. import { Effect } from "babylonjs/Materials/effect";
  22553. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22554. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22555. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22556. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22557. import { Animation } from "babylonjs/Animations/animation";
  22558. /**
  22559. * Base class for the main features of a material in Babylon.js
  22560. */
  22561. export class Material implements IAnimatable {
  22562. /**
  22563. * Returns the triangle fill mode
  22564. */
  22565. static readonly TriangleFillMode: number;
  22566. /**
  22567. * Returns the wireframe mode
  22568. */
  22569. static readonly WireFrameFillMode: number;
  22570. /**
  22571. * Returns the point fill mode
  22572. */
  22573. static readonly PointFillMode: number;
  22574. /**
  22575. * Returns the point list draw mode
  22576. */
  22577. static readonly PointListDrawMode: number;
  22578. /**
  22579. * Returns the line list draw mode
  22580. */
  22581. static readonly LineListDrawMode: number;
  22582. /**
  22583. * Returns the line loop draw mode
  22584. */
  22585. static readonly LineLoopDrawMode: number;
  22586. /**
  22587. * Returns the line strip draw mode
  22588. */
  22589. static readonly LineStripDrawMode: number;
  22590. /**
  22591. * Returns the triangle strip draw mode
  22592. */
  22593. static readonly TriangleStripDrawMode: number;
  22594. /**
  22595. * Returns the triangle fan draw mode
  22596. */
  22597. static readonly TriangleFanDrawMode: number;
  22598. /**
  22599. * Stores the clock-wise side orientation
  22600. */
  22601. static readonly ClockWiseSideOrientation: number;
  22602. /**
  22603. * Stores the counter clock-wise side orientation
  22604. */
  22605. static readonly CounterClockWiseSideOrientation: number;
  22606. /**
  22607. * The dirty texture flag value
  22608. */
  22609. static readonly TextureDirtyFlag: number;
  22610. /**
  22611. * The dirty light flag value
  22612. */
  22613. static readonly LightDirtyFlag: number;
  22614. /**
  22615. * The dirty fresnel flag value
  22616. */
  22617. static readonly FresnelDirtyFlag: number;
  22618. /**
  22619. * The dirty attribute flag value
  22620. */
  22621. static readonly AttributesDirtyFlag: number;
  22622. /**
  22623. * The dirty misc flag value
  22624. */
  22625. static readonly MiscDirtyFlag: number;
  22626. /**
  22627. * The all dirty flag value
  22628. */
  22629. static readonly AllDirtyFlag: number;
  22630. /**
  22631. * The ID of the material
  22632. */
  22633. id: string;
  22634. /**
  22635. * Gets or sets the unique id of the material
  22636. */
  22637. uniqueId: number;
  22638. /**
  22639. * The name of the material
  22640. */
  22641. name: string;
  22642. /**
  22643. * Gets or sets user defined metadata
  22644. */
  22645. metadata: any;
  22646. /**
  22647. * For internal use only. Please do not use.
  22648. */
  22649. reservedDataStore: any;
  22650. /**
  22651. * Specifies if the ready state should be checked on each call
  22652. */
  22653. checkReadyOnEveryCall: boolean;
  22654. /**
  22655. * Specifies if the ready state should be checked once
  22656. */
  22657. checkReadyOnlyOnce: boolean;
  22658. /**
  22659. * The state of the material
  22660. */
  22661. state: string;
  22662. /**
  22663. * The alpha value of the material
  22664. */
  22665. protected _alpha: number;
  22666. /**
  22667. * List of inspectable custom properties (used by the Inspector)
  22668. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22669. */
  22670. inspectableCustomProperties: IInspectable[];
  22671. /**
  22672. * Sets the alpha value of the material
  22673. */
  22674. /**
  22675. * Gets the alpha value of the material
  22676. */
  22677. alpha: number;
  22678. /**
  22679. * Specifies if back face culling is enabled
  22680. */
  22681. protected _backFaceCulling: boolean;
  22682. /**
  22683. * Sets the back-face culling state
  22684. */
  22685. /**
  22686. * Gets the back-face culling state
  22687. */
  22688. backFaceCulling: boolean;
  22689. /**
  22690. * Stores the value for side orientation
  22691. */
  22692. sideOrientation: number;
  22693. /**
  22694. * Callback triggered when the material is compiled
  22695. */
  22696. onCompiled: Nullable<(effect: Effect) => void>;
  22697. /**
  22698. * Callback triggered when an error occurs
  22699. */
  22700. onError: Nullable<(effect: Effect, errors: string) => void>;
  22701. /**
  22702. * Callback triggered to get the render target textures
  22703. */
  22704. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22705. /**
  22706. * Gets a boolean indicating that current material needs to register RTT
  22707. */
  22708. readonly hasRenderTargetTextures: boolean;
  22709. /**
  22710. * Specifies if the material should be serialized
  22711. */
  22712. doNotSerialize: boolean;
  22713. /**
  22714. * @hidden
  22715. */
  22716. _storeEffectOnSubMeshes: boolean;
  22717. /**
  22718. * Stores the animations for the material
  22719. */
  22720. animations: Nullable<Array<Animation>>;
  22721. /**
  22722. * An event triggered when the material is disposed
  22723. */
  22724. onDisposeObservable: Observable<Material>;
  22725. /**
  22726. * An observer which watches for dispose events
  22727. */
  22728. private _onDisposeObserver;
  22729. private _onUnBindObservable;
  22730. /**
  22731. * Called during a dispose event
  22732. */
  22733. onDispose: () => void;
  22734. private _onBindObservable;
  22735. /**
  22736. * An event triggered when the material is bound
  22737. */
  22738. readonly onBindObservable: Observable<AbstractMesh>;
  22739. /**
  22740. * An observer which watches for bind events
  22741. */
  22742. private _onBindObserver;
  22743. /**
  22744. * Called during a bind event
  22745. */
  22746. onBind: (Mesh: AbstractMesh) => void;
  22747. /**
  22748. * An event triggered when the material is unbound
  22749. */
  22750. readonly onUnBindObservable: Observable<Material>;
  22751. /**
  22752. * Stores the value of the alpha mode
  22753. */
  22754. private _alphaMode;
  22755. /**
  22756. * Sets the value of the alpha mode.
  22757. *
  22758. * | Value | Type | Description |
  22759. * | --- | --- | --- |
  22760. * | 0 | ALPHA_DISABLE | |
  22761. * | 1 | ALPHA_ADD | |
  22762. * | 2 | ALPHA_COMBINE | |
  22763. * | 3 | ALPHA_SUBTRACT | |
  22764. * | 4 | ALPHA_MULTIPLY | |
  22765. * | 5 | ALPHA_MAXIMIZED | |
  22766. * | 6 | ALPHA_ONEONE | |
  22767. * | 7 | ALPHA_PREMULTIPLIED | |
  22768. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22769. * | 9 | ALPHA_INTERPOLATE | |
  22770. * | 10 | ALPHA_SCREENMODE | |
  22771. *
  22772. */
  22773. /**
  22774. * Gets the value of the alpha mode
  22775. */
  22776. alphaMode: number;
  22777. /**
  22778. * Stores the state of the need depth pre-pass value
  22779. */
  22780. private _needDepthPrePass;
  22781. /**
  22782. * Sets the need depth pre-pass value
  22783. */
  22784. /**
  22785. * Gets the depth pre-pass value
  22786. */
  22787. needDepthPrePass: boolean;
  22788. /**
  22789. * Specifies if depth writing should be disabled
  22790. */
  22791. disableDepthWrite: boolean;
  22792. /**
  22793. * Specifies if depth writing should be forced
  22794. */
  22795. forceDepthWrite: boolean;
  22796. /**
  22797. * Specifies if there should be a separate pass for culling
  22798. */
  22799. separateCullingPass: boolean;
  22800. /**
  22801. * Stores the state specifing if fog should be enabled
  22802. */
  22803. private _fogEnabled;
  22804. /**
  22805. * Sets the state for enabling fog
  22806. */
  22807. /**
  22808. * Gets the value of the fog enabled state
  22809. */
  22810. fogEnabled: boolean;
  22811. /**
  22812. * Stores the size of points
  22813. */
  22814. pointSize: number;
  22815. /**
  22816. * Stores the z offset value
  22817. */
  22818. zOffset: number;
  22819. /**
  22820. * Gets a value specifying if wireframe mode is enabled
  22821. */
  22822. /**
  22823. * Sets the state of wireframe mode
  22824. */
  22825. wireframe: boolean;
  22826. /**
  22827. * Gets the value specifying if point clouds are enabled
  22828. */
  22829. /**
  22830. * Sets the state of point cloud mode
  22831. */
  22832. pointsCloud: boolean;
  22833. /**
  22834. * Gets the material fill mode
  22835. */
  22836. /**
  22837. * Sets the material fill mode
  22838. */
  22839. fillMode: number;
  22840. /**
  22841. * @hidden
  22842. * Stores the effects for the material
  22843. */
  22844. _effect: Nullable<Effect>;
  22845. /**
  22846. * @hidden
  22847. * Specifies if the material was previously ready
  22848. */
  22849. _wasPreviouslyReady: boolean;
  22850. /**
  22851. * Specifies if uniform buffers should be used
  22852. */
  22853. private _useUBO;
  22854. /**
  22855. * Stores a reference to the scene
  22856. */
  22857. private _scene;
  22858. /**
  22859. * Stores the fill mode state
  22860. */
  22861. private _fillMode;
  22862. /**
  22863. * Specifies if the depth write state should be cached
  22864. */
  22865. private _cachedDepthWriteState;
  22866. /**
  22867. * Stores the uniform buffer
  22868. */
  22869. protected _uniformBuffer: UniformBuffer;
  22870. /** @hidden */
  22871. _indexInSceneMaterialArray: number;
  22872. /** @hidden */
  22873. meshMap: Nullable<{
  22874. [id: string]: AbstractMesh | undefined;
  22875. }>;
  22876. /**
  22877. * Creates a material instance
  22878. * @param name defines the name of the material
  22879. * @param scene defines the scene to reference
  22880. * @param doNotAdd specifies if the material should be added to the scene
  22881. */
  22882. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22883. /**
  22884. * Returns a string representation of the current material
  22885. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22886. * @returns a string with material information
  22887. */
  22888. toString(fullDetails?: boolean): string;
  22889. /**
  22890. * Gets the class name of the material
  22891. * @returns a string with the class name of the material
  22892. */
  22893. getClassName(): string;
  22894. /**
  22895. * Specifies if updates for the material been locked
  22896. */
  22897. readonly isFrozen: boolean;
  22898. /**
  22899. * Locks updates for the material
  22900. */
  22901. freeze(): void;
  22902. /**
  22903. * Unlocks updates for the material
  22904. */
  22905. unfreeze(): void;
  22906. /**
  22907. * Specifies if the material is ready to be used
  22908. * @param mesh defines the mesh to check
  22909. * @param useInstances specifies if instances should be used
  22910. * @returns a boolean indicating if the material is ready to be used
  22911. */
  22912. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22913. /**
  22914. * Specifies that the submesh is ready to be used
  22915. * @param mesh defines the mesh to check
  22916. * @param subMesh defines which submesh to check
  22917. * @param useInstances specifies that instances should be used
  22918. * @returns a boolean indicating that the submesh is ready or not
  22919. */
  22920. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22921. /**
  22922. * Returns the material effect
  22923. * @returns the effect associated with the material
  22924. */
  22925. getEffect(): Nullable<Effect>;
  22926. /**
  22927. * Returns the current scene
  22928. * @returns a Scene
  22929. */
  22930. getScene(): Scene;
  22931. /**
  22932. * Specifies if the material will require alpha blending
  22933. * @returns a boolean specifying if alpha blending is needed
  22934. */
  22935. needAlphaBlending(): boolean;
  22936. /**
  22937. * Specifies if the mesh will require alpha blending
  22938. * @param mesh defines the mesh to check
  22939. * @returns a boolean specifying if alpha blending is needed for the mesh
  22940. */
  22941. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22942. /**
  22943. * Specifies if this material should be rendered in alpha test mode
  22944. * @returns a boolean specifying if an alpha test is needed.
  22945. */
  22946. needAlphaTesting(): boolean;
  22947. /**
  22948. * Gets the texture used for the alpha test
  22949. * @returns the texture to use for alpha testing
  22950. */
  22951. getAlphaTestTexture(): Nullable<BaseTexture>;
  22952. /**
  22953. * Marks the material to indicate that it needs to be re-calculated
  22954. */
  22955. markDirty(): void;
  22956. /** @hidden */
  22957. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22958. /**
  22959. * Binds the material to the mesh
  22960. * @param world defines the world transformation matrix
  22961. * @param mesh defines the mesh to bind the material to
  22962. */
  22963. bind(world: Matrix, mesh?: Mesh): void;
  22964. /**
  22965. * Binds the submesh to the material
  22966. * @param world defines the world transformation matrix
  22967. * @param mesh defines the mesh containing the submesh
  22968. * @param subMesh defines the submesh to bind the material to
  22969. */
  22970. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22971. /**
  22972. * Binds the world matrix to the material
  22973. * @param world defines the world transformation matrix
  22974. */
  22975. bindOnlyWorldMatrix(world: Matrix): void;
  22976. /**
  22977. * Binds the scene's uniform buffer to the effect.
  22978. * @param effect defines the effect to bind to the scene uniform buffer
  22979. * @param sceneUbo defines the uniform buffer storing scene data
  22980. */
  22981. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22982. /**
  22983. * Binds the view matrix to the effect
  22984. * @param effect defines the effect to bind the view matrix to
  22985. */
  22986. bindView(effect: Effect): void;
  22987. /**
  22988. * Binds the view projection matrix to the effect
  22989. * @param effect defines the effect to bind the view projection matrix to
  22990. */
  22991. bindViewProjection(effect: Effect): void;
  22992. /**
  22993. * Specifies if material alpha testing should be turned on for the mesh
  22994. * @param mesh defines the mesh to check
  22995. */
  22996. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22997. /**
  22998. * Processes to execute after binding the material to a mesh
  22999. * @param mesh defines the rendered mesh
  23000. */
  23001. protected _afterBind(mesh?: Mesh): void;
  23002. /**
  23003. * Unbinds the material from the mesh
  23004. */
  23005. unbind(): void;
  23006. /**
  23007. * Gets the active textures from the material
  23008. * @returns an array of textures
  23009. */
  23010. getActiveTextures(): BaseTexture[];
  23011. /**
  23012. * Specifies if the material uses a texture
  23013. * @param texture defines the texture to check against the material
  23014. * @returns a boolean specifying if the material uses the texture
  23015. */
  23016. hasTexture(texture: BaseTexture): boolean;
  23017. /**
  23018. * Makes a duplicate of the material, and gives it a new name
  23019. * @param name defines the new name for the duplicated material
  23020. * @returns the cloned material
  23021. */
  23022. clone(name: string): Nullable<Material>;
  23023. /**
  23024. * Gets the meshes bound to the material
  23025. * @returns an array of meshes bound to the material
  23026. */
  23027. getBindedMeshes(): AbstractMesh[];
  23028. /**
  23029. * Force shader compilation
  23030. * @param mesh defines the mesh associated with this material
  23031. * @param onCompiled defines a function to execute once the material is compiled
  23032. * @param options defines the options to configure the compilation
  23033. */
  23034. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23035. clipPlane: boolean;
  23036. }>): void;
  23037. /**
  23038. * Force shader compilation
  23039. * @param mesh defines the mesh that will use this material
  23040. * @param options defines additional options for compiling the shaders
  23041. * @returns a promise that resolves when the compilation completes
  23042. */
  23043. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23044. clipPlane: boolean;
  23045. }>): Promise<void>;
  23046. private static readonly _ImageProcessingDirtyCallBack;
  23047. private static readonly _TextureDirtyCallBack;
  23048. private static readonly _FresnelDirtyCallBack;
  23049. private static readonly _MiscDirtyCallBack;
  23050. private static readonly _LightsDirtyCallBack;
  23051. private static readonly _AttributeDirtyCallBack;
  23052. private static _FresnelAndMiscDirtyCallBack;
  23053. private static _TextureAndMiscDirtyCallBack;
  23054. private static readonly _DirtyCallbackArray;
  23055. private static readonly _RunDirtyCallBacks;
  23056. /**
  23057. * Marks a define in the material to indicate that it needs to be re-computed
  23058. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23059. */
  23060. markAsDirty(flag: number): void;
  23061. /**
  23062. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23063. * @param func defines a function which checks material defines against the submeshes
  23064. */
  23065. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23066. /**
  23067. * Indicates that image processing needs to be re-calculated for all submeshes
  23068. */
  23069. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23070. /**
  23071. * Indicates that textures need to be re-calculated for all submeshes
  23072. */
  23073. protected _markAllSubMeshesAsTexturesDirty(): void;
  23074. /**
  23075. * Indicates that fresnel needs to be re-calculated for all submeshes
  23076. */
  23077. protected _markAllSubMeshesAsFresnelDirty(): void;
  23078. /**
  23079. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23080. */
  23081. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23082. /**
  23083. * Indicates that lights need to be re-calculated for all submeshes
  23084. */
  23085. protected _markAllSubMeshesAsLightsDirty(): void;
  23086. /**
  23087. * Indicates that attributes need to be re-calculated for all submeshes
  23088. */
  23089. protected _markAllSubMeshesAsAttributesDirty(): void;
  23090. /**
  23091. * Indicates that misc needs to be re-calculated for all submeshes
  23092. */
  23093. protected _markAllSubMeshesAsMiscDirty(): void;
  23094. /**
  23095. * Indicates that textures and misc need to be re-calculated for all submeshes
  23096. */
  23097. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23098. /**
  23099. * Disposes the material
  23100. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23101. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23102. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23103. */
  23104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23105. /** @hidden */
  23106. private releaseVertexArrayObject;
  23107. /**
  23108. * Serializes this material
  23109. * @returns the serialized material object
  23110. */
  23111. serialize(): any;
  23112. /**
  23113. * Creates a material from parsed material data
  23114. * @param parsedMaterial defines parsed material data
  23115. * @param scene defines the hosting scene
  23116. * @param rootUrl defines the root URL to use to load textures
  23117. * @returns a new material
  23118. */
  23119. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23120. }
  23121. }
  23122. declare module "babylonjs/Meshes/subMesh" {
  23123. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23124. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23125. import { Engine } from "babylonjs/Engines/engine";
  23126. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23127. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23128. import { Effect } from "babylonjs/Materials/effect";
  23129. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23130. import { Collider } from "babylonjs/Collisions/collider";
  23131. import { Material } from "babylonjs/Materials/material";
  23132. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23134. import { Mesh } from "babylonjs/Meshes/mesh";
  23135. import { Ray } from "babylonjs/Culling/ray";
  23136. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23137. /**
  23138. * Base class for submeshes
  23139. */
  23140. export class BaseSubMesh {
  23141. /** @hidden */
  23142. _materialDefines: Nullable<MaterialDefines>;
  23143. /** @hidden */
  23144. _materialEffect: Nullable<Effect>;
  23145. /**
  23146. * Gets associated effect
  23147. */
  23148. readonly effect: Nullable<Effect>;
  23149. /**
  23150. * Sets associated effect (effect used to render this submesh)
  23151. * @param effect defines the effect to associate with
  23152. * @param defines defines the set of defines used to compile this effect
  23153. */
  23154. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23155. }
  23156. /**
  23157. * Defines a subdivision inside a mesh
  23158. */
  23159. export class SubMesh extends BaseSubMesh implements ICullable {
  23160. /** the material index to use */
  23161. materialIndex: number;
  23162. /** vertex index start */
  23163. verticesStart: number;
  23164. /** vertices count */
  23165. verticesCount: number;
  23166. /** index start */
  23167. indexStart: number;
  23168. /** indices count */
  23169. indexCount: number;
  23170. /** @hidden */
  23171. _linesIndexCount: number;
  23172. private _mesh;
  23173. private _renderingMesh;
  23174. private _boundingInfo;
  23175. private _linesIndexBuffer;
  23176. /** @hidden */
  23177. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23178. /** @hidden */
  23179. _trianglePlanes: Plane[];
  23180. /** @hidden */
  23181. _lastColliderTransformMatrix: Nullable<Matrix>;
  23182. /** @hidden */
  23183. _renderId: number;
  23184. /** @hidden */
  23185. _alphaIndex: number;
  23186. /** @hidden */
  23187. _distanceToCamera: number;
  23188. /** @hidden */
  23189. _id: number;
  23190. private _currentMaterial;
  23191. /**
  23192. * Add a new submesh to a mesh
  23193. * @param materialIndex defines the material index to use
  23194. * @param verticesStart defines vertex index start
  23195. * @param verticesCount defines vertices count
  23196. * @param indexStart defines index start
  23197. * @param indexCount defines indices count
  23198. * @param mesh defines the parent mesh
  23199. * @param renderingMesh defines an optional rendering mesh
  23200. * @param createBoundingBox defines if bounding box should be created for this submesh
  23201. * @returns the new submesh
  23202. */
  23203. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23204. /**
  23205. * Creates a new submesh
  23206. * @param materialIndex defines the material index to use
  23207. * @param verticesStart defines vertex index start
  23208. * @param verticesCount defines vertices count
  23209. * @param indexStart defines index start
  23210. * @param indexCount defines indices count
  23211. * @param mesh defines the parent mesh
  23212. * @param renderingMesh defines an optional rendering mesh
  23213. * @param createBoundingBox defines if bounding box should be created for this submesh
  23214. */
  23215. constructor(
  23216. /** the material index to use */
  23217. materialIndex: number,
  23218. /** vertex index start */
  23219. verticesStart: number,
  23220. /** vertices count */
  23221. verticesCount: number,
  23222. /** index start */
  23223. indexStart: number,
  23224. /** indices count */
  23225. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23226. /**
  23227. * Returns true if this submesh covers the entire parent mesh
  23228. * @ignorenaming
  23229. */
  23230. readonly IsGlobal: boolean;
  23231. /**
  23232. * Returns the submesh BoudingInfo object
  23233. * @returns current bounding info (or mesh's one if the submesh is global)
  23234. */
  23235. getBoundingInfo(): BoundingInfo;
  23236. /**
  23237. * Sets the submesh BoundingInfo
  23238. * @param boundingInfo defines the new bounding info to use
  23239. * @returns the SubMesh
  23240. */
  23241. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23242. /**
  23243. * Returns the mesh of the current submesh
  23244. * @return the parent mesh
  23245. */
  23246. getMesh(): AbstractMesh;
  23247. /**
  23248. * Returns the rendering mesh of the submesh
  23249. * @returns the rendering mesh (could be different from parent mesh)
  23250. */
  23251. getRenderingMesh(): Mesh;
  23252. /**
  23253. * Returns the submesh material
  23254. * @returns null or the current material
  23255. */
  23256. getMaterial(): Nullable<Material>;
  23257. /**
  23258. * Sets a new updated BoundingInfo object to the submesh
  23259. * @param data defines an optional position array to use to determine the bounding info
  23260. * @returns the SubMesh
  23261. */
  23262. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23263. /** @hidden */
  23264. _checkCollision(collider: Collider): boolean;
  23265. /**
  23266. * Updates the submesh BoundingInfo
  23267. * @param world defines the world matrix to use to update the bounding info
  23268. * @returns the submesh
  23269. */
  23270. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23271. /**
  23272. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23273. * @param frustumPlanes defines the frustum planes
  23274. * @returns true if the submesh is intersecting with the frustum
  23275. */
  23276. isInFrustum(frustumPlanes: Plane[]): boolean;
  23277. /**
  23278. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23279. * @param frustumPlanes defines the frustum planes
  23280. * @returns true if the submesh is inside the frustum
  23281. */
  23282. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23283. /**
  23284. * Renders the submesh
  23285. * @param enableAlphaMode defines if alpha needs to be used
  23286. * @returns the submesh
  23287. */
  23288. render(enableAlphaMode: boolean): SubMesh;
  23289. /**
  23290. * @hidden
  23291. */
  23292. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23293. /**
  23294. * Checks if the submesh intersects with a ray
  23295. * @param ray defines the ray to test
  23296. * @returns true is the passed ray intersects the submesh bounding box
  23297. */
  23298. canIntersects(ray: Ray): boolean;
  23299. /**
  23300. * Intersects current submesh with a ray
  23301. * @param ray defines the ray to test
  23302. * @param positions defines mesh's positions array
  23303. * @param indices defines mesh's indices array
  23304. * @param fastCheck defines if only bounding info should be used
  23305. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23306. * @returns intersection info or null if no intersection
  23307. */
  23308. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23309. /** @hidden */
  23310. private _intersectLines;
  23311. /** @hidden */
  23312. private _intersectTriangles;
  23313. /** @hidden */
  23314. _rebuild(): void;
  23315. /**
  23316. * Creates a new submesh from the passed mesh
  23317. * @param newMesh defines the new hosting mesh
  23318. * @param newRenderingMesh defines an optional rendering mesh
  23319. * @returns the new submesh
  23320. */
  23321. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23322. /**
  23323. * Release associated resources
  23324. */
  23325. dispose(): void;
  23326. /**
  23327. * Gets the class name
  23328. * @returns the string "SubMesh".
  23329. */
  23330. getClassName(): string;
  23331. /**
  23332. * Creates a new submesh from indices data
  23333. * @param materialIndex the index of the main mesh material
  23334. * @param startIndex the index where to start the copy in the mesh indices array
  23335. * @param indexCount the number of indices to copy then from the startIndex
  23336. * @param mesh the main mesh to create the submesh from
  23337. * @param renderingMesh the optional rendering mesh
  23338. * @returns a new submesh
  23339. */
  23340. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23341. }
  23342. }
  23343. declare module "babylonjs/Meshes/geometry" {
  23344. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23345. import { Scene } from "babylonjs/scene";
  23346. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23347. import { Engine } from "babylonjs/Engines/engine";
  23348. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23349. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23350. import { Effect } from "babylonjs/Materials/effect";
  23351. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23352. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23353. import { Mesh } from "babylonjs/Meshes/mesh";
  23354. /**
  23355. * Class used to store geometry data (vertex buffers + index buffer)
  23356. */
  23357. export class Geometry implements IGetSetVerticesData {
  23358. /**
  23359. * Gets or sets the ID of the geometry
  23360. */
  23361. id: string;
  23362. /**
  23363. * Gets or sets the unique ID of the geometry
  23364. */
  23365. uniqueId: number;
  23366. /**
  23367. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23368. */
  23369. delayLoadState: number;
  23370. /**
  23371. * Gets the file containing the data to load when running in delay load state
  23372. */
  23373. delayLoadingFile: Nullable<string>;
  23374. /**
  23375. * Callback called when the geometry is updated
  23376. */
  23377. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23378. private _scene;
  23379. private _engine;
  23380. private _meshes;
  23381. private _totalVertices;
  23382. /** @hidden */
  23383. _indices: IndicesArray;
  23384. /** @hidden */
  23385. _vertexBuffers: {
  23386. [key: string]: VertexBuffer;
  23387. };
  23388. private _isDisposed;
  23389. private _extend;
  23390. private _boundingBias;
  23391. /** @hidden */
  23392. _delayInfo: Array<string>;
  23393. private _indexBuffer;
  23394. private _indexBufferIsUpdatable;
  23395. /** @hidden */
  23396. _boundingInfo: Nullable<BoundingInfo>;
  23397. /** @hidden */
  23398. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23399. /** @hidden */
  23400. _softwareSkinningFrameId: number;
  23401. private _vertexArrayObjects;
  23402. private _updatable;
  23403. /** @hidden */
  23404. _positions: Nullable<Vector3[]>;
  23405. /**
  23406. * 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
  23407. */
  23408. /**
  23409. * 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
  23410. */
  23411. boundingBias: Vector2;
  23412. /**
  23413. * Static function used to attach a new empty geometry to a mesh
  23414. * @param mesh defines the mesh to attach the geometry to
  23415. * @returns the new Geometry
  23416. */
  23417. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23418. /**
  23419. * Creates a new geometry
  23420. * @param id defines the unique ID
  23421. * @param scene defines the hosting scene
  23422. * @param vertexData defines the VertexData used to get geometry data
  23423. * @param updatable defines if geometry must be updatable (false by default)
  23424. * @param mesh defines the mesh that will be associated with the geometry
  23425. */
  23426. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23427. /**
  23428. * Gets the current extend of the geometry
  23429. */
  23430. readonly extend: {
  23431. minimum: Vector3;
  23432. maximum: Vector3;
  23433. };
  23434. /**
  23435. * Gets the hosting scene
  23436. * @returns the hosting Scene
  23437. */
  23438. getScene(): Scene;
  23439. /**
  23440. * Gets the hosting engine
  23441. * @returns the hosting Engine
  23442. */
  23443. getEngine(): Engine;
  23444. /**
  23445. * Defines if the geometry is ready to use
  23446. * @returns true if the geometry is ready to be used
  23447. */
  23448. isReady(): boolean;
  23449. /**
  23450. * Gets a value indicating that the geometry should not be serialized
  23451. */
  23452. readonly doNotSerialize: boolean;
  23453. /** @hidden */
  23454. _rebuild(): void;
  23455. /**
  23456. * Affects all geometry data in one call
  23457. * @param vertexData defines the geometry data
  23458. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23459. */
  23460. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23461. /**
  23462. * Set specific vertex data
  23463. * @param kind defines the data kind (Position, normal, etc...)
  23464. * @param data defines the vertex data to use
  23465. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23466. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23467. */
  23468. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23469. /**
  23470. * Removes a specific vertex data
  23471. * @param kind defines the data kind (Position, normal, etc...)
  23472. */
  23473. removeVerticesData(kind: string): void;
  23474. /**
  23475. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23476. * @param buffer defines the vertex buffer to use
  23477. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23478. */
  23479. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23480. /**
  23481. * Update a specific vertex buffer
  23482. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23483. * It will do nothing if the buffer is not updatable
  23484. * @param kind defines the data kind (Position, normal, etc...)
  23485. * @param data defines the data to use
  23486. * @param offset defines the offset in the target buffer where to store the data
  23487. * @param useBytes set to true if the offset is in bytes
  23488. */
  23489. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23490. /**
  23491. * Update a specific vertex buffer
  23492. * This function will create a new buffer if the current one is not updatable
  23493. * @param kind defines the data kind (Position, normal, etc...)
  23494. * @param data defines the data to use
  23495. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23496. */
  23497. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23498. private _updateBoundingInfo;
  23499. /** @hidden */
  23500. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23501. /**
  23502. * Gets total number of vertices
  23503. * @returns the total number of vertices
  23504. */
  23505. getTotalVertices(): number;
  23506. /**
  23507. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23508. * @param kind defines the data kind (Position, normal, etc...)
  23509. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23510. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23511. * @returns a float array containing vertex data
  23512. */
  23513. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23514. /**
  23515. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23516. * @param kind defines the data kind (Position, normal, etc...)
  23517. * @returns true if the vertex buffer with the specified kind is updatable
  23518. */
  23519. isVertexBufferUpdatable(kind: string): boolean;
  23520. /**
  23521. * Gets a specific vertex buffer
  23522. * @param kind defines the data kind (Position, normal, etc...)
  23523. * @returns a VertexBuffer
  23524. */
  23525. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23526. /**
  23527. * Returns all vertex buffers
  23528. * @return an object holding all vertex buffers indexed by kind
  23529. */
  23530. getVertexBuffers(): Nullable<{
  23531. [key: string]: VertexBuffer;
  23532. }>;
  23533. /**
  23534. * Gets a boolean indicating if specific vertex buffer is present
  23535. * @param kind defines the data kind (Position, normal, etc...)
  23536. * @returns true if data is present
  23537. */
  23538. isVerticesDataPresent(kind: string): boolean;
  23539. /**
  23540. * Gets a list of all attached data kinds (Position, normal, etc...)
  23541. * @returns a list of string containing all kinds
  23542. */
  23543. getVerticesDataKinds(): string[];
  23544. /**
  23545. * Update index buffer
  23546. * @param indices defines the indices to store in the index buffer
  23547. * @param offset defines the offset in the target buffer where to store the data
  23548. * @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)
  23549. */
  23550. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23551. /**
  23552. * Creates a new index buffer
  23553. * @param indices defines the indices to store in the index buffer
  23554. * @param totalVertices defines the total number of vertices (could be null)
  23555. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23556. */
  23557. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23558. /**
  23559. * Return the total number of indices
  23560. * @returns the total number of indices
  23561. */
  23562. getTotalIndices(): number;
  23563. /**
  23564. * Gets the index buffer array
  23565. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23566. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23567. * @returns the index buffer array
  23568. */
  23569. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23570. /**
  23571. * Gets the index buffer
  23572. * @return the index buffer
  23573. */
  23574. getIndexBuffer(): Nullable<DataBuffer>;
  23575. /** @hidden */
  23576. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23577. /**
  23578. * Release the associated resources for a specific mesh
  23579. * @param mesh defines the source mesh
  23580. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23581. */
  23582. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23583. /**
  23584. * Apply current geometry to a given mesh
  23585. * @param mesh defines the mesh to apply geometry to
  23586. */
  23587. applyToMesh(mesh: Mesh): void;
  23588. private _updateExtend;
  23589. private _applyToMesh;
  23590. private notifyUpdate;
  23591. /**
  23592. * Load the geometry if it was flagged as delay loaded
  23593. * @param scene defines the hosting scene
  23594. * @param onLoaded defines a callback called when the geometry is loaded
  23595. */
  23596. load(scene: Scene, onLoaded?: () => void): void;
  23597. private _queueLoad;
  23598. /**
  23599. * Invert the geometry to move from a right handed system to a left handed one.
  23600. */
  23601. toLeftHanded(): void;
  23602. /** @hidden */
  23603. _resetPointsArrayCache(): void;
  23604. /** @hidden */
  23605. _generatePointsArray(): boolean;
  23606. /**
  23607. * Gets a value indicating if the geometry is disposed
  23608. * @returns true if the geometry was disposed
  23609. */
  23610. isDisposed(): boolean;
  23611. private _disposeVertexArrayObjects;
  23612. /**
  23613. * Free all associated resources
  23614. */
  23615. dispose(): void;
  23616. /**
  23617. * Clone the current geometry into a new geometry
  23618. * @param id defines the unique ID of the new geometry
  23619. * @returns a new geometry object
  23620. */
  23621. copy(id: string): Geometry;
  23622. /**
  23623. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23624. * @return a JSON representation of the current geometry data (without the vertices data)
  23625. */
  23626. serialize(): any;
  23627. private toNumberArray;
  23628. /**
  23629. * Serialize all vertices data into a JSON oject
  23630. * @returns a JSON representation of the current geometry data
  23631. */
  23632. serializeVerticeData(): any;
  23633. /**
  23634. * Extracts a clone of a mesh geometry
  23635. * @param mesh defines the source mesh
  23636. * @param id defines the unique ID of the new geometry object
  23637. * @returns the new geometry object
  23638. */
  23639. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23640. /**
  23641. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23642. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23643. * Be aware Math.random() could cause collisions, but:
  23644. * "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"
  23645. * @returns a string containing a new GUID
  23646. */
  23647. static RandomId(): string;
  23648. /** @hidden */
  23649. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23650. private static _CleanMatricesWeights;
  23651. /**
  23652. * Create a new geometry from persisted data (Using .babylon file format)
  23653. * @param parsedVertexData defines the persisted data
  23654. * @param scene defines the hosting scene
  23655. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23656. * @returns the new geometry object
  23657. */
  23658. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23659. }
  23660. }
  23661. declare module "babylonjs/Meshes/mesh.vertexData" {
  23662. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23663. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23664. import { Geometry } from "babylonjs/Meshes/geometry";
  23665. import { Mesh } from "babylonjs/Meshes/mesh";
  23666. /**
  23667. * Define an interface for all classes that will get and set the data on vertices
  23668. */
  23669. export interface IGetSetVerticesData {
  23670. /**
  23671. * Gets a boolean indicating if specific vertex data is present
  23672. * @param kind defines the vertex data kind to use
  23673. * @returns true is data kind is present
  23674. */
  23675. isVerticesDataPresent(kind: string): boolean;
  23676. /**
  23677. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23678. * @param kind defines the data kind (Position, normal, etc...)
  23679. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23680. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23681. * @returns a float array containing vertex data
  23682. */
  23683. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23684. /**
  23685. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23686. * @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.
  23687. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23688. * @returns the indices array or an empty array if the mesh has no geometry
  23689. */
  23690. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23691. /**
  23692. * Set specific vertex data
  23693. * @param kind defines the data kind (Position, normal, etc...)
  23694. * @param data defines the vertex data to use
  23695. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23696. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23697. */
  23698. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23699. /**
  23700. * Update a specific associated vertex buffer
  23701. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23702. * - VertexBuffer.PositionKind
  23703. * - VertexBuffer.UVKind
  23704. * - VertexBuffer.UV2Kind
  23705. * - VertexBuffer.UV3Kind
  23706. * - VertexBuffer.UV4Kind
  23707. * - VertexBuffer.UV5Kind
  23708. * - VertexBuffer.UV6Kind
  23709. * - VertexBuffer.ColorKind
  23710. * - VertexBuffer.MatricesIndicesKind
  23711. * - VertexBuffer.MatricesIndicesExtraKind
  23712. * - VertexBuffer.MatricesWeightsKind
  23713. * - VertexBuffer.MatricesWeightsExtraKind
  23714. * @param data defines the data source
  23715. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23716. * @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)
  23717. */
  23718. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23719. /**
  23720. * Creates a new index buffer
  23721. * @param indices defines the indices to store in the index buffer
  23722. * @param totalVertices defines the total number of vertices (could be null)
  23723. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23724. */
  23725. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23726. }
  23727. /**
  23728. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23729. */
  23730. export class VertexData {
  23731. /**
  23732. * Mesh side orientation : usually the external or front surface
  23733. */
  23734. static readonly FRONTSIDE: number;
  23735. /**
  23736. * Mesh side orientation : usually the internal or back surface
  23737. */
  23738. static readonly BACKSIDE: number;
  23739. /**
  23740. * Mesh side orientation : both internal and external or front and back surfaces
  23741. */
  23742. static readonly DOUBLESIDE: number;
  23743. /**
  23744. * Mesh side orientation : by default, `FRONTSIDE`
  23745. */
  23746. static readonly DEFAULTSIDE: number;
  23747. /**
  23748. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23749. */
  23750. positions: Nullable<FloatArray>;
  23751. /**
  23752. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23753. */
  23754. normals: Nullable<FloatArray>;
  23755. /**
  23756. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23757. */
  23758. tangents: Nullable<FloatArray>;
  23759. /**
  23760. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23761. */
  23762. uvs: Nullable<FloatArray>;
  23763. /**
  23764. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23765. */
  23766. uvs2: Nullable<FloatArray>;
  23767. /**
  23768. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23769. */
  23770. uvs3: Nullable<FloatArray>;
  23771. /**
  23772. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23773. */
  23774. uvs4: Nullable<FloatArray>;
  23775. /**
  23776. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23777. */
  23778. uvs5: Nullable<FloatArray>;
  23779. /**
  23780. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23781. */
  23782. uvs6: Nullable<FloatArray>;
  23783. /**
  23784. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23785. */
  23786. colors: Nullable<FloatArray>;
  23787. /**
  23788. * 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).
  23789. */
  23790. matricesIndices: Nullable<FloatArray>;
  23791. /**
  23792. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23793. */
  23794. matricesWeights: Nullable<FloatArray>;
  23795. /**
  23796. * An array extending the number of possible indices
  23797. */
  23798. matricesIndicesExtra: Nullable<FloatArray>;
  23799. /**
  23800. * An array extending the number of possible weights when the number of indices is extended
  23801. */
  23802. matricesWeightsExtra: Nullable<FloatArray>;
  23803. /**
  23804. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23805. */
  23806. indices: Nullable<IndicesArray>;
  23807. /**
  23808. * Uses the passed data array to set the set the values for the specified kind of data
  23809. * @param data a linear array of floating numbers
  23810. * @param kind the type of data that is being set, eg positions, colors etc
  23811. */
  23812. set(data: FloatArray, kind: string): void;
  23813. /**
  23814. * Associates the vertexData to the passed Mesh.
  23815. * Sets it as updatable or not (default `false`)
  23816. * @param mesh the mesh the vertexData is applied to
  23817. * @param updatable when used and having the value true allows new data to update the vertexData
  23818. * @returns the VertexData
  23819. */
  23820. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23821. /**
  23822. * Associates the vertexData to the passed Geometry.
  23823. * Sets it as updatable or not (default `false`)
  23824. * @param geometry the geometry the vertexData is applied to
  23825. * @param updatable when used and having the value true allows new data to update the vertexData
  23826. * @returns VertexData
  23827. */
  23828. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23829. /**
  23830. * Updates the associated mesh
  23831. * @param mesh the mesh to be updated
  23832. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23833. * @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
  23834. * @returns VertexData
  23835. */
  23836. updateMesh(mesh: Mesh): VertexData;
  23837. /**
  23838. * Updates the associated geometry
  23839. * @param geometry the geometry to be updated
  23840. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23841. * @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
  23842. * @returns VertexData.
  23843. */
  23844. updateGeometry(geometry: Geometry): VertexData;
  23845. private _applyTo;
  23846. private _update;
  23847. /**
  23848. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23849. * @param matrix the transforming matrix
  23850. * @returns the VertexData
  23851. */
  23852. transform(matrix: Matrix): VertexData;
  23853. /**
  23854. * Merges the passed VertexData into the current one
  23855. * @param other the VertexData to be merged into the current one
  23856. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23857. * @returns the modified VertexData
  23858. */
  23859. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23860. private _mergeElement;
  23861. private _validate;
  23862. /**
  23863. * Serializes the VertexData
  23864. * @returns a serialized object
  23865. */
  23866. serialize(): any;
  23867. /**
  23868. * Extracts the vertexData from a mesh
  23869. * @param mesh the mesh from which to extract the VertexData
  23870. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23871. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23872. * @returns the object VertexData associated to the passed mesh
  23873. */
  23874. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23875. /**
  23876. * Extracts the vertexData from the geometry
  23877. * @param geometry the geometry from which to extract the VertexData
  23878. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23879. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23880. * @returns the object VertexData associated to the passed mesh
  23881. */
  23882. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23883. private static _ExtractFrom;
  23884. /**
  23885. * Creates the VertexData for a Ribbon
  23886. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23887. * * pathArray array of paths, each of which an array of successive Vector3
  23888. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23889. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23890. * * 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
  23891. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23892. * * 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)
  23893. * * 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)
  23894. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23895. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23896. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23897. * @returns the VertexData of the ribbon
  23898. */
  23899. static CreateRibbon(options: {
  23900. pathArray: Vector3[][];
  23901. closeArray?: boolean;
  23902. closePath?: boolean;
  23903. offset?: number;
  23904. sideOrientation?: number;
  23905. frontUVs?: Vector4;
  23906. backUVs?: Vector4;
  23907. invertUV?: boolean;
  23908. uvs?: Vector2[];
  23909. colors?: Color4[];
  23910. }): VertexData;
  23911. /**
  23912. * Creates the VertexData for a box
  23913. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23914. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23915. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23916. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23917. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23918. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23919. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23920. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23921. * * 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)
  23922. * * 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)
  23923. * @returns the VertexData of the box
  23924. */
  23925. static CreateBox(options: {
  23926. size?: number;
  23927. width?: number;
  23928. height?: number;
  23929. depth?: number;
  23930. faceUV?: Vector4[];
  23931. faceColors?: Color4[];
  23932. sideOrientation?: number;
  23933. frontUVs?: Vector4;
  23934. backUVs?: Vector4;
  23935. }): VertexData;
  23936. /**
  23937. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23938. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23939. * * segments sets the number of horizontal strips optional, default 32
  23940. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23941. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23942. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23943. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23944. * * 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
  23945. * * 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
  23946. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23947. * * 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)
  23948. * * 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)
  23949. * @returns the VertexData of the ellipsoid
  23950. */
  23951. static CreateSphere(options: {
  23952. segments?: number;
  23953. diameter?: number;
  23954. diameterX?: number;
  23955. diameterY?: number;
  23956. diameterZ?: number;
  23957. arc?: number;
  23958. slice?: number;
  23959. sideOrientation?: number;
  23960. frontUVs?: Vector4;
  23961. backUVs?: Vector4;
  23962. }): VertexData;
  23963. /**
  23964. * Creates the VertexData for a cylinder, cone or prism
  23965. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23966. * * height sets the height (y direction) of the cylinder, optional, default 2
  23967. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23968. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23969. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23970. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23971. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23972. * * 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
  23973. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23974. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23975. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23976. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23978. * * 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)
  23979. * * 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)
  23980. * @returns the VertexData of the cylinder, cone or prism
  23981. */
  23982. static CreateCylinder(options: {
  23983. height?: number;
  23984. diameterTop?: number;
  23985. diameterBottom?: number;
  23986. diameter?: number;
  23987. tessellation?: number;
  23988. subdivisions?: number;
  23989. arc?: number;
  23990. faceColors?: Color4[];
  23991. faceUV?: Vector4[];
  23992. hasRings?: boolean;
  23993. enclose?: boolean;
  23994. sideOrientation?: number;
  23995. frontUVs?: Vector4;
  23996. backUVs?: Vector4;
  23997. }): VertexData;
  23998. /**
  23999. * Creates the VertexData for a torus
  24000. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24001. * * diameter the diameter of the torus, optional default 1
  24002. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24003. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24004. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24005. * * 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)
  24006. * * 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)
  24007. * @returns the VertexData of the torus
  24008. */
  24009. static CreateTorus(options: {
  24010. diameter?: number;
  24011. thickness?: number;
  24012. tessellation?: number;
  24013. sideOrientation?: number;
  24014. frontUVs?: Vector4;
  24015. backUVs?: Vector4;
  24016. }): VertexData;
  24017. /**
  24018. * Creates the VertexData of the LineSystem
  24019. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24020. * - lines an array of lines, each line being an array of successive Vector3
  24021. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24022. * @returns the VertexData of the LineSystem
  24023. */
  24024. static CreateLineSystem(options: {
  24025. lines: Vector3[][];
  24026. colors?: Nullable<Color4[][]>;
  24027. }): VertexData;
  24028. /**
  24029. * Create the VertexData for a DashedLines
  24030. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24031. * - points an array successive Vector3
  24032. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24033. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24034. * - dashNb the intended total number of dashes, optional, default 200
  24035. * @returns the VertexData for the DashedLines
  24036. */
  24037. static CreateDashedLines(options: {
  24038. points: Vector3[];
  24039. dashSize?: number;
  24040. gapSize?: number;
  24041. dashNb?: number;
  24042. }): VertexData;
  24043. /**
  24044. * Creates the VertexData for a Ground
  24045. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24046. * - width the width (x direction) of the ground, optional, default 1
  24047. * - height the height (z direction) of the ground, optional, default 1
  24048. * - subdivisions the number of subdivisions per side, optional, default 1
  24049. * @returns the VertexData of the Ground
  24050. */
  24051. static CreateGround(options: {
  24052. width?: number;
  24053. height?: number;
  24054. subdivisions?: number;
  24055. subdivisionsX?: number;
  24056. subdivisionsY?: number;
  24057. }): VertexData;
  24058. /**
  24059. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24060. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24061. * * xmin the ground minimum X coordinate, optional, default -1
  24062. * * zmin the ground minimum Z coordinate, optional, default -1
  24063. * * xmax the ground maximum X coordinate, optional, default 1
  24064. * * zmax the ground maximum Z coordinate, optional, default 1
  24065. * * 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}
  24066. * * 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}
  24067. * @returns the VertexData of the TiledGround
  24068. */
  24069. static CreateTiledGround(options: {
  24070. xmin: number;
  24071. zmin: number;
  24072. xmax: number;
  24073. zmax: number;
  24074. subdivisions?: {
  24075. w: number;
  24076. h: number;
  24077. };
  24078. precision?: {
  24079. w: number;
  24080. h: number;
  24081. };
  24082. }): VertexData;
  24083. /**
  24084. * Creates the VertexData of the Ground designed from a heightmap
  24085. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24086. * * width the width (x direction) of the ground
  24087. * * height the height (z direction) of the ground
  24088. * * subdivisions the number of subdivisions per side
  24089. * * minHeight the minimum altitude on the ground, optional, default 0
  24090. * * maxHeight the maximum altitude on the ground, optional default 1
  24091. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24092. * * buffer the array holding the image color data
  24093. * * bufferWidth the width of image
  24094. * * bufferHeight the height of image
  24095. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24096. * @returns the VertexData of the Ground designed from a heightmap
  24097. */
  24098. static CreateGroundFromHeightMap(options: {
  24099. width: number;
  24100. height: number;
  24101. subdivisions: number;
  24102. minHeight: number;
  24103. maxHeight: number;
  24104. colorFilter: Color3;
  24105. buffer: Uint8Array;
  24106. bufferWidth: number;
  24107. bufferHeight: number;
  24108. alphaFilter: number;
  24109. }): VertexData;
  24110. /**
  24111. * Creates the VertexData for a Plane
  24112. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24113. * * size sets the width and height of the plane to the value of size, optional default 1
  24114. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24115. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24117. * * 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)
  24118. * * 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)
  24119. * @returns the VertexData of the box
  24120. */
  24121. static CreatePlane(options: {
  24122. size?: number;
  24123. width?: number;
  24124. height?: number;
  24125. sideOrientation?: number;
  24126. frontUVs?: Vector4;
  24127. backUVs?: Vector4;
  24128. }): VertexData;
  24129. /**
  24130. * Creates the VertexData of the Disc or regular Polygon
  24131. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24132. * * radius the radius of the disc, optional default 0.5
  24133. * * tessellation the number of polygon sides, optional, default 64
  24134. * * 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
  24135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24136. * * 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)
  24137. * * 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)
  24138. * @returns the VertexData of the box
  24139. */
  24140. static CreateDisc(options: {
  24141. radius?: number;
  24142. tessellation?: number;
  24143. arc?: number;
  24144. sideOrientation?: number;
  24145. frontUVs?: Vector4;
  24146. backUVs?: Vector4;
  24147. }): VertexData;
  24148. /**
  24149. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24150. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24151. * @param polygon a mesh built from polygonTriangulation.build()
  24152. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24153. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24154. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24155. * @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)
  24156. * @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)
  24157. * @returns the VertexData of the Polygon
  24158. */
  24159. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24160. /**
  24161. * Creates the VertexData of the IcoSphere
  24162. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24163. * * radius the radius of the IcoSphere, optional default 1
  24164. * * radiusX allows stretching in the x direction, optional, default radius
  24165. * * radiusY allows stretching in the y direction, optional, default radius
  24166. * * radiusZ allows stretching in the z direction, optional, default radius
  24167. * * flat when true creates a flat shaded mesh, optional, default true
  24168. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24169. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24170. * * 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)
  24171. * * 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)
  24172. * @returns the VertexData of the IcoSphere
  24173. */
  24174. static CreateIcoSphere(options: {
  24175. radius?: number;
  24176. radiusX?: number;
  24177. radiusY?: number;
  24178. radiusZ?: number;
  24179. flat?: boolean;
  24180. subdivisions?: number;
  24181. sideOrientation?: number;
  24182. frontUVs?: Vector4;
  24183. backUVs?: Vector4;
  24184. }): VertexData;
  24185. /**
  24186. * Creates the VertexData for a Polyhedron
  24187. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24188. * * type provided types are:
  24189. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24190. * * 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)
  24191. * * size the size of the IcoSphere, optional default 1
  24192. * * sizeX allows stretching in the x direction, optional, default size
  24193. * * sizeY allows stretching in the y direction, optional, default size
  24194. * * sizeZ allows stretching in the z direction, optional, default size
  24195. * * 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
  24196. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24197. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24198. * * flat when true creates a flat shaded mesh, optional, default true
  24199. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24201. * * 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)
  24202. * * 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)
  24203. * @returns the VertexData of the Polyhedron
  24204. */
  24205. static CreatePolyhedron(options: {
  24206. type?: number;
  24207. size?: number;
  24208. sizeX?: number;
  24209. sizeY?: number;
  24210. sizeZ?: number;
  24211. custom?: any;
  24212. faceUV?: Vector4[];
  24213. faceColors?: Color4[];
  24214. flat?: boolean;
  24215. sideOrientation?: number;
  24216. frontUVs?: Vector4;
  24217. backUVs?: Vector4;
  24218. }): VertexData;
  24219. /**
  24220. * Creates the VertexData for a TorusKnot
  24221. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24222. * * radius the radius of the torus knot, optional, default 2
  24223. * * tube the thickness of the tube, optional, default 0.5
  24224. * * radialSegments the number of sides on each tube segments, optional, default 32
  24225. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24226. * * p the number of windings around the z axis, optional, default 2
  24227. * * q the number of windings around the x axis, optional, default 3
  24228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24229. * * 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)
  24230. * * 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)
  24231. * @returns the VertexData of the Torus Knot
  24232. */
  24233. static CreateTorusKnot(options: {
  24234. radius?: number;
  24235. tube?: number;
  24236. radialSegments?: number;
  24237. tubularSegments?: number;
  24238. p?: number;
  24239. q?: number;
  24240. sideOrientation?: number;
  24241. frontUVs?: Vector4;
  24242. backUVs?: Vector4;
  24243. }): VertexData;
  24244. /**
  24245. * Compute normals for given positions and indices
  24246. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24247. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24248. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24249. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24250. * * facetNormals : optional array of facet normals (vector3)
  24251. * * facetPositions : optional array of facet positions (vector3)
  24252. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24253. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24254. * * bInfo : optional bounding info, required for facetPartitioning computation
  24255. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24256. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24257. * * useRightHandedSystem: optional boolean to for right handed system computation
  24258. * * depthSort : optional boolean to enable the facet depth sort computation
  24259. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24260. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24261. */
  24262. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24263. facetNormals?: any;
  24264. facetPositions?: any;
  24265. facetPartitioning?: any;
  24266. ratio?: number;
  24267. bInfo?: any;
  24268. bbSize?: Vector3;
  24269. subDiv?: any;
  24270. useRightHandedSystem?: boolean;
  24271. depthSort?: boolean;
  24272. distanceTo?: Vector3;
  24273. depthSortedFacets?: any;
  24274. }): void;
  24275. /** @hidden */
  24276. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24277. /**
  24278. * Applies VertexData created from the imported parameters to the geometry
  24279. * @param parsedVertexData the parsed data from an imported file
  24280. * @param geometry the geometry to apply the VertexData to
  24281. */
  24282. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24283. }
  24284. }
  24285. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24286. import { Nullable } from "babylonjs/types";
  24287. import { Scene } from "babylonjs/scene";
  24288. import { Vector4 } from "babylonjs/Maths/math";
  24289. import { Mesh } from "babylonjs/Meshes/mesh";
  24290. /**
  24291. * Class containing static functions to help procedurally build meshes
  24292. */
  24293. export class DiscBuilder {
  24294. /**
  24295. * Creates a plane polygonal mesh. By default, this is a disc
  24296. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24297. * * 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
  24298. * * 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
  24299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24302. * @param name defines the name of the mesh
  24303. * @param options defines the options used to create the mesh
  24304. * @param scene defines the hosting scene
  24305. * @returns the plane polygonal mesh
  24306. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24307. */
  24308. static CreateDisc(name: string, options: {
  24309. radius?: number;
  24310. tessellation?: number;
  24311. arc?: number;
  24312. updatable?: boolean;
  24313. sideOrientation?: number;
  24314. frontUVs?: Vector4;
  24315. backUVs?: Vector4;
  24316. }, scene?: Nullable<Scene>): Mesh;
  24317. }
  24318. }
  24319. declare module "babylonjs/Particles/solidParticleSystem" {
  24320. import { Vector3 } from "babylonjs/Maths/math";
  24321. import { Mesh } from "babylonjs/Meshes/mesh";
  24322. import { Scene, IDisposable } from "babylonjs/scene";
  24323. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24324. /**
  24325. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24326. *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.
  24327. * The SPS is also a particle system. It provides some methods to manage the particles.
  24328. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24329. *
  24330. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24331. */
  24332. export class SolidParticleSystem implements IDisposable {
  24333. /**
  24334. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24335. * Example : var p = SPS.particles[i];
  24336. */
  24337. particles: SolidParticle[];
  24338. /**
  24339. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24340. */
  24341. nbParticles: number;
  24342. /**
  24343. * If the particles must ever face the camera (default false). Useful for planar particles.
  24344. */
  24345. billboard: boolean;
  24346. /**
  24347. * Recompute normals when adding a shape
  24348. */
  24349. recomputeNormals: boolean;
  24350. /**
  24351. * This a counter ofr your own usage. It's not set by any SPS functions.
  24352. */
  24353. counter: number;
  24354. /**
  24355. * The SPS name. This name is also given to the underlying mesh.
  24356. */
  24357. name: string;
  24358. /**
  24359. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24360. */
  24361. mesh: Mesh;
  24362. /**
  24363. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24364. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24365. */
  24366. vars: any;
  24367. /**
  24368. * This array is populated when the SPS is set as 'pickable'.
  24369. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24370. * Each element of this array is an object `{idx: int, faceId: int}`.
  24371. * `idx` is the picked particle index in the `SPS.particles` array
  24372. * `faceId` is the picked face index counted within this particle.
  24373. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24374. */
  24375. pickedParticles: {
  24376. idx: number;
  24377. faceId: number;
  24378. }[];
  24379. /**
  24380. * This array is populated when `enableDepthSort` is set to true.
  24381. * Each element of this array is an instance of the class DepthSortedParticle.
  24382. */
  24383. depthSortedParticles: DepthSortedParticle[];
  24384. /**
  24385. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24386. * @hidden
  24387. */
  24388. _bSphereOnly: boolean;
  24389. /**
  24390. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24391. * @hidden
  24392. */
  24393. _bSphereRadiusFactor: number;
  24394. private _scene;
  24395. private _positions;
  24396. private _indices;
  24397. private _normals;
  24398. private _colors;
  24399. private _uvs;
  24400. private _indices32;
  24401. private _positions32;
  24402. private _normals32;
  24403. private _fixedNormal32;
  24404. private _colors32;
  24405. private _uvs32;
  24406. private _index;
  24407. private _updatable;
  24408. private _pickable;
  24409. private _isVisibilityBoxLocked;
  24410. private _alwaysVisible;
  24411. private _depthSort;
  24412. private _shapeCounter;
  24413. private _copy;
  24414. private _color;
  24415. private _computeParticleColor;
  24416. private _computeParticleTexture;
  24417. private _computeParticleRotation;
  24418. private _computeParticleVertex;
  24419. private _computeBoundingBox;
  24420. private _depthSortParticles;
  24421. private _camera;
  24422. private _mustUnrotateFixedNormals;
  24423. private _particlesIntersect;
  24424. private _needs32Bits;
  24425. /**
  24426. * Creates a SPS (Solid Particle System) object.
  24427. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24428. * @param scene (Scene) is the scene in which the SPS is added.
  24429. * @param options defines the options of the sps e.g.
  24430. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24431. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24432. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24433. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24434. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24435. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24436. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24437. */
  24438. constructor(name: string, scene: Scene, options?: {
  24439. updatable?: boolean;
  24440. isPickable?: boolean;
  24441. enableDepthSort?: boolean;
  24442. particleIntersection?: boolean;
  24443. boundingSphereOnly?: boolean;
  24444. bSphereRadiusFactor?: number;
  24445. });
  24446. /**
  24447. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24448. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24449. * @returns the created mesh
  24450. */
  24451. buildMesh(): Mesh;
  24452. /**
  24453. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24454. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24455. * Thus the particles generated from `digest()` have their property `position` set yet.
  24456. * @param mesh ( Mesh ) is the mesh to be digested
  24457. * @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
  24458. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24459. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24460. * @returns the current SPS
  24461. */
  24462. digest(mesh: Mesh, options?: {
  24463. facetNb?: number;
  24464. number?: number;
  24465. delta?: number;
  24466. }): SolidParticleSystem;
  24467. private _unrotateFixedNormals;
  24468. private _resetCopy;
  24469. private _meshBuilder;
  24470. private _posToShape;
  24471. private _uvsToShapeUV;
  24472. private _addParticle;
  24473. /**
  24474. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24475. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24476. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24477. * @param nb (positive integer) the number of particles to be created from this model
  24478. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24479. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24480. * @returns the number of shapes in the system
  24481. */
  24482. addShape(mesh: Mesh, nb: number, options?: {
  24483. positionFunction?: any;
  24484. vertexFunction?: any;
  24485. }): number;
  24486. private _rebuildParticle;
  24487. /**
  24488. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24489. * @returns the SPS.
  24490. */
  24491. rebuildMesh(): SolidParticleSystem;
  24492. /**
  24493. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24494. * This method calls `updateParticle()` for each particle of the SPS.
  24495. * For an animated SPS, it is usually called within the render loop.
  24496. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24497. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24498. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24499. * @returns the SPS.
  24500. */
  24501. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24502. /**
  24503. * Disposes the SPS.
  24504. */
  24505. dispose(): void;
  24506. /**
  24507. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24508. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24509. * @returns the SPS.
  24510. */
  24511. refreshVisibleSize(): SolidParticleSystem;
  24512. /**
  24513. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24514. * @param size the size (float) of the visibility box
  24515. * note : this doesn't lock the SPS mesh bounding box.
  24516. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24517. */
  24518. setVisibilityBox(size: number): void;
  24519. /**
  24520. * Gets whether the SPS as always visible or not
  24521. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24522. */
  24523. /**
  24524. * Sets the SPS as always visible or not
  24525. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24526. */
  24527. isAlwaysVisible: boolean;
  24528. /**
  24529. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24530. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24531. */
  24532. /**
  24533. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24534. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24535. */
  24536. isVisibilityBoxLocked: boolean;
  24537. /**
  24538. * Tells to `setParticles()` to compute the particle rotations or not.
  24539. * Default value : true. The SPS is faster when it's set to false.
  24540. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24541. */
  24542. /**
  24543. * Gets if `setParticles()` computes the particle rotations or not.
  24544. * Default value : true. The SPS is faster when it's set to false.
  24545. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24546. */
  24547. computeParticleRotation: boolean;
  24548. /**
  24549. * Tells to `setParticles()` to compute the particle colors or not.
  24550. * Default value : true. The SPS is faster when it's set to false.
  24551. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24552. */
  24553. /**
  24554. * Gets if `setParticles()` computes the particle colors or not.
  24555. * Default value : true. The SPS is faster when it's set to false.
  24556. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24557. */
  24558. computeParticleColor: boolean;
  24559. /**
  24560. * Gets if `setParticles()` computes the particle textures or not.
  24561. * Default value : true. The SPS is faster when it's set to false.
  24562. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24563. */
  24564. computeParticleTexture: boolean;
  24565. /**
  24566. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24567. * Default value : false. The SPS is faster when it's set to false.
  24568. * Note : the particle custom vertex positions aren't stored values.
  24569. */
  24570. /**
  24571. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24572. * Default value : false. The SPS is faster when it's set to false.
  24573. * Note : the particle custom vertex positions aren't stored values.
  24574. */
  24575. computeParticleVertex: boolean;
  24576. /**
  24577. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24578. */
  24579. /**
  24580. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24581. */
  24582. computeBoundingBox: boolean;
  24583. /**
  24584. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24585. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24586. * Default : `true`
  24587. */
  24588. /**
  24589. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24590. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24591. * Default : `true`
  24592. */
  24593. depthSortParticles: boolean;
  24594. /**
  24595. * This function does nothing. It may be overwritten to set all the particle first values.
  24596. * The SPS doesn't call this function, you may have to call it by your own.
  24597. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24598. */
  24599. initParticles(): void;
  24600. /**
  24601. * This function does nothing. It may be overwritten to recycle a particle.
  24602. * The SPS doesn't call this function, you may have to call it by your own.
  24603. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24604. * @param particle The particle to recycle
  24605. * @returns the recycled particle
  24606. */
  24607. recycleParticle(particle: SolidParticle): SolidParticle;
  24608. /**
  24609. * Updates a particle : this function should be overwritten by the user.
  24610. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24611. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24612. * @example : just set a particle position or velocity and recycle conditions
  24613. * @param particle The particle to update
  24614. * @returns the updated particle
  24615. */
  24616. updateParticle(particle: SolidParticle): SolidParticle;
  24617. /**
  24618. * Updates a vertex of a particle : it can be overwritten by the user.
  24619. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24620. * @param particle the current particle
  24621. * @param vertex the current index of the current particle
  24622. * @param pt the index of the current vertex in the particle shape
  24623. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24624. * @example : just set a vertex particle position
  24625. * @returns the updated vertex
  24626. */
  24627. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24628. /**
  24629. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24630. * This does nothing and may be overwritten by the user.
  24631. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24632. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24633. * @param update the boolean update value actually passed to setParticles()
  24634. */
  24635. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24636. /**
  24637. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24638. * This will be passed three parameters.
  24639. * This does nothing and may be overwritten by the user.
  24640. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24641. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24642. * @param update the boolean update value actually passed to setParticles()
  24643. */
  24644. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24645. }
  24646. }
  24647. declare module "babylonjs/Particles/solidParticle" {
  24648. import { Nullable } from "babylonjs/types";
  24649. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24650. import { Mesh } from "babylonjs/Meshes/mesh";
  24651. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24652. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24653. /**
  24654. * Represents one particle of a solid particle system.
  24655. */
  24656. export class SolidParticle {
  24657. /**
  24658. * particle global index
  24659. */
  24660. idx: number;
  24661. /**
  24662. * The color of the particle
  24663. */
  24664. color: Nullable<Color4>;
  24665. /**
  24666. * The world space position of the particle.
  24667. */
  24668. position: Vector3;
  24669. /**
  24670. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24671. */
  24672. rotation: Vector3;
  24673. /**
  24674. * The world space rotation quaternion of the particle.
  24675. */
  24676. rotationQuaternion: Nullable<Quaternion>;
  24677. /**
  24678. * The scaling of the particle.
  24679. */
  24680. scaling: Vector3;
  24681. /**
  24682. * The uvs of the particle.
  24683. */
  24684. uvs: Vector4;
  24685. /**
  24686. * The current speed of the particle.
  24687. */
  24688. velocity: Vector3;
  24689. /**
  24690. * The pivot point in the particle local space.
  24691. */
  24692. pivot: Vector3;
  24693. /**
  24694. * Must the particle be translated from its pivot point in its local space ?
  24695. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24696. * Default : false
  24697. */
  24698. translateFromPivot: boolean;
  24699. /**
  24700. * Is the particle active or not ?
  24701. */
  24702. alive: boolean;
  24703. /**
  24704. * Is the particle visible or not ?
  24705. */
  24706. isVisible: boolean;
  24707. /**
  24708. * Index of this particle in the global "positions" array (Internal use)
  24709. * @hidden
  24710. */
  24711. _pos: number;
  24712. /**
  24713. * @hidden Index of this particle in the global "indices" array (Internal use)
  24714. */
  24715. _ind: number;
  24716. /**
  24717. * @hidden ModelShape of this particle (Internal use)
  24718. */
  24719. _model: ModelShape;
  24720. /**
  24721. * ModelShape id of this particle
  24722. */
  24723. shapeId: number;
  24724. /**
  24725. * Index of the particle in its shape id (Internal use)
  24726. */
  24727. idxInShape: number;
  24728. /**
  24729. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24730. */
  24731. _modelBoundingInfo: BoundingInfo;
  24732. /**
  24733. * @hidden Particle BoundingInfo object (Internal use)
  24734. */
  24735. _boundingInfo: BoundingInfo;
  24736. /**
  24737. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24738. */
  24739. _sps: SolidParticleSystem;
  24740. /**
  24741. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24742. */
  24743. _stillInvisible: boolean;
  24744. /**
  24745. * @hidden Last computed particle rotation matrix
  24746. */
  24747. _rotationMatrix: number[];
  24748. /**
  24749. * Parent particle Id, if any.
  24750. * Default null.
  24751. */
  24752. parentId: Nullable<number>;
  24753. /**
  24754. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24755. * The possible values are :
  24756. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24757. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24758. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24759. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24760. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24761. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24762. * */
  24763. cullingStrategy: number;
  24764. /**
  24765. * @hidden Internal global position in the SPS.
  24766. */
  24767. _globalPosition: Vector3;
  24768. /**
  24769. * Creates a Solid Particle object.
  24770. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24771. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24772. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24773. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24774. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24775. * @param shapeId (integer) is the model shape identifier in the SPS.
  24776. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24777. * @param sps defines the sps it is associated to
  24778. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24779. */
  24780. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24781. /**
  24782. * Legacy support, changed scale to scaling
  24783. */
  24784. /**
  24785. * Legacy support, changed scale to scaling
  24786. */
  24787. scale: Vector3;
  24788. /**
  24789. * Legacy support, changed quaternion to rotationQuaternion
  24790. */
  24791. /**
  24792. * Legacy support, changed quaternion to rotationQuaternion
  24793. */
  24794. quaternion: Nullable<Quaternion>;
  24795. /**
  24796. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24797. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24798. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24799. * @returns true if it intersects
  24800. */
  24801. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24802. /**
  24803. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24804. * A particle is in the frustum if its bounding box intersects the frustum
  24805. * @param frustumPlanes defines the frustum to test
  24806. * @returns true if the particle is in the frustum planes
  24807. */
  24808. isInFrustum(frustumPlanes: Plane[]): boolean;
  24809. /**
  24810. * get the rotation matrix of the particle
  24811. * @hidden
  24812. */
  24813. getRotationMatrix(m: Matrix): void;
  24814. }
  24815. /**
  24816. * Represents the shape of the model used by one particle of a solid particle system.
  24817. * SPS internal tool, don't use it manually.
  24818. */
  24819. export class ModelShape {
  24820. /**
  24821. * The shape id
  24822. * @hidden
  24823. */
  24824. shapeID: number;
  24825. /**
  24826. * flat array of model positions (internal use)
  24827. * @hidden
  24828. */
  24829. _shape: Vector3[];
  24830. /**
  24831. * flat array of model UVs (internal use)
  24832. * @hidden
  24833. */
  24834. _shapeUV: number[];
  24835. /**
  24836. * length of the shape in the model indices array (internal use)
  24837. * @hidden
  24838. */
  24839. _indicesLength: number;
  24840. /**
  24841. * Custom position function (internal use)
  24842. * @hidden
  24843. */
  24844. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24845. /**
  24846. * Custom vertex function (internal use)
  24847. * @hidden
  24848. */
  24849. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24850. /**
  24851. * 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.
  24852. * SPS internal tool, don't use it manually.
  24853. * @hidden
  24854. */
  24855. 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>);
  24856. }
  24857. /**
  24858. * Represents a Depth Sorted Particle in the solid particle system.
  24859. */
  24860. export class DepthSortedParticle {
  24861. /**
  24862. * Index of the particle in the "indices" array
  24863. */
  24864. ind: number;
  24865. /**
  24866. * Length of the particle shape in the "indices" array
  24867. */
  24868. indicesLength: number;
  24869. /**
  24870. * Squared distance from the particle to the camera
  24871. */
  24872. sqDistance: number;
  24873. }
  24874. }
  24875. declare module "babylonjs/Meshes/abstractMesh" {
  24876. import { Observable } from "babylonjs/Misc/observable";
  24877. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24878. import { Camera } from "babylonjs/Cameras/camera";
  24879. import { Scene, IDisposable } from "babylonjs/scene";
  24880. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24881. import { Node } from "babylonjs/node";
  24882. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24883. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24884. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24885. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24886. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24887. import { Material } from "babylonjs/Materials/material";
  24888. import { Light } from "babylonjs/Lights/light";
  24889. import { Skeleton } from "babylonjs/Bones/skeleton";
  24890. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24891. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24892. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24893. import { Ray } from "babylonjs/Culling/ray";
  24894. import { Collider } from "babylonjs/Collisions/collider";
  24895. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24896. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24897. /**
  24898. * Class used to store all common mesh properties
  24899. */
  24900. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24901. /** No occlusion */
  24902. static OCCLUSION_TYPE_NONE: number;
  24903. /** Occlusion set to optimisitic */
  24904. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24905. /** Occlusion set to strict */
  24906. static OCCLUSION_TYPE_STRICT: number;
  24907. /** Use an accurante occlusion algorithm */
  24908. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24909. /** Use a conservative occlusion algorithm */
  24910. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24911. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24912. * Test order :
  24913. * Is the bounding sphere outside the frustum ?
  24914. * If not, are the bounding box vertices outside the frustum ?
  24915. * It not, then the cullable object is in the frustum.
  24916. */
  24917. static readonly CULLINGSTRATEGY_STANDARD: number;
  24918. /** Culling strategy : Bounding Sphere Only.
  24919. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24920. * It's also less accurate than the standard because some not visible objects can still be selected.
  24921. * Test : is the bounding sphere outside the frustum ?
  24922. * If not, then the cullable object is in the frustum.
  24923. */
  24924. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24925. /** Culling strategy : Optimistic Inclusion.
  24926. * This in an inclusion test first, then the standard exclusion test.
  24927. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24928. * 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.
  24929. * Anyway, it's as accurate as the standard strategy.
  24930. * Test :
  24931. * Is the cullable object bounding sphere center in the frustum ?
  24932. * If not, apply the default culling strategy.
  24933. */
  24934. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24935. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24936. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24937. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24938. * 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.
  24939. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24940. * Test :
  24941. * Is the cullable object bounding sphere center in the frustum ?
  24942. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24943. */
  24944. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24945. /**
  24946. * No billboard
  24947. */
  24948. static readonly BILLBOARDMODE_NONE: number;
  24949. /** Billboard on X axis */
  24950. static readonly BILLBOARDMODE_X: number;
  24951. /** Billboard on Y axis */
  24952. static readonly BILLBOARDMODE_Y: number;
  24953. /** Billboard on Z axis */
  24954. static readonly BILLBOARDMODE_Z: number;
  24955. /** Billboard on all axes */
  24956. static readonly BILLBOARDMODE_ALL: number;
  24957. private _facetData;
  24958. /**
  24959. * The culling strategy to use to check whether the mesh must be rendered or not.
  24960. * This value can be changed at any time and will be used on the next render mesh selection.
  24961. * The possible values are :
  24962. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24963. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24964. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24965. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24966. * Please read each static variable documentation to get details about the culling process.
  24967. * */
  24968. cullingStrategy: number;
  24969. /**
  24970. * Gets the number of facets in the mesh
  24971. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24972. */
  24973. readonly facetNb: number;
  24974. /**
  24975. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24977. */
  24978. partitioningSubdivisions: number;
  24979. /**
  24980. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24981. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24983. */
  24984. partitioningBBoxRatio: number;
  24985. /**
  24986. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24987. * Works only for updatable meshes.
  24988. * Doesn't work with multi-materials
  24989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24990. */
  24991. mustDepthSortFacets: boolean;
  24992. /**
  24993. * The location (Vector3) where the facet depth sort must be computed from.
  24994. * By default, the active camera position.
  24995. * Used only when facet depth sort is enabled
  24996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24997. */
  24998. facetDepthSortFrom: Vector3;
  24999. /**
  25000. * gets a boolean indicating if facetData is enabled
  25001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25002. */
  25003. readonly isFacetDataEnabled: boolean;
  25004. /** @hidden */
  25005. _updateNonUniformScalingState(value: boolean): boolean;
  25006. /**
  25007. * An event triggered when this mesh collides with another one
  25008. */
  25009. onCollideObservable: Observable<AbstractMesh>;
  25010. private _onCollideObserver;
  25011. /** Set a function to call when this mesh collides with another one */
  25012. onCollide: () => void;
  25013. /**
  25014. * An event triggered when the collision's position changes
  25015. */
  25016. onCollisionPositionChangeObservable: Observable<Vector3>;
  25017. private _onCollisionPositionChangeObserver;
  25018. /** Set a function to call when the collision's position changes */
  25019. onCollisionPositionChange: () => void;
  25020. /**
  25021. * An event triggered when material is changed
  25022. */
  25023. onMaterialChangedObservable: Observable<AbstractMesh>;
  25024. /**
  25025. * Gets or sets the orientation for POV movement & rotation
  25026. */
  25027. definedFacingForward: boolean;
  25028. /** @hidden */
  25029. _occlusionQuery: Nullable<WebGLQuery>;
  25030. private _visibility;
  25031. /** @hidden */
  25032. _isActive: boolean;
  25033. /** @hidden */
  25034. _onlyForInstances: boolean;
  25035. /** @hidden */
  25036. _renderingGroup: Nullable<RenderingGroup>;
  25037. /**
  25038. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25039. */
  25040. /**
  25041. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25042. */
  25043. visibility: number;
  25044. /** Gets or sets the alpha index used to sort transparent meshes
  25045. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25046. */
  25047. alphaIndex: number;
  25048. /**
  25049. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25050. */
  25051. isVisible: boolean;
  25052. /**
  25053. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25054. */
  25055. isPickable: boolean;
  25056. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25057. showSubMeshesBoundingBox: boolean;
  25058. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25059. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25060. */
  25061. isBlocker: boolean;
  25062. /**
  25063. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25064. */
  25065. enablePointerMoveEvents: boolean;
  25066. /**
  25067. * Specifies the rendering group id for this mesh (0 by default)
  25068. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25069. */
  25070. renderingGroupId: number;
  25071. private _material;
  25072. /** Gets or sets current material */
  25073. material: Nullable<Material>;
  25074. private _receiveShadows;
  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. private _hasVertexAlpha;
  25089. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25090. hasVertexAlpha: boolean;
  25091. private _useVertexColors;
  25092. /** 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) */
  25093. useVertexColors: boolean;
  25094. private _computeBonesUsingShaders;
  25095. /**
  25096. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25097. */
  25098. computeBonesUsingShaders: boolean;
  25099. private _numBoneInfluencers;
  25100. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25101. numBoneInfluencers: number;
  25102. private _applyFog;
  25103. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25104. applyFog: boolean;
  25105. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25106. useOctreeForRenderingSelection: boolean;
  25107. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25108. useOctreeForPicking: boolean;
  25109. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25110. useOctreeForCollisions: boolean;
  25111. private _layerMask;
  25112. /**
  25113. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25114. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25115. */
  25116. layerMask: number;
  25117. /**
  25118. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25119. */
  25120. alwaysSelectAsActiveMesh: boolean;
  25121. /**
  25122. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25123. */
  25124. doNotSyncBoundingInfo: boolean;
  25125. /**
  25126. * Gets or sets the current action manager
  25127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25128. */
  25129. actionManager: Nullable<AbstractActionManager>;
  25130. private _checkCollisions;
  25131. private _collisionMask;
  25132. private _collisionGroup;
  25133. /**
  25134. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25135. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25136. */
  25137. ellipsoid: Vector3;
  25138. /**
  25139. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25140. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25141. */
  25142. ellipsoidOffset: Vector3;
  25143. private _collider;
  25144. private _oldPositionForCollisions;
  25145. private _diffPositionForCollisions;
  25146. /**
  25147. * Gets or sets a collision mask used to mask collisions (default is -1).
  25148. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25149. */
  25150. collisionMask: number;
  25151. /**
  25152. * Gets or sets the current collision group mask (-1 by default).
  25153. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25154. */
  25155. collisionGroup: number;
  25156. /**
  25157. * Defines edge width used when edgesRenderer is enabled
  25158. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25159. */
  25160. edgesWidth: number;
  25161. /**
  25162. * Defines edge color used when edgesRenderer is enabled
  25163. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25164. */
  25165. edgesColor: Color4;
  25166. /** @hidden */
  25167. _edgesRenderer: Nullable<IEdgesRenderer>;
  25168. /** @hidden */
  25169. _masterMesh: Nullable<AbstractMesh>;
  25170. /** @hidden */
  25171. _boundingInfo: Nullable<BoundingInfo>;
  25172. /** @hidden */
  25173. _renderId: number;
  25174. /**
  25175. * Gets or sets the list of subMeshes
  25176. * @see http://doc.babylonjs.com/how_to/multi_materials
  25177. */
  25178. subMeshes: SubMesh[];
  25179. /** @hidden */
  25180. _intersectionsInProgress: AbstractMesh[];
  25181. /** @hidden */
  25182. _unIndexed: boolean;
  25183. /** @hidden */
  25184. _lightSources: Light[];
  25185. /** Gets the list of lights affecting that mesh */
  25186. readonly lightSources: Light[];
  25187. /** @hidden */
  25188. readonly _positions: Nullable<Vector3[]>;
  25189. /** @hidden */
  25190. _waitingData: {
  25191. lods: Nullable<any>;
  25192. actions: Nullable<any>;
  25193. freezeWorldMatrix: Nullable<boolean>;
  25194. };
  25195. private _skeleton;
  25196. /** @hidden */
  25197. _bonesTransformMatrices: Nullable<Float32Array>;
  25198. /**
  25199. * Gets or sets a skeleton to apply skining transformations
  25200. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25201. */
  25202. skeleton: Nullable<Skeleton>;
  25203. /**
  25204. * An event triggered when the mesh is rebuilt.
  25205. */
  25206. onRebuildObservable: Observable<AbstractMesh>;
  25207. /**
  25208. * Creates a new AbstractMesh
  25209. * @param name defines the name of the mesh
  25210. * @param scene defines the hosting scene
  25211. */
  25212. constructor(name: string, scene?: Nullable<Scene>);
  25213. /**
  25214. * Returns the string "AbstractMesh"
  25215. * @returns "AbstractMesh"
  25216. */
  25217. getClassName(): string;
  25218. /**
  25219. * Gets a string representation of the current mesh
  25220. * @param fullDetails defines a boolean indicating if full details must be included
  25221. * @returns a string representation of the current mesh
  25222. */
  25223. toString(fullDetails?: boolean): string;
  25224. /**
  25225. * @hidden
  25226. */
  25227. protected _getEffectiveParent(): Nullable<Node>;
  25228. /** @hidden */
  25229. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25230. /** @hidden */
  25231. _rebuild(): void;
  25232. /** @hidden */
  25233. _resyncLightSources(): void;
  25234. /** @hidden */
  25235. _resyncLighSource(light: Light): void;
  25236. /** @hidden */
  25237. _unBindEffect(): void;
  25238. /** @hidden */
  25239. _removeLightSource(light: Light): void;
  25240. private _markSubMeshesAsDirty;
  25241. /** @hidden */
  25242. _markSubMeshesAsLightDirty(): void;
  25243. /** @hidden */
  25244. _markSubMeshesAsAttributesDirty(): void;
  25245. /** @hidden */
  25246. _markSubMeshesAsMiscDirty(): void;
  25247. /**
  25248. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25249. */
  25250. scaling: Vector3;
  25251. /**
  25252. * Returns true if the mesh is blocked. Implemented by child classes
  25253. */
  25254. readonly isBlocked: boolean;
  25255. /**
  25256. * Returns the mesh itself by default. Implemented by child classes
  25257. * @param camera defines the camera to use to pick the right LOD level
  25258. * @returns the currentAbstractMesh
  25259. */
  25260. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25261. /**
  25262. * Returns 0 by default. Implemented by child classes
  25263. * @returns an integer
  25264. */
  25265. getTotalVertices(): number;
  25266. /**
  25267. * Returns a positive integer : the total number of indices in this mesh geometry.
  25268. * @returns the numner of indices or zero if the mesh has no geometry.
  25269. */
  25270. getTotalIndices(): number;
  25271. /**
  25272. * Returns null by default. Implemented by child classes
  25273. * @returns null
  25274. */
  25275. getIndices(): Nullable<IndicesArray>;
  25276. /**
  25277. * Returns the array of the requested vertex data kind. Implemented by child classes
  25278. * @param kind defines the vertex data kind to use
  25279. * @returns null
  25280. */
  25281. getVerticesData(kind: string): Nullable<FloatArray>;
  25282. /**
  25283. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25284. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25285. * Note that a new underlying VertexBuffer object is created each call.
  25286. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25287. * @param kind defines vertex data kind:
  25288. * * VertexBuffer.PositionKind
  25289. * * VertexBuffer.UVKind
  25290. * * VertexBuffer.UV2Kind
  25291. * * VertexBuffer.UV3Kind
  25292. * * VertexBuffer.UV4Kind
  25293. * * VertexBuffer.UV5Kind
  25294. * * VertexBuffer.UV6Kind
  25295. * * VertexBuffer.ColorKind
  25296. * * VertexBuffer.MatricesIndicesKind
  25297. * * VertexBuffer.MatricesIndicesExtraKind
  25298. * * VertexBuffer.MatricesWeightsKind
  25299. * * VertexBuffer.MatricesWeightsExtraKind
  25300. * @param data defines the data source
  25301. * @param updatable defines if the data must be flagged as updatable (or static)
  25302. * @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
  25303. * @returns the current mesh
  25304. */
  25305. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25306. /**
  25307. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25308. * If the mesh has no geometry, it is simply returned as it is.
  25309. * @param kind defines vertex data kind:
  25310. * * VertexBuffer.PositionKind
  25311. * * VertexBuffer.UVKind
  25312. * * VertexBuffer.UV2Kind
  25313. * * VertexBuffer.UV3Kind
  25314. * * VertexBuffer.UV4Kind
  25315. * * VertexBuffer.UV5Kind
  25316. * * VertexBuffer.UV6Kind
  25317. * * VertexBuffer.ColorKind
  25318. * * VertexBuffer.MatricesIndicesKind
  25319. * * VertexBuffer.MatricesIndicesExtraKind
  25320. * * VertexBuffer.MatricesWeightsKind
  25321. * * VertexBuffer.MatricesWeightsExtraKind
  25322. * @param data defines the data source
  25323. * @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
  25324. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25325. * @returns the current mesh
  25326. */
  25327. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25328. /**
  25329. * Sets the mesh indices,
  25330. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25331. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25332. * @param totalVertices Defines the total number of vertices
  25333. * @returns the current mesh
  25334. */
  25335. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25336. /**
  25337. * Gets a boolean indicating if specific vertex data is present
  25338. * @param kind defines the vertex data kind to use
  25339. * @returns true is data kind is present
  25340. */
  25341. isVerticesDataPresent(kind: string): boolean;
  25342. /**
  25343. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25344. * @returns a BoundingInfo
  25345. */
  25346. getBoundingInfo(): BoundingInfo;
  25347. /**
  25348. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25349. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25350. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25351. * @returns the current mesh
  25352. */
  25353. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25354. /**
  25355. * Overwrite the current bounding info
  25356. * @param boundingInfo defines the new bounding info
  25357. * @returns the current mesh
  25358. */
  25359. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25360. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25361. readonly useBones: boolean;
  25362. /** @hidden */
  25363. _preActivate(): void;
  25364. /** @hidden */
  25365. _preActivateForIntermediateRendering(renderId: number): void;
  25366. /** @hidden */
  25367. _activate(renderId: number): boolean;
  25368. /** @hidden */
  25369. _postActivate(): void;
  25370. /** @hidden */
  25371. _freeze(): void;
  25372. /** @hidden */
  25373. _unFreeze(): void;
  25374. /**
  25375. * Gets the current world matrix
  25376. * @returns a Matrix
  25377. */
  25378. getWorldMatrix(): Matrix;
  25379. /** @hidden */
  25380. _getWorldMatrixDeterminant(): number;
  25381. /**
  25382. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25383. */
  25384. readonly isAnInstance: boolean;
  25385. /**
  25386. * Perform relative position change from the point of view of behind the front of the mesh.
  25387. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25388. * Supports definition of mesh facing forward or backward
  25389. * @param amountRight defines the distance on the right axis
  25390. * @param amountUp defines the distance on the up axis
  25391. * @param amountForward defines the distance on the forward axis
  25392. * @returns the current mesh
  25393. */
  25394. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25395. /**
  25396. * Calculate relative position change from the point of view of behind the front of the mesh.
  25397. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25398. * Supports definition of mesh facing forward or backward
  25399. * @param amountRight defines the distance on the right axis
  25400. * @param amountUp defines the distance on the up axis
  25401. * @param amountForward defines the distance on the forward axis
  25402. * @returns the new displacement vector
  25403. */
  25404. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25405. /**
  25406. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25407. * Supports definition of mesh facing forward or backward
  25408. * @param flipBack defines the flip
  25409. * @param twirlClockwise defines the twirl
  25410. * @param tiltRight defines the tilt
  25411. * @returns the current mesh
  25412. */
  25413. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25414. /**
  25415. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25416. * Supports definition of mesh facing forward or backward.
  25417. * @param flipBack defines the flip
  25418. * @param twirlClockwise defines the twirl
  25419. * @param tiltRight defines the tilt
  25420. * @returns the new rotation vector
  25421. */
  25422. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25423. /**
  25424. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25425. * This means the mesh underlying bounding box and sphere are recomputed.
  25426. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25427. * @returns the current mesh
  25428. */
  25429. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25430. /** @hidden */
  25431. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25432. /** @hidden */
  25433. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25434. /** @hidden */
  25435. _updateBoundingInfo(): AbstractMesh;
  25436. /** @hidden */
  25437. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25438. /** @hidden */
  25439. protected _afterComputeWorldMatrix(): void;
  25440. /** @hidden */
  25441. readonly _effectiveMesh: AbstractMesh;
  25442. /**
  25443. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25444. * A mesh is in the frustum if its bounding box intersects the frustum
  25445. * @param frustumPlanes defines the frustum to test
  25446. * @returns true if the mesh is in the frustum planes
  25447. */
  25448. isInFrustum(frustumPlanes: Plane[]): boolean;
  25449. /**
  25450. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25451. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25452. * @param frustumPlanes defines the frustum to test
  25453. * @returns true if the mesh is completely in the frustum planes
  25454. */
  25455. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25456. /**
  25457. * True if the mesh intersects another mesh or a SolidParticle object
  25458. * @param mesh defines a target mesh or SolidParticle to test
  25459. * @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)
  25460. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25461. * @returns true if there is an intersection
  25462. */
  25463. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25464. /**
  25465. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25466. * @param point defines the point to test
  25467. * @returns true if there is an intersection
  25468. */
  25469. intersectsPoint(point: Vector3): boolean;
  25470. /**
  25471. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25472. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25473. */
  25474. checkCollisions: boolean;
  25475. /**
  25476. * Gets Collider object used to compute collisions (not physics)
  25477. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25478. */
  25479. readonly collider: Nullable<Collider>;
  25480. /**
  25481. * Move the mesh using collision engine
  25482. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25483. * @param displacement defines the requested displacement vector
  25484. * @returns the current mesh
  25485. */
  25486. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25487. private _onCollisionPositionChange;
  25488. /** @hidden */
  25489. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25490. /** @hidden */
  25491. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25492. /** @hidden */
  25493. _checkCollision(collider: Collider): AbstractMesh;
  25494. /** @hidden */
  25495. _generatePointsArray(): boolean;
  25496. /**
  25497. * Checks if the passed Ray intersects with the mesh
  25498. * @param ray defines the ray to use
  25499. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25500. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25501. * @returns the picking info
  25502. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25503. */
  25504. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25505. /**
  25506. * Clones the current mesh
  25507. * @param name defines the mesh name
  25508. * @param newParent defines the new mesh parent
  25509. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25510. * @returns the new mesh
  25511. */
  25512. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25513. /**
  25514. * Disposes all the submeshes of the current meshnp
  25515. * @returns the current mesh
  25516. */
  25517. releaseSubMeshes(): AbstractMesh;
  25518. /**
  25519. * Releases resources associated with this abstract mesh.
  25520. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25521. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25522. */
  25523. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25524. /**
  25525. * Adds the passed mesh as a child to the current mesh
  25526. * @param mesh defines the child mesh
  25527. * @returns the current mesh
  25528. */
  25529. addChild(mesh: AbstractMesh): AbstractMesh;
  25530. /**
  25531. * Removes the passed mesh from the current mesh children list
  25532. * @param mesh defines the child mesh
  25533. * @returns the current mesh
  25534. */
  25535. removeChild(mesh: AbstractMesh): AbstractMesh;
  25536. /** @hidden */
  25537. private _initFacetData;
  25538. /**
  25539. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25540. * This method can be called within the render loop.
  25541. * 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
  25542. * @returns the current mesh
  25543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25544. */
  25545. updateFacetData(): AbstractMesh;
  25546. /**
  25547. * Returns the facetLocalNormals array.
  25548. * The normals are expressed in the mesh local spac
  25549. * @returns an array of Vector3
  25550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25551. */
  25552. getFacetLocalNormals(): Vector3[];
  25553. /**
  25554. * Returns the facetLocalPositions array.
  25555. * The facet positions are expressed in the mesh local space
  25556. * @returns an array of Vector3
  25557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25558. */
  25559. getFacetLocalPositions(): Vector3[];
  25560. /**
  25561. * Returns the facetLocalPartioning array
  25562. * @returns an array of array of numbers
  25563. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25564. */
  25565. getFacetLocalPartitioning(): number[][];
  25566. /**
  25567. * Returns the i-th facet position in the world system.
  25568. * This method allocates a new Vector3 per call
  25569. * @param i defines the facet index
  25570. * @returns a new Vector3
  25571. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25572. */
  25573. getFacetPosition(i: number): Vector3;
  25574. /**
  25575. * Sets the reference Vector3 with the i-th facet position in the world system
  25576. * @param i defines the facet index
  25577. * @param ref defines the target vector
  25578. * @returns the current mesh
  25579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25580. */
  25581. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25582. /**
  25583. * Returns the i-th facet normal in the world system.
  25584. * This method allocates a new Vector3 per call
  25585. * @param i defines the facet index
  25586. * @returns a new Vector3
  25587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25588. */
  25589. getFacetNormal(i: number): Vector3;
  25590. /**
  25591. * Sets the reference Vector3 with the i-th facet normal in the world system
  25592. * @param i defines the facet index
  25593. * @param ref defines the target vector
  25594. * @returns the current mesh
  25595. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25596. */
  25597. getFacetNormalToRef(i: number, ref: Vector3): this;
  25598. /**
  25599. * 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)
  25600. * @param x defines x coordinate
  25601. * @param y defines y coordinate
  25602. * @param z defines z coordinate
  25603. * @returns the array of facet indexes
  25604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25605. */
  25606. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25607. /**
  25608. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25609. * @param projected sets as the (x,y,z) world 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. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25619. /**
  25620. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25621. * @param projected sets as the (x,y,z) local projection on the facet
  25622. * @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
  25623. * @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
  25624. * @param x defines x coordinate
  25625. * @param y defines y coordinate
  25626. * @param z defines z coordinate
  25627. * @returns the face index if found (or null instead)
  25628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25629. */
  25630. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25631. /**
  25632. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25633. * @returns the parameters
  25634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25635. */
  25636. getFacetDataParameters(): any;
  25637. /**
  25638. * Disables the feature FacetData and frees the related memory
  25639. * @returns the current mesh
  25640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25641. */
  25642. disableFacetData(): AbstractMesh;
  25643. /**
  25644. * Updates the AbstractMesh indices array
  25645. * @param indices defines the data source
  25646. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25647. * @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)
  25648. * @returns the current mesh
  25649. */
  25650. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25651. /**
  25652. * Creates new normals data for the mesh
  25653. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25654. * @returns the current mesh
  25655. */
  25656. createNormals(updatable: boolean): AbstractMesh;
  25657. /**
  25658. * Align the mesh with a normal
  25659. * @param normal defines the normal to use
  25660. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25661. * @returns the current mesh
  25662. */
  25663. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25664. /** @hidden */
  25665. _checkOcclusionQuery(): boolean;
  25666. }
  25667. }
  25668. declare module "babylonjs/Actions/actionEvent" {
  25669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25670. import { Nullable } from "babylonjs/types";
  25671. import { Sprite } from "babylonjs/Sprites/sprite";
  25672. import { Scene } from "babylonjs/scene";
  25673. import { Vector2 } from "babylonjs/Maths/math";
  25674. /**
  25675. * Interface used to define ActionEvent
  25676. */
  25677. export interface IActionEvent {
  25678. /** The mesh or sprite that triggered the action */
  25679. source: any;
  25680. /** The X mouse cursor position at the time of the event */
  25681. pointerX: number;
  25682. /** The Y mouse cursor position at the time of the event */
  25683. pointerY: number;
  25684. /** The mesh that is currently pointed at (can be null) */
  25685. meshUnderPointer: Nullable<AbstractMesh>;
  25686. /** the original (browser) event that triggered the ActionEvent */
  25687. sourceEvent?: any;
  25688. /** additional data for the event */
  25689. additionalData?: any;
  25690. }
  25691. /**
  25692. * ActionEvent is the event being sent when an action is triggered.
  25693. */
  25694. export class ActionEvent implements IActionEvent {
  25695. /** The mesh or sprite that triggered the action */
  25696. source: any;
  25697. /** The X mouse cursor position at the time of the event */
  25698. pointerX: number;
  25699. /** The Y mouse cursor position at the time of the event */
  25700. pointerY: number;
  25701. /** The mesh that is currently pointed at (can be null) */
  25702. meshUnderPointer: Nullable<AbstractMesh>;
  25703. /** the original (browser) event that triggered the ActionEvent */
  25704. sourceEvent?: any;
  25705. /** additional data for the event */
  25706. additionalData?: any;
  25707. /**
  25708. * Creates a new ActionEvent
  25709. * @param source The mesh or sprite that triggered the action
  25710. * @param pointerX The X mouse cursor position at the time of the event
  25711. * @param pointerY The Y mouse cursor position at the time of the event
  25712. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25713. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25714. * @param additionalData additional data for the event
  25715. */
  25716. constructor(
  25717. /** The mesh or sprite that triggered the action */
  25718. source: any,
  25719. /** The X mouse cursor position at the time of the event */
  25720. pointerX: number,
  25721. /** The Y mouse cursor position at the time of the event */
  25722. pointerY: number,
  25723. /** The mesh that is currently pointed at (can be null) */
  25724. meshUnderPointer: Nullable<AbstractMesh>,
  25725. /** the original (browser) event that triggered the ActionEvent */
  25726. sourceEvent?: any,
  25727. /** additional data for the event */
  25728. additionalData?: any);
  25729. /**
  25730. * Helper function to auto-create an ActionEvent from a source mesh.
  25731. * @param source The source mesh that triggered the event
  25732. * @param evt The original (browser) event
  25733. * @param additionalData additional data for the event
  25734. * @returns the new ActionEvent
  25735. */
  25736. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25737. /**
  25738. * Helper function to auto-create an ActionEvent from a source sprite
  25739. * @param source The source sprite that triggered the event
  25740. * @param scene Scene associated with the sprite
  25741. * @param evt The original (browser) event
  25742. * @param additionalData additional data for the event
  25743. * @returns the new ActionEvent
  25744. */
  25745. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25746. /**
  25747. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25748. * @param scene the scene where the event occurred
  25749. * @param evt The original (browser) event
  25750. * @returns the new ActionEvent
  25751. */
  25752. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25753. /**
  25754. * Helper function to auto-create an ActionEvent from a primitive
  25755. * @param prim defines the target primitive
  25756. * @param pointerPos defines the pointer position
  25757. * @param evt The original (browser) event
  25758. * @param additionalData additional data for the event
  25759. * @returns the new ActionEvent
  25760. */
  25761. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25762. }
  25763. }
  25764. declare module "babylonjs/Actions/abstractActionManager" {
  25765. import { IDisposable } from "babylonjs/scene";
  25766. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25767. import { IAction } from "babylonjs/Actions/action";
  25768. import { Nullable } from "babylonjs/types";
  25769. /**
  25770. * Abstract class used to decouple action Manager from scene and meshes.
  25771. * Do not instantiate.
  25772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25773. */
  25774. export abstract class AbstractActionManager implements IDisposable {
  25775. /** Gets the list of active triggers */
  25776. static Triggers: {
  25777. [key: string]: number;
  25778. };
  25779. /** Gets the cursor to use when hovering items */
  25780. hoverCursor: string;
  25781. /** Gets the list of actions */
  25782. actions: IAction[];
  25783. /**
  25784. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25785. */
  25786. isRecursive: boolean;
  25787. /**
  25788. * Releases all associated resources
  25789. */
  25790. abstract dispose(): void;
  25791. /**
  25792. * Does this action manager has pointer triggers
  25793. */
  25794. abstract readonly hasPointerTriggers: boolean;
  25795. /**
  25796. * Does this action manager has pick triggers
  25797. */
  25798. abstract readonly hasPickTriggers: boolean;
  25799. /**
  25800. * Process a specific trigger
  25801. * @param trigger defines the trigger to process
  25802. * @param evt defines the event details to be processed
  25803. */
  25804. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25805. /**
  25806. * Does this action manager handles actions of any of the given triggers
  25807. * @param triggers defines the triggers to be tested
  25808. * @return a boolean indicating whether one (or more) of the triggers is handled
  25809. */
  25810. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25811. /**
  25812. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25813. * speed.
  25814. * @param triggerA defines the trigger to be tested
  25815. * @param triggerB defines the trigger to be tested
  25816. * @return a boolean indicating whether one (or more) of the triggers is handled
  25817. */
  25818. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25819. /**
  25820. * Does this action manager handles actions of a given trigger
  25821. * @param trigger defines the trigger to be tested
  25822. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25823. * @return whether the trigger is handled
  25824. */
  25825. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25826. /**
  25827. * Serialize this manager to a JSON object
  25828. * @param name defines the property name to store this manager
  25829. * @returns a JSON representation of this manager
  25830. */
  25831. abstract serialize(name: string): any;
  25832. /**
  25833. * Registers an action to this action manager
  25834. * @param action defines the action to be registered
  25835. * @return the action amended (prepared) after registration
  25836. */
  25837. abstract registerAction(action: IAction): Nullable<IAction>;
  25838. /**
  25839. * Unregisters an action to this action manager
  25840. * @param action defines the action to be unregistered
  25841. * @return a boolean indicating whether the action has been unregistered
  25842. */
  25843. abstract unregisterAction(action: IAction): Boolean;
  25844. /**
  25845. * Does exist one action manager with at least one trigger
  25846. **/
  25847. static readonly HasTriggers: boolean;
  25848. /**
  25849. * Does exist one action manager with at least one pick trigger
  25850. **/
  25851. static readonly HasPickTriggers: boolean;
  25852. /**
  25853. * Does exist one action manager that handles actions of a given trigger
  25854. * @param trigger defines the trigger to be tested
  25855. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25856. **/
  25857. static HasSpecificTrigger(trigger: number): boolean;
  25858. }
  25859. }
  25860. declare module "babylonjs/node" {
  25861. import { Scene } from "babylonjs/scene";
  25862. import { Nullable } from "babylonjs/types";
  25863. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25864. import { Engine } from "babylonjs/Engines/engine";
  25865. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25866. import { Observable } from "babylonjs/Misc/observable";
  25867. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25868. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25869. import { Animatable } from "babylonjs/Animations/animatable";
  25870. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25871. import { Animation } from "babylonjs/Animations/animation";
  25872. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25874. /**
  25875. * Defines how a node can be built from a string name.
  25876. */
  25877. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25878. /**
  25879. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25880. */
  25881. export class Node implements IBehaviorAware<Node> {
  25882. /** @hidden */
  25883. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25884. private static _NodeConstructors;
  25885. /**
  25886. * Add a new node constructor
  25887. * @param type defines the type name of the node to construct
  25888. * @param constructorFunc defines the constructor function
  25889. */
  25890. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25891. /**
  25892. * Returns a node constructor based on type name
  25893. * @param type defines the type name
  25894. * @param name defines the new node name
  25895. * @param scene defines the hosting scene
  25896. * @param options defines optional options to transmit to constructors
  25897. * @returns the new constructor or null
  25898. */
  25899. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25900. /**
  25901. * Gets or sets the name of the node
  25902. */
  25903. name: string;
  25904. /**
  25905. * Gets or sets the id of the node
  25906. */
  25907. id: string;
  25908. /**
  25909. * Gets or sets the unique id of the node
  25910. */
  25911. uniqueId: number;
  25912. /**
  25913. * Gets or sets a string used to store user defined state for the node
  25914. */
  25915. state: string;
  25916. /**
  25917. * Gets or sets an object used to store user defined information for the node
  25918. */
  25919. metadata: any;
  25920. /**
  25921. * For internal use only. Please do not use.
  25922. */
  25923. reservedDataStore: any;
  25924. /**
  25925. * List of inspectable custom properties (used by the Inspector)
  25926. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25927. */
  25928. inspectableCustomProperties: IInspectable[];
  25929. /**
  25930. * Gets or sets a boolean used to define if the node must be serialized
  25931. */
  25932. doNotSerialize: boolean;
  25933. /** @hidden */
  25934. _isDisposed: boolean;
  25935. /**
  25936. * Gets a list of Animations associated with the node
  25937. */
  25938. animations: import("babylonjs/Animations/animation").Animation[];
  25939. protected _ranges: {
  25940. [name: string]: Nullable<AnimationRange>;
  25941. };
  25942. /**
  25943. * Callback raised when the node is ready to be used
  25944. */
  25945. onReady: Nullable<(node: Node) => void>;
  25946. private _isEnabled;
  25947. private _isParentEnabled;
  25948. private _isReady;
  25949. /** @hidden */
  25950. _currentRenderId: number;
  25951. private _parentUpdateId;
  25952. /** @hidden */
  25953. _childUpdateId: number;
  25954. /** @hidden */
  25955. _waitingParentId: Nullable<string>;
  25956. /** @hidden */
  25957. _scene: Scene;
  25958. /** @hidden */
  25959. _cache: any;
  25960. private _parentNode;
  25961. private _children;
  25962. /** @hidden */
  25963. _worldMatrix: Matrix;
  25964. /** @hidden */
  25965. _worldMatrixDeterminant: number;
  25966. /** @hidden */
  25967. _worldMatrixDeterminantIsDirty: boolean;
  25968. /** @hidden */
  25969. private _sceneRootNodesIndex;
  25970. /**
  25971. * Gets a boolean indicating if the node has been disposed
  25972. * @returns true if the node was disposed
  25973. */
  25974. isDisposed(): boolean;
  25975. /**
  25976. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25977. * @see https://doc.babylonjs.com/how_to/parenting
  25978. */
  25979. parent: Nullable<Node>;
  25980. private addToSceneRootNodes;
  25981. private removeFromSceneRootNodes;
  25982. private _animationPropertiesOverride;
  25983. /**
  25984. * Gets or sets the animation properties override
  25985. */
  25986. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25987. /**
  25988. * Gets a string idenfifying the name of the class
  25989. * @returns "Node" string
  25990. */
  25991. getClassName(): string;
  25992. /** @hidden */
  25993. readonly _isNode: boolean;
  25994. /**
  25995. * An event triggered when the mesh is disposed
  25996. */
  25997. onDisposeObservable: Observable<Node>;
  25998. private _onDisposeObserver;
  25999. /**
  26000. * Sets a callback that will be raised when the node will be disposed
  26001. */
  26002. onDispose: () => void;
  26003. /**
  26004. * Creates a new Node
  26005. * @param name the name and id to be given to this node
  26006. * @param scene the scene this node will be added to
  26007. * @param addToRootNodes the node will be added to scene.rootNodes
  26008. */
  26009. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26010. /**
  26011. * Gets the scene of the node
  26012. * @returns a scene
  26013. */
  26014. getScene(): Scene;
  26015. /**
  26016. * Gets the engine of the node
  26017. * @returns a Engine
  26018. */
  26019. getEngine(): Engine;
  26020. private _behaviors;
  26021. /**
  26022. * Attach a behavior to the node
  26023. * @see http://doc.babylonjs.com/features/behaviour
  26024. * @param behavior defines the behavior to attach
  26025. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26026. * @returns the current Node
  26027. */
  26028. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26029. /**
  26030. * Remove an attached behavior
  26031. * @see http://doc.babylonjs.com/features/behaviour
  26032. * @param behavior defines the behavior to attach
  26033. * @returns the current Node
  26034. */
  26035. removeBehavior(behavior: Behavior<Node>): Node;
  26036. /**
  26037. * Gets the list of attached behaviors
  26038. * @see http://doc.babylonjs.com/features/behaviour
  26039. */
  26040. readonly behaviors: Behavior<Node>[];
  26041. /**
  26042. * Gets an attached behavior by name
  26043. * @param name defines the name of the behavior to look for
  26044. * @see http://doc.babylonjs.com/features/behaviour
  26045. * @returns null if behavior was not found else the requested behavior
  26046. */
  26047. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26048. /**
  26049. * Returns the latest update of the World matrix
  26050. * @returns a Matrix
  26051. */
  26052. getWorldMatrix(): Matrix;
  26053. /** @hidden */
  26054. _getWorldMatrixDeterminant(): number;
  26055. /**
  26056. * Returns directly the latest state of the mesh World matrix.
  26057. * A Matrix is returned.
  26058. */
  26059. readonly worldMatrixFromCache: Matrix;
  26060. /** @hidden */
  26061. _initCache(): void;
  26062. /** @hidden */
  26063. updateCache(force?: boolean): void;
  26064. /** @hidden */
  26065. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26066. /** @hidden */
  26067. _updateCache(ignoreParentClass?: boolean): void;
  26068. /** @hidden */
  26069. _isSynchronized(): boolean;
  26070. /** @hidden */
  26071. _markSyncedWithParent(): void;
  26072. /** @hidden */
  26073. isSynchronizedWithParent(): boolean;
  26074. /** @hidden */
  26075. isSynchronized(): boolean;
  26076. /**
  26077. * Is this node ready to be used/rendered
  26078. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26079. * @return true if the node is ready
  26080. */
  26081. isReady(completeCheck?: boolean): boolean;
  26082. /**
  26083. * Is this node enabled?
  26084. * 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
  26085. * @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
  26086. * @return whether this node (and its parent) is enabled
  26087. */
  26088. isEnabled(checkAncestors?: boolean): boolean;
  26089. /** @hidden */
  26090. protected _syncParentEnabledState(): void;
  26091. /**
  26092. * Set the enabled state of this node
  26093. * @param value defines the new enabled state
  26094. */
  26095. setEnabled(value: boolean): void;
  26096. /**
  26097. * Is this node a descendant of the given node?
  26098. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26099. * @param ancestor defines the parent node to inspect
  26100. * @returns a boolean indicating if this node is a descendant of the given node
  26101. */
  26102. isDescendantOf(ancestor: Node): boolean;
  26103. /** @hidden */
  26104. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26105. /**
  26106. * Will return all nodes that have this node as ascendant
  26107. * @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
  26108. * @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
  26109. * @return all children nodes of all types
  26110. */
  26111. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26112. /**
  26113. * Get all child-meshes of this node
  26114. * @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)
  26115. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  26116. * @returns an array of AbstractMesh
  26117. */
  26118. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26119. /**
  26120. * Get all direct children of this node
  26121. * @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
  26122. * @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)
  26123. * @returns an array of Node
  26124. */
  26125. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26126. /** @hidden */
  26127. _setReady(state: boolean): void;
  26128. /**
  26129. * Get an animation by name
  26130. * @param name defines the name of the animation to look for
  26131. * @returns null if not found else the requested animation
  26132. */
  26133. getAnimationByName(name: string): Nullable<Animation>;
  26134. /**
  26135. * Creates an animation range for this node
  26136. * @param name defines the name of the range
  26137. * @param from defines the starting key
  26138. * @param to defines the end key
  26139. */
  26140. createAnimationRange(name: string, from: number, to: number): void;
  26141. /**
  26142. * Delete a specific animation range
  26143. * @param name defines the name of the range to delete
  26144. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26145. */
  26146. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26147. /**
  26148. * Get an animation range by name
  26149. * @param name defines the name of the animation range to look for
  26150. * @returns null if not found else the requested animation range
  26151. */
  26152. getAnimationRange(name: string): Nullable<AnimationRange>;
  26153. /**
  26154. * Gets the list of all animation ranges defined on this node
  26155. * @returns an array
  26156. */
  26157. getAnimationRanges(): Nullable<AnimationRange>[];
  26158. /**
  26159. * Will start the animation sequence
  26160. * @param name defines the range frames for animation sequence
  26161. * @param loop defines if the animation should loop (false by default)
  26162. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26163. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26164. * @returns the object created for this animation. If range does not exist, it will return null
  26165. */
  26166. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26167. /**
  26168. * Serialize animation ranges into a JSON compatible object
  26169. * @returns serialization object
  26170. */
  26171. serializeAnimationRanges(): any;
  26172. /**
  26173. * Computes the world matrix of the node
  26174. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26175. * @returns the world matrix
  26176. */
  26177. computeWorldMatrix(force?: boolean): Matrix;
  26178. /**
  26179. * Releases resources associated with this node.
  26180. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26181. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26182. */
  26183. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26184. /**
  26185. * Parse animation range data from a serialization object and store them into a given node
  26186. * @param node defines where to store the animation ranges
  26187. * @param parsedNode defines the serialization object to read data from
  26188. * @param scene defines the hosting scene
  26189. */
  26190. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26191. /**
  26192. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26193. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26194. * @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
  26195. * @returns the new bounding vectors
  26196. */
  26197. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26198. min: Vector3;
  26199. max: Vector3;
  26200. };
  26201. }
  26202. }
  26203. declare module "babylonjs/Animations/animation" {
  26204. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26205. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26206. import { Nullable } from "babylonjs/types";
  26207. import { Scene } from "babylonjs/scene";
  26208. import { IAnimatable } from "babylonjs/Misc/tools";
  26209. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26210. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26211. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26212. import { Node } from "babylonjs/node";
  26213. import { Animatable } from "babylonjs/Animations/animatable";
  26214. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26215. /**
  26216. * @hidden
  26217. */
  26218. export class _IAnimationState {
  26219. key: number;
  26220. repeatCount: number;
  26221. workValue?: any;
  26222. loopMode?: number;
  26223. offsetValue?: any;
  26224. highLimitValue?: any;
  26225. }
  26226. /**
  26227. * Class used to store any kind of animation
  26228. */
  26229. export class Animation {
  26230. /**Name of the animation */
  26231. name: string;
  26232. /**Property to animate */
  26233. targetProperty: string;
  26234. /**The frames per second of the animation */
  26235. framePerSecond: number;
  26236. /**The data type of the animation */
  26237. dataType: number;
  26238. /**The loop mode of the animation */
  26239. loopMode?: number | undefined;
  26240. /**Specifies if blending should be enabled */
  26241. enableBlending?: boolean | undefined;
  26242. /**
  26243. * Use matrix interpolation instead of using direct key value when animating matrices
  26244. */
  26245. static AllowMatricesInterpolation: boolean;
  26246. /**
  26247. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26248. */
  26249. static AllowMatrixDecomposeForInterpolation: boolean;
  26250. /**
  26251. * Stores the key frames of the animation
  26252. */
  26253. private _keys;
  26254. /**
  26255. * Stores the easing function of the animation
  26256. */
  26257. private _easingFunction;
  26258. /**
  26259. * @hidden Internal use only
  26260. */
  26261. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26262. /**
  26263. * The set of event that will be linked to this animation
  26264. */
  26265. private _events;
  26266. /**
  26267. * Stores an array of target property paths
  26268. */
  26269. targetPropertyPath: string[];
  26270. /**
  26271. * Stores the blending speed of the animation
  26272. */
  26273. blendingSpeed: number;
  26274. /**
  26275. * Stores the animation ranges for the animation
  26276. */
  26277. private _ranges;
  26278. /**
  26279. * @hidden Internal use
  26280. */
  26281. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26282. /**
  26283. * Sets up an animation
  26284. * @param property The property to animate
  26285. * @param animationType The animation type to apply
  26286. * @param framePerSecond The frames per second of the animation
  26287. * @param easingFunction The easing function used in the animation
  26288. * @returns The created animation
  26289. */
  26290. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26291. /**
  26292. * Create and start an animation on a node
  26293. * @param name defines the name of the global animation that will be run on all nodes
  26294. * @param node defines the root node where the animation will take place
  26295. * @param targetProperty defines property to animate
  26296. * @param framePerSecond defines the number of frame per second yo use
  26297. * @param totalFrame defines the number of frames in total
  26298. * @param from defines the initial value
  26299. * @param to defines the final value
  26300. * @param loopMode defines which loop mode you want to use (off by default)
  26301. * @param easingFunction defines the easing function to use (linear by default)
  26302. * @param onAnimationEnd defines the callback to call when animation end
  26303. * @returns the animatable created for this animation
  26304. */
  26305. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26306. /**
  26307. * Create and start an animation on a node and its descendants
  26308. * @param name defines the name of the global animation that will be run on all nodes
  26309. * @param node defines the root node where the animation will take place
  26310. * @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
  26311. * @param targetProperty defines property to animate
  26312. * @param framePerSecond defines the number of frame per second to use
  26313. * @param totalFrame defines the number of frames in total
  26314. * @param from defines the initial value
  26315. * @param to defines the final value
  26316. * @param loopMode defines which loop mode you want to use (off by default)
  26317. * @param easingFunction defines the easing function to use (linear by default)
  26318. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26319. * @returns the list of animatables created for all nodes
  26320. * @example https://www.babylonjs-playground.com/#MH0VLI
  26321. */
  26322. 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[]>;
  26323. /**
  26324. * Creates a new animation, merges it with the existing animations and starts it
  26325. * @param name Name of the animation
  26326. * @param node Node which contains the scene that begins the animations
  26327. * @param targetProperty Specifies which property to animate
  26328. * @param framePerSecond The frames per second of the animation
  26329. * @param totalFrame The total number of frames
  26330. * @param from The frame at the beginning of the animation
  26331. * @param to The frame at the end of the animation
  26332. * @param loopMode Specifies the loop mode of the animation
  26333. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26334. * @param onAnimationEnd Callback to run once the animation is complete
  26335. * @returns Nullable animation
  26336. */
  26337. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26338. /**
  26339. * Transition property of an host to the target Value
  26340. * @param property The property to transition
  26341. * @param targetValue The target Value of the property
  26342. * @param host The object where the property to animate belongs
  26343. * @param scene Scene used to run the animation
  26344. * @param frameRate Framerate (in frame/s) to use
  26345. * @param transition The transition type we want to use
  26346. * @param duration The duration of the animation, in milliseconds
  26347. * @param onAnimationEnd Callback trigger at the end of the animation
  26348. * @returns Nullable animation
  26349. */
  26350. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26351. /**
  26352. * Return the array of runtime animations currently using this animation
  26353. */
  26354. readonly runtimeAnimations: RuntimeAnimation[];
  26355. /**
  26356. * Specifies if any of the runtime animations are currently running
  26357. */
  26358. readonly hasRunningRuntimeAnimations: boolean;
  26359. /**
  26360. * Initializes the animation
  26361. * @param name Name of the animation
  26362. * @param targetProperty Property to animate
  26363. * @param framePerSecond The frames per second of the animation
  26364. * @param dataType The data type of the animation
  26365. * @param loopMode The loop mode of the animation
  26366. * @param enableBlending Specifies if blending should be enabled
  26367. */
  26368. constructor(
  26369. /**Name of the animation */
  26370. name: string,
  26371. /**Property to animate */
  26372. targetProperty: string,
  26373. /**The frames per second of the animation */
  26374. framePerSecond: number,
  26375. /**The data type of the animation */
  26376. dataType: number,
  26377. /**The loop mode of the animation */
  26378. loopMode?: number | undefined,
  26379. /**Specifies if blending should be enabled */
  26380. enableBlending?: boolean | undefined);
  26381. /**
  26382. * Converts the animation to a string
  26383. * @param fullDetails support for multiple levels of logging within scene loading
  26384. * @returns String form of the animation
  26385. */
  26386. toString(fullDetails?: boolean): string;
  26387. /**
  26388. * Add an event to this animation
  26389. * @param event Event to add
  26390. */
  26391. addEvent(event: AnimationEvent): void;
  26392. /**
  26393. * Remove all events found at the given frame
  26394. * @param frame The frame to remove events from
  26395. */
  26396. removeEvents(frame: number): void;
  26397. /**
  26398. * Retrieves all the events from the animation
  26399. * @returns Events from the animation
  26400. */
  26401. getEvents(): AnimationEvent[];
  26402. /**
  26403. * Creates an animation range
  26404. * @param name Name of the animation range
  26405. * @param from Starting frame of the animation range
  26406. * @param to Ending frame of the animation
  26407. */
  26408. createRange(name: string, from: number, to: number): void;
  26409. /**
  26410. * Deletes an animation range by name
  26411. * @param name Name of the animation range to delete
  26412. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26413. */
  26414. deleteRange(name: string, deleteFrames?: boolean): void;
  26415. /**
  26416. * Gets the animation range by name, or null if not defined
  26417. * @param name Name of the animation range
  26418. * @returns Nullable animation range
  26419. */
  26420. getRange(name: string): Nullable<AnimationRange>;
  26421. /**
  26422. * Gets the key frames from the animation
  26423. * @returns The key frames of the animation
  26424. */
  26425. getKeys(): Array<IAnimationKey>;
  26426. /**
  26427. * Gets the highest frame rate of the animation
  26428. * @returns Highest frame rate of the animation
  26429. */
  26430. getHighestFrame(): number;
  26431. /**
  26432. * Gets the easing function of the animation
  26433. * @returns Easing function of the animation
  26434. */
  26435. getEasingFunction(): IEasingFunction;
  26436. /**
  26437. * Sets the easing function of the animation
  26438. * @param easingFunction A custom mathematical formula for animation
  26439. */
  26440. setEasingFunction(easingFunction: EasingFunction): void;
  26441. /**
  26442. * Interpolates a scalar linearly
  26443. * @param startValue Start value of the animation curve
  26444. * @param endValue End value of the animation curve
  26445. * @param gradient Scalar amount to interpolate
  26446. * @returns Interpolated scalar value
  26447. */
  26448. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26449. /**
  26450. * Interpolates a scalar cubically
  26451. * @param startValue Start value of the animation curve
  26452. * @param outTangent End tangent of the animation
  26453. * @param endValue End value of the animation curve
  26454. * @param inTangent Start tangent of the animation curve
  26455. * @param gradient Scalar amount to interpolate
  26456. * @returns Interpolated scalar value
  26457. */
  26458. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26459. /**
  26460. * Interpolates a quaternion using a spherical linear interpolation
  26461. * @param startValue Start value of the animation curve
  26462. * @param endValue End value of the animation curve
  26463. * @param gradient Scalar amount to interpolate
  26464. * @returns Interpolated quaternion value
  26465. */
  26466. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26467. /**
  26468. * Interpolates a quaternion cubically
  26469. * @param startValue Start value of the animation curve
  26470. * @param outTangent End tangent of the animation curve
  26471. * @param endValue End value of the animation curve
  26472. * @param inTangent Start tangent of the animation curve
  26473. * @param gradient Scalar amount to interpolate
  26474. * @returns Interpolated quaternion value
  26475. */
  26476. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26477. /**
  26478. * Interpolates a Vector3 linearl
  26479. * @param startValue Start value of the animation curve
  26480. * @param endValue End value of the animation curve
  26481. * @param gradient Scalar amount to interpolate
  26482. * @returns Interpolated scalar value
  26483. */
  26484. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26485. /**
  26486. * Interpolates a Vector3 cubically
  26487. * @param startValue Start value of the animation curve
  26488. * @param outTangent End tangent of the animation
  26489. * @param endValue End value of the animation curve
  26490. * @param inTangent Start tangent of the animation curve
  26491. * @param gradient Scalar amount to interpolate
  26492. * @returns InterpolatedVector3 value
  26493. */
  26494. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26495. /**
  26496. * Interpolates a Vector2 linearly
  26497. * @param startValue Start value of the animation curve
  26498. * @param endValue End value of the animation curve
  26499. * @param gradient Scalar amount to interpolate
  26500. * @returns Interpolated Vector2 value
  26501. */
  26502. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26503. /**
  26504. * Interpolates a Vector2 cubically
  26505. * @param startValue Start value of the animation curve
  26506. * @param outTangent End tangent of the animation
  26507. * @param endValue End value of the animation curve
  26508. * @param inTangent Start tangent of the animation curve
  26509. * @param gradient Scalar amount to interpolate
  26510. * @returns Interpolated Vector2 value
  26511. */
  26512. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26513. /**
  26514. * Interpolates a size linearly
  26515. * @param startValue Start value of the animation curve
  26516. * @param endValue End value of the animation curve
  26517. * @param gradient Scalar amount to interpolate
  26518. * @returns Interpolated Size value
  26519. */
  26520. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26521. /**
  26522. * Interpolates a Color3 linearly
  26523. * @param startValue Start value of the animation curve
  26524. * @param endValue End value of the animation curve
  26525. * @param gradient Scalar amount to interpolate
  26526. * @returns Interpolated Color3 value
  26527. */
  26528. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26529. /**
  26530. * @hidden Internal use only
  26531. */
  26532. _getKeyValue(value: any): any;
  26533. /**
  26534. * @hidden Internal use only
  26535. */
  26536. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26537. /**
  26538. * Defines the function to use to interpolate matrices
  26539. * @param startValue defines the start matrix
  26540. * @param endValue defines the end matrix
  26541. * @param gradient defines the gradient between both matrices
  26542. * @param result defines an optional target matrix where to store the interpolation
  26543. * @returns the interpolated matrix
  26544. */
  26545. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26546. /**
  26547. * Makes a copy of the animation
  26548. * @returns Cloned animation
  26549. */
  26550. clone(): Animation;
  26551. /**
  26552. * Sets the key frames of the animation
  26553. * @param values The animation key frames to set
  26554. */
  26555. setKeys(values: Array<IAnimationKey>): void;
  26556. /**
  26557. * Serializes the animation to an object
  26558. * @returns Serialized object
  26559. */
  26560. serialize(): any;
  26561. /**
  26562. * Float animation type
  26563. */
  26564. private static _ANIMATIONTYPE_FLOAT;
  26565. /**
  26566. * Vector3 animation type
  26567. */
  26568. private static _ANIMATIONTYPE_VECTOR3;
  26569. /**
  26570. * Quaternion animation type
  26571. */
  26572. private static _ANIMATIONTYPE_QUATERNION;
  26573. /**
  26574. * Matrix animation type
  26575. */
  26576. private static _ANIMATIONTYPE_MATRIX;
  26577. /**
  26578. * Color3 animation type
  26579. */
  26580. private static _ANIMATIONTYPE_COLOR3;
  26581. /**
  26582. * Vector2 animation type
  26583. */
  26584. private static _ANIMATIONTYPE_VECTOR2;
  26585. /**
  26586. * Size animation type
  26587. */
  26588. private static _ANIMATIONTYPE_SIZE;
  26589. /**
  26590. * Relative Loop Mode
  26591. */
  26592. private static _ANIMATIONLOOPMODE_RELATIVE;
  26593. /**
  26594. * Cycle Loop Mode
  26595. */
  26596. private static _ANIMATIONLOOPMODE_CYCLE;
  26597. /**
  26598. * Constant Loop Mode
  26599. */
  26600. private static _ANIMATIONLOOPMODE_CONSTANT;
  26601. /**
  26602. * Get the float animation type
  26603. */
  26604. static readonly ANIMATIONTYPE_FLOAT: number;
  26605. /**
  26606. * Get the Vector3 animation type
  26607. */
  26608. static readonly ANIMATIONTYPE_VECTOR3: number;
  26609. /**
  26610. * Get the Vector2 animation type
  26611. */
  26612. static readonly ANIMATIONTYPE_VECTOR2: number;
  26613. /**
  26614. * Get the Size animation type
  26615. */
  26616. static readonly ANIMATIONTYPE_SIZE: number;
  26617. /**
  26618. * Get the Quaternion animation type
  26619. */
  26620. static readonly ANIMATIONTYPE_QUATERNION: number;
  26621. /**
  26622. * Get the Matrix animation type
  26623. */
  26624. static readonly ANIMATIONTYPE_MATRIX: number;
  26625. /**
  26626. * Get the Color3 animation type
  26627. */
  26628. static readonly ANIMATIONTYPE_COLOR3: number;
  26629. /**
  26630. * Get the Relative Loop Mode
  26631. */
  26632. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26633. /**
  26634. * Get the Cycle Loop Mode
  26635. */
  26636. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26637. /**
  26638. * Get the Constant Loop Mode
  26639. */
  26640. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26641. /** @hidden */
  26642. static _UniversalLerp(left: any, right: any, amount: number): any;
  26643. /**
  26644. * Parses an animation object and creates an animation
  26645. * @param parsedAnimation Parsed animation object
  26646. * @returns Animation object
  26647. */
  26648. static Parse(parsedAnimation: any): Animation;
  26649. /**
  26650. * Appends the serialized animations from the source animations
  26651. * @param source Source containing the animations
  26652. * @param destination Target to store the animations
  26653. */
  26654. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26655. }
  26656. }
  26657. declare module "babylonjs/Materials/Textures/baseTexture" {
  26658. import { Observable } from "babylonjs/Misc/observable";
  26659. import { IAnimatable } from "babylonjs/Misc/tools";
  26660. import { Nullable } from "babylonjs/types";
  26661. import { Scene } from "babylonjs/scene";
  26662. import { Matrix, ISize } from "babylonjs/Maths/math";
  26663. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26665. /**
  26666. * Base class of all the textures in babylon.
  26667. * It groups all the common properties the materials, post process, lights... might need
  26668. * in order to make a correct use of the texture.
  26669. */
  26670. export class BaseTexture implements IAnimatable {
  26671. /**
  26672. * Default anisotropic filtering level for the application.
  26673. * It is set to 4 as a good tradeoff between perf and quality.
  26674. */
  26675. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26676. /**
  26677. * Gets or sets the unique id of the texture
  26678. */
  26679. uniqueId: number;
  26680. /**
  26681. * Define the name of the texture.
  26682. */
  26683. name: string;
  26684. /**
  26685. * Gets or sets an object used to store user defined information.
  26686. */
  26687. metadata: any;
  26688. /**
  26689. * For internal use only. Please do not use.
  26690. */
  26691. reservedDataStore: any;
  26692. private _hasAlpha;
  26693. /**
  26694. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26695. */
  26696. hasAlpha: boolean;
  26697. /**
  26698. * Defines if the alpha value should be determined via the rgb values.
  26699. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26700. */
  26701. getAlphaFromRGB: boolean;
  26702. /**
  26703. * Intensity or strength of the texture.
  26704. * It is commonly used by materials to fine tune the intensity of the texture
  26705. */
  26706. level: number;
  26707. /**
  26708. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26709. * This is part of the texture as textures usually maps to one uv set.
  26710. */
  26711. coordinatesIndex: number;
  26712. private _coordinatesMode;
  26713. /**
  26714. * How a texture is mapped.
  26715. *
  26716. * | Value | Type | Description |
  26717. * | ----- | ----------------------------------- | ----------- |
  26718. * | 0 | EXPLICIT_MODE | |
  26719. * | 1 | SPHERICAL_MODE | |
  26720. * | 2 | PLANAR_MODE | |
  26721. * | 3 | CUBIC_MODE | |
  26722. * | 4 | PROJECTION_MODE | |
  26723. * | 5 | SKYBOX_MODE | |
  26724. * | 6 | INVCUBIC_MODE | |
  26725. * | 7 | EQUIRECTANGULAR_MODE | |
  26726. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26727. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26728. */
  26729. coordinatesMode: number;
  26730. /**
  26731. * | Value | Type | Description |
  26732. * | ----- | ------------------ | ----------- |
  26733. * | 0 | CLAMP_ADDRESSMODE | |
  26734. * | 1 | WRAP_ADDRESSMODE | |
  26735. * | 2 | MIRROR_ADDRESSMODE | |
  26736. */
  26737. wrapU: number;
  26738. /**
  26739. * | Value | Type | Description |
  26740. * | ----- | ------------------ | ----------- |
  26741. * | 0 | CLAMP_ADDRESSMODE | |
  26742. * | 1 | WRAP_ADDRESSMODE | |
  26743. * | 2 | MIRROR_ADDRESSMODE | |
  26744. */
  26745. wrapV: number;
  26746. /**
  26747. * | Value | Type | Description |
  26748. * | ----- | ------------------ | ----------- |
  26749. * | 0 | CLAMP_ADDRESSMODE | |
  26750. * | 1 | WRAP_ADDRESSMODE | |
  26751. * | 2 | MIRROR_ADDRESSMODE | |
  26752. */
  26753. wrapR: number;
  26754. /**
  26755. * With compliant hardware and browser (supporting anisotropic filtering)
  26756. * this defines the level of anisotropic filtering in the texture.
  26757. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26758. */
  26759. anisotropicFilteringLevel: number;
  26760. /**
  26761. * Define if the texture is a cube texture or if false a 2d texture.
  26762. */
  26763. isCube: boolean;
  26764. /**
  26765. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26766. */
  26767. is3D: boolean;
  26768. /**
  26769. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26770. * HDR texture are usually stored in linear space.
  26771. * This only impacts the PBR and Background materials
  26772. */
  26773. gammaSpace: boolean;
  26774. /**
  26775. * Gets whether or not the texture contains RGBD data.
  26776. */
  26777. readonly isRGBD: boolean;
  26778. /**
  26779. * Is Z inverted in the texture (useful in a cube texture).
  26780. */
  26781. invertZ: boolean;
  26782. /**
  26783. * Are mip maps generated for this texture or not.
  26784. */
  26785. readonly noMipmap: boolean;
  26786. /**
  26787. * @hidden
  26788. */
  26789. lodLevelInAlpha: boolean;
  26790. /**
  26791. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26792. */
  26793. lodGenerationOffset: number;
  26794. /**
  26795. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26796. */
  26797. lodGenerationScale: number;
  26798. /**
  26799. * Define if the texture is a render target.
  26800. */
  26801. isRenderTarget: boolean;
  26802. /**
  26803. * Define the unique id of the texture in the scene.
  26804. */
  26805. readonly uid: string;
  26806. /**
  26807. * Return a string representation of the texture.
  26808. * @returns the texture as a string
  26809. */
  26810. toString(): string;
  26811. /**
  26812. * Get the class name of the texture.
  26813. * @returns "BaseTexture"
  26814. */
  26815. getClassName(): string;
  26816. /**
  26817. * Define the list of animation attached to the texture.
  26818. */
  26819. animations: import("babylonjs/Animations/animation").Animation[];
  26820. /**
  26821. * An event triggered when the texture is disposed.
  26822. */
  26823. onDisposeObservable: Observable<BaseTexture>;
  26824. private _onDisposeObserver;
  26825. /**
  26826. * Callback triggered when the texture has been disposed.
  26827. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26828. */
  26829. onDispose: () => void;
  26830. /**
  26831. * Define the current state of the loading sequence when in delayed load mode.
  26832. */
  26833. delayLoadState: number;
  26834. private _scene;
  26835. /** @hidden */
  26836. _texture: Nullable<InternalTexture>;
  26837. private _uid;
  26838. /**
  26839. * Define if the texture is preventinga material to render or not.
  26840. * If not and the texture is not ready, the engine will use a default black texture instead.
  26841. */
  26842. readonly isBlocking: boolean;
  26843. /**
  26844. * Instantiates a new BaseTexture.
  26845. * Base class of all the textures in babylon.
  26846. * It groups all the common properties the materials, post process, lights... might need
  26847. * in order to make a correct use of the texture.
  26848. * @param scene Define the scene the texture blongs to
  26849. */
  26850. constructor(scene: Nullable<Scene>);
  26851. /**
  26852. * Get the scene the texture belongs to.
  26853. * @returns the scene or null if undefined
  26854. */
  26855. getScene(): Nullable<Scene>;
  26856. /**
  26857. * Get the texture transform matrix used to offset tile the texture for istance.
  26858. * @returns the transformation matrix
  26859. */
  26860. getTextureMatrix(): Matrix;
  26861. /**
  26862. * Get the texture reflection matrix used to rotate/transform the reflection.
  26863. * @returns the reflection matrix
  26864. */
  26865. getReflectionTextureMatrix(): Matrix;
  26866. /**
  26867. * Get the underlying lower level texture from Babylon.
  26868. * @returns the insternal texture
  26869. */
  26870. getInternalTexture(): Nullable<InternalTexture>;
  26871. /**
  26872. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26873. * @returns true if ready or not blocking
  26874. */
  26875. isReadyOrNotBlocking(): boolean;
  26876. /**
  26877. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26878. * @returns true if fully ready
  26879. */
  26880. isReady(): boolean;
  26881. private _cachedSize;
  26882. /**
  26883. * Get the size of the texture.
  26884. * @returns the texture size.
  26885. */
  26886. getSize(): ISize;
  26887. /**
  26888. * Get the base size of the texture.
  26889. * It can be different from the size if the texture has been resized for POT for instance
  26890. * @returns the base size
  26891. */
  26892. getBaseSize(): ISize;
  26893. /**
  26894. * Update the sampling mode of the texture.
  26895. * Default is Trilinear mode.
  26896. *
  26897. * | Value | Type | Description |
  26898. * | ----- | ------------------ | ----------- |
  26899. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26900. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26901. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26902. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26903. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26904. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26905. * | 7 | NEAREST_LINEAR | |
  26906. * | 8 | NEAREST_NEAREST | |
  26907. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26908. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26909. * | 11 | LINEAR_LINEAR | |
  26910. * | 12 | LINEAR_NEAREST | |
  26911. *
  26912. * > _mag_: magnification filter (close to the viewer)
  26913. * > _min_: minification filter (far from the viewer)
  26914. * > _mip_: filter used between mip map levels
  26915. *@param samplingMode Define the new sampling mode of the texture
  26916. */
  26917. updateSamplingMode(samplingMode: number): void;
  26918. /**
  26919. * Scales the texture if is `canRescale()`
  26920. * @param ratio the resize factor we want to use to rescale
  26921. */
  26922. scale(ratio: number): void;
  26923. /**
  26924. * Get if the texture can rescale.
  26925. */
  26926. readonly canRescale: boolean;
  26927. /** @hidden */
  26928. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26929. /** @hidden */
  26930. _rebuild(): void;
  26931. /**
  26932. * Triggers the load sequence in delayed load mode.
  26933. */
  26934. delayLoad(): void;
  26935. /**
  26936. * Clones the texture.
  26937. * @returns the cloned texture
  26938. */
  26939. clone(): Nullable<BaseTexture>;
  26940. /**
  26941. * Get the texture underlying type (INT, FLOAT...)
  26942. */
  26943. readonly textureType: number;
  26944. /**
  26945. * Get the texture underlying format (RGB, RGBA...)
  26946. */
  26947. readonly textureFormat: number;
  26948. /**
  26949. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26950. * This will returns an RGBA array buffer containing either in values (0-255) or
  26951. * float values (0-1) depending of the underlying buffer type.
  26952. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26953. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26954. * @param buffer defines a user defined buffer to fill with data (can be null)
  26955. * @returns The Array buffer containing the pixels data.
  26956. */
  26957. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26958. /**
  26959. * Release and destroy the underlying lower level texture aka internalTexture.
  26960. */
  26961. releaseInternalTexture(): void;
  26962. /**
  26963. * Get the polynomial representation of the texture data.
  26964. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26965. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26966. */
  26967. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26968. /** @hidden */
  26969. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26970. /** @hidden */
  26971. readonly _lodTextureMid: Nullable<BaseTexture>;
  26972. /** @hidden */
  26973. readonly _lodTextureLow: Nullable<BaseTexture>;
  26974. /**
  26975. * Dispose the texture and release its associated resources.
  26976. */
  26977. dispose(): void;
  26978. /**
  26979. * Serialize the texture into a JSON representation that can be parsed later on.
  26980. * @returns the JSON representation of the texture
  26981. */
  26982. serialize(): any;
  26983. /**
  26984. * Helper function to be called back once a list of texture contains only ready textures.
  26985. * @param textures Define the list of textures to wait for
  26986. * @param callback Define the callback triggered once the entire list will be ready
  26987. */
  26988. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26989. }
  26990. }
  26991. declare module "babylonjs/Materials/uniformBuffer" {
  26992. import { Nullable, FloatArray } from "babylonjs/types";
  26993. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26994. import { Engine } from "babylonjs/Engines/engine";
  26995. import { Effect } from "babylonjs/Materials/effect";
  26996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26997. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26998. /**
  26999. * Uniform buffer objects.
  27000. *
  27001. * Handles blocks of uniform on the GPU.
  27002. *
  27003. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27004. *
  27005. * For more information, please refer to :
  27006. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27007. */
  27008. export class UniformBuffer {
  27009. private _engine;
  27010. private _buffer;
  27011. private _data;
  27012. private _bufferData;
  27013. private _dynamic?;
  27014. private _uniformLocations;
  27015. private _uniformSizes;
  27016. private _uniformLocationPointer;
  27017. private _needSync;
  27018. private _noUBO;
  27019. private _currentEffect;
  27020. private static _MAX_UNIFORM_SIZE;
  27021. private static _tempBuffer;
  27022. /**
  27023. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27024. * This is dynamic to allow compat with webgl 1 and 2.
  27025. * You will need to pass the name of the uniform as well as the value.
  27026. */
  27027. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27028. /**
  27029. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27030. * This is dynamic to allow compat with webgl 1 and 2.
  27031. * You will need to pass the name of the uniform as well as the value.
  27032. */
  27033. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27034. /**
  27035. * Lambda to Update a single float in a uniform buffer.
  27036. * This is dynamic to allow compat with webgl 1 and 2.
  27037. * You will need to pass the name of the uniform as well as the value.
  27038. */
  27039. updateFloat: (name: string, x: number) => void;
  27040. /**
  27041. * Lambda to Update a vec2 of float in a uniform buffer.
  27042. * This is dynamic to allow compat with webgl 1 and 2.
  27043. * You will need to pass the name of the uniform as well as the value.
  27044. */
  27045. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27046. /**
  27047. * Lambda to Update a vec3 of float in a uniform buffer.
  27048. * This is dynamic to allow compat with webgl 1 and 2.
  27049. * You will need to pass the name of the uniform as well as the value.
  27050. */
  27051. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27052. /**
  27053. * Lambda to Update a vec4 of float in a uniform buffer.
  27054. * This is dynamic to allow compat with webgl 1 and 2.
  27055. * You will need to pass the name of the uniform as well as the value.
  27056. */
  27057. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27058. /**
  27059. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27060. * This is dynamic to allow compat with webgl 1 and 2.
  27061. * You will need to pass the name of the uniform as well as the value.
  27062. */
  27063. updateMatrix: (name: string, mat: Matrix) => void;
  27064. /**
  27065. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27066. * This is dynamic to allow compat with webgl 1 and 2.
  27067. * You will need to pass the name of the uniform as well as the value.
  27068. */
  27069. updateVector3: (name: string, vector: Vector3) => void;
  27070. /**
  27071. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27072. * This is dynamic to allow compat with webgl 1 and 2.
  27073. * You will need to pass the name of the uniform as well as the value.
  27074. */
  27075. updateVector4: (name: string, vector: Vector4) => void;
  27076. /**
  27077. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27078. * This is dynamic to allow compat with webgl 1 and 2.
  27079. * You will need to pass the name of the uniform as well as the value.
  27080. */
  27081. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27082. /**
  27083. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27084. * This is dynamic to allow compat with webgl 1 and 2.
  27085. * You will need to pass the name of the uniform as well as the value.
  27086. */
  27087. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27088. /**
  27089. * Instantiates a new Uniform buffer objects.
  27090. *
  27091. * Handles blocks of uniform on the GPU.
  27092. *
  27093. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27094. *
  27095. * For more information, please refer to :
  27096. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27097. * @param engine Define the engine the buffer is associated with
  27098. * @param data Define the data contained in the buffer
  27099. * @param dynamic Define if the buffer is updatable
  27100. */
  27101. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27102. /**
  27103. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27104. * or just falling back on setUniformXXX calls.
  27105. */
  27106. readonly useUbo: boolean;
  27107. /**
  27108. * Indicates if the WebGL underlying uniform buffer is in sync
  27109. * with the javascript cache data.
  27110. */
  27111. readonly isSync: boolean;
  27112. /**
  27113. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27114. * Also, a dynamic UniformBuffer will disable cache verification and always
  27115. * update the underlying WebGL uniform buffer to the GPU.
  27116. * @returns if Dynamic, otherwise false
  27117. */
  27118. isDynamic(): boolean;
  27119. /**
  27120. * The data cache on JS side.
  27121. * @returns the underlying data as a float array
  27122. */
  27123. getData(): Float32Array;
  27124. /**
  27125. * The underlying WebGL Uniform buffer.
  27126. * @returns the webgl buffer
  27127. */
  27128. getBuffer(): Nullable<DataBuffer>;
  27129. /**
  27130. * std140 layout specifies how to align data within an UBO structure.
  27131. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27132. * for specs.
  27133. */
  27134. private _fillAlignment;
  27135. /**
  27136. * Adds an uniform in the buffer.
  27137. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27138. * for the layout to be correct !
  27139. * @param name Name of the uniform, as used in the uniform block in the shader.
  27140. * @param size Data size, or data directly.
  27141. */
  27142. addUniform(name: string, size: number | number[]): void;
  27143. /**
  27144. * Adds a Matrix 4x4 to the uniform buffer.
  27145. * @param name Name of the uniform, as used in the uniform block in the shader.
  27146. * @param mat A 4x4 matrix.
  27147. */
  27148. addMatrix(name: string, mat: Matrix): void;
  27149. /**
  27150. * Adds a vec2 to the uniform buffer.
  27151. * @param name Name of the uniform, as used in the uniform block in the shader.
  27152. * @param x Define the x component value of the vec2
  27153. * @param y Define the y component value of the vec2
  27154. */
  27155. addFloat2(name: string, x: number, y: number): void;
  27156. /**
  27157. * Adds a vec3 to the uniform buffer.
  27158. * @param name Name of the uniform, as used in the uniform block in the shader.
  27159. * @param x Define the x component value of the vec3
  27160. * @param y Define the y component value of the vec3
  27161. * @param z Define the z component value of the vec3
  27162. */
  27163. addFloat3(name: string, x: number, y: number, z: number): void;
  27164. /**
  27165. * Adds a vec3 to the uniform buffer.
  27166. * @param name Name of the uniform, as used in the uniform block in the shader.
  27167. * @param color Define the vec3 from a Color
  27168. */
  27169. addColor3(name: string, color: Color3): void;
  27170. /**
  27171. * Adds a vec4 to the uniform buffer.
  27172. * @param name Name of the uniform, as used in the uniform block in the shader.
  27173. * @param color Define the rgb components from a Color
  27174. * @param alpha Define the a component of the vec4
  27175. */
  27176. addColor4(name: string, color: Color3, alpha: number): void;
  27177. /**
  27178. * Adds a vec3 to the uniform buffer.
  27179. * @param name Name of the uniform, as used in the uniform block in the shader.
  27180. * @param vector Define the vec3 components from a Vector
  27181. */
  27182. addVector3(name: string, vector: Vector3): void;
  27183. /**
  27184. * Adds a Matrix 3x3 to the uniform buffer.
  27185. * @param name Name of the uniform, as used in the uniform block in the shader.
  27186. */
  27187. addMatrix3x3(name: string): void;
  27188. /**
  27189. * Adds a Matrix 2x2 to the uniform buffer.
  27190. * @param name Name of the uniform, as used in the uniform block in the shader.
  27191. */
  27192. addMatrix2x2(name: string): void;
  27193. /**
  27194. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27195. */
  27196. create(): void;
  27197. /** @hidden */
  27198. _rebuild(): void;
  27199. /**
  27200. * Updates the WebGL Uniform Buffer on the GPU.
  27201. * If the `dynamic` flag is set to true, no cache comparison is done.
  27202. * Otherwise, the buffer will be updated only if the cache differs.
  27203. */
  27204. update(): void;
  27205. /**
  27206. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27207. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27208. * @param data Define the flattened data
  27209. * @param size Define the size of the data.
  27210. */
  27211. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27212. private _updateMatrix3x3ForUniform;
  27213. private _updateMatrix3x3ForEffect;
  27214. private _updateMatrix2x2ForEffect;
  27215. private _updateMatrix2x2ForUniform;
  27216. private _updateFloatForEffect;
  27217. private _updateFloatForUniform;
  27218. private _updateFloat2ForEffect;
  27219. private _updateFloat2ForUniform;
  27220. private _updateFloat3ForEffect;
  27221. private _updateFloat3ForUniform;
  27222. private _updateFloat4ForEffect;
  27223. private _updateFloat4ForUniform;
  27224. private _updateMatrixForEffect;
  27225. private _updateMatrixForUniform;
  27226. private _updateVector3ForEffect;
  27227. private _updateVector3ForUniform;
  27228. private _updateVector4ForEffect;
  27229. private _updateVector4ForUniform;
  27230. private _updateColor3ForEffect;
  27231. private _updateColor3ForUniform;
  27232. private _updateColor4ForEffect;
  27233. private _updateColor4ForUniform;
  27234. /**
  27235. * Sets a sampler uniform on the effect.
  27236. * @param name Define the name of the sampler.
  27237. * @param texture Define the texture to set in the sampler
  27238. */
  27239. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27240. /**
  27241. * Directly updates the value of the uniform in the cache AND on the GPU.
  27242. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27243. * @param data Define the flattened data
  27244. */
  27245. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27246. /**
  27247. * Binds this uniform buffer to an effect.
  27248. * @param effect Define the effect to bind the buffer to
  27249. * @param name Name of the uniform block in the shader.
  27250. */
  27251. bindToEffect(effect: Effect, name: string): void;
  27252. /**
  27253. * Disposes the uniform buffer.
  27254. */
  27255. dispose(): void;
  27256. }
  27257. }
  27258. declare module "babylonjs/Audio/analyser" {
  27259. import { Scene } from "babylonjs/scene";
  27260. /**
  27261. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27263. */
  27264. export class Analyser {
  27265. /**
  27266. * Gets or sets the smoothing
  27267. * @ignorenaming
  27268. */
  27269. SMOOTHING: number;
  27270. /**
  27271. * Gets or sets the FFT table size
  27272. * @ignorenaming
  27273. */
  27274. FFT_SIZE: number;
  27275. /**
  27276. * Gets or sets the bar graph amplitude
  27277. * @ignorenaming
  27278. */
  27279. BARGRAPHAMPLITUDE: number;
  27280. /**
  27281. * Gets or sets the position of the debug canvas
  27282. * @ignorenaming
  27283. */
  27284. DEBUGCANVASPOS: {
  27285. x: number;
  27286. y: number;
  27287. };
  27288. /**
  27289. * Gets or sets the debug canvas size
  27290. * @ignorenaming
  27291. */
  27292. DEBUGCANVASSIZE: {
  27293. width: number;
  27294. height: number;
  27295. };
  27296. private _byteFreqs;
  27297. private _byteTime;
  27298. private _floatFreqs;
  27299. private _webAudioAnalyser;
  27300. private _debugCanvas;
  27301. private _debugCanvasContext;
  27302. private _scene;
  27303. private _registerFunc;
  27304. private _audioEngine;
  27305. /**
  27306. * Creates a new analyser
  27307. * @param scene defines hosting scene
  27308. */
  27309. constructor(scene: Scene);
  27310. /**
  27311. * Get the number of data values you will have to play with for the visualization
  27312. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27313. * @returns a number
  27314. */
  27315. getFrequencyBinCount(): number;
  27316. /**
  27317. * Gets the current frequency data as a byte array
  27318. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27319. * @returns a Uint8Array
  27320. */
  27321. getByteFrequencyData(): Uint8Array;
  27322. /**
  27323. * Gets the current waveform as a byte array
  27324. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27325. * @returns a Uint8Array
  27326. */
  27327. getByteTimeDomainData(): Uint8Array;
  27328. /**
  27329. * Gets the current frequency data as a float array
  27330. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27331. * @returns a Float32Array
  27332. */
  27333. getFloatFrequencyData(): Float32Array;
  27334. /**
  27335. * Renders the debug canvas
  27336. */
  27337. drawDebugCanvas(): void;
  27338. /**
  27339. * Stops rendering the debug canvas and removes it
  27340. */
  27341. stopDebugCanvas(): void;
  27342. /**
  27343. * Connects two audio nodes
  27344. * @param inputAudioNode defines first node to connect
  27345. * @param outputAudioNode defines second node to connect
  27346. */
  27347. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27348. /**
  27349. * Releases all associated resources
  27350. */
  27351. dispose(): void;
  27352. }
  27353. }
  27354. declare module "babylonjs/Audio/audioEngine" {
  27355. import { IDisposable } from "babylonjs/scene";
  27356. import { Analyser } from "babylonjs/Audio/analyser";
  27357. import { Nullable } from "babylonjs/types";
  27358. import { Observable } from "babylonjs/Misc/observable";
  27359. /**
  27360. * This represents an audio engine and it is responsible
  27361. * to play, synchronize and analyse sounds throughout the application.
  27362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27363. */
  27364. export interface IAudioEngine extends IDisposable {
  27365. /**
  27366. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27367. */
  27368. readonly canUseWebAudio: boolean;
  27369. /**
  27370. * Gets the current AudioContext if available.
  27371. */
  27372. readonly audioContext: Nullable<AudioContext>;
  27373. /**
  27374. * The master gain node defines the global audio volume of your audio engine.
  27375. */
  27376. readonly masterGain: GainNode;
  27377. /**
  27378. * Gets whether or not mp3 are supported by your browser.
  27379. */
  27380. readonly isMP3supported: boolean;
  27381. /**
  27382. * Gets whether or not ogg are supported by your browser.
  27383. */
  27384. readonly isOGGsupported: boolean;
  27385. /**
  27386. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27387. * @ignoreNaming
  27388. */
  27389. WarnedWebAudioUnsupported: boolean;
  27390. /**
  27391. * Defines if the audio engine relies on a custom unlocked button.
  27392. * In this case, the embedded button will not be displayed.
  27393. */
  27394. useCustomUnlockedButton: boolean;
  27395. /**
  27396. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27397. */
  27398. readonly unlocked: boolean;
  27399. /**
  27400. * Event raised when audio has been unlocked on the browser.
  27401. */
  27402. onAudioUnlockedObservable: Observable<AudioEngine>;
  27403. /**
  27404. * Event raised when audio has been locked on the browser.
  27405. */
  27406. onAudioLockedObservable: Observable<AudioEngine>;
  27407. /**
  27408. * Flags the audio engine in Locked state.
  27409. * This happens due to new browser policies preventing audio to autoplay.
  27410. */
  27411. lock(): void;
  27412. /**
  27413. * Unlocks the audio engine once a user action has been done on the dom.
  27414. * This is helpful to resume play once browser policies have been satisfied.
  27415. */
  27416. unlock(): void;
  27417. }
  27418. /**
  27419. * This represents the default audio engine used in babylon.
  27420. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27422. */
  27423. export class AudioEngine implements IAudioEngine {
  27424. private _audioContext;
  27425. private _audioContextInitialized;
  27426. private _muteButton;
  27427. private _hostElement;
  27428. /**
  27429. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27430. */
  27431. canUseWebAudio: boolean;
  27432. /**
  27433. * The master gain node defines the global audio volume of your audio engine.
  27434. */
  27435. masterGain: GainNode;
  27436. /**
  27437. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27438. * @ignoreNaming
  27439. */
  27440. WarnedWebAudioUnsupported: boolean;
  27441. /**
  27442. * Gets whether or not mp3 are supported by your browser.
  27443. */
  27444. isMP3supported: boolean;
  27445. /**
  27446. * Gets whether or not ogg are supported by your browser.
  27447. */
  27448. isOGGsupported: boolean;
  27449. /**
  27450. * Gets whether audio has been unlocked on the device.
  27451. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27452. * a user interaction has happened.
  27453. */
  27454. unlocked: boolean;
  27455. /**
  27456. * Defines if the audio engine relies on a custom unlocked button.
  27457. * In this case, the embedded button will not be displayed.
  27458. */
  27459. useCustomUnlockedButton: boolean;
  27460. /**
  27461. * Event raised when audio has been unlocked on the browser.
  27462. */
  27463. onAudioUnlockedObservable: Observable<AudioEngine>;
  27464. /**
  27465. * Event raised when audio has been locked on the browser.
  27466. */
  27467. onAudioLockedObservable: Observable<AudioEngine>;
  27468. /**
  27469. * Gets the current AudioContext if available.
  27470. */
  27471. readonly audioContext: Nullable<AudioContext>;
  27472. private _connectedAnalyser;
  27473. /**
  27474. * Instantiates a new audio engine.
  27475. *
  27476. * There should be only one per page as some browsers restrict the number
  27477. * of audio contexts you can create.
  27478. * @param hostElement defines the host element where to display the mute icon if necessary
  27479. */
  27480. constructor(hostElement?: Nullable<HTMLElement>);
  27481. /**
  27482. * Flags the audio engine in Locked state.
  27483. * This happens due to new browser policies preventing audio to autoplay.
  27484. */
  27485. lock(): void;
  27486. /**
  27487. * Unlocks the audio engine once a user action has been done on the dom.
  27488. * This is helpful to resume play once browser policies have been satisfied.
  27489. */
  27490. unlock(): void;
  27491. private _resumeAudioContext;
  27492. private _initializeAudioContext;
  27493. private _tryToRun;
  27494. private _triggerRunningState;
  27495. private _triggerSuspendedState;
  27496. private _displayMuteButton;
  27497. private _moveButtonToTopLeft;
  27498. private _onResize;
  27499. private _hideMuteButton;
  27500. /**
  27501. * Destroy and release the resources associated with the audio ccontext.
  27502. */
  27503. dispose(): void;
  27504. /**
  27505. * Gets the global volume sets on the master gain.
  27506. * @returns the global volume if set or -1 otherwise
  27507. */
  27508. getGlobalVolume(): number;
  27509. /**
  27510. * Sets the global volume of your experience (sets on the master gain).
  27511. * @param newVolume Defines the new global volume of the application
  27512. */
  27513. setGlobalVolume(newVolume: number): void;
  27514. /**
  27515. * Connect the audio engine to an audio analyser allowing some amazing
  27516. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27518. * @param analyser The analyser to connect to the engine
  27519. */
  27520. connectToAnalyser(analyser: Analyser): void;
  27521. }
  27522. }
  27523. declare module "babylonjs/Loading/loadingScreen" {
  27524. /**
  27525. * Interface used to present a loading screen while loading a scene
  27526. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27527. */
  27528. export interface ILoadingScreen {
  27529. /**
  27530. * Function called to display the loading screen
  27531. */
  27532. displayLoadingUI: () => void;
  27533. /**
  27534. * Function called to hide the loading screen
  27535. */
  27536. hideLoadingUI: () => void;
  27537. /**
  27538. * Gets or sets the color to use for the background
  27539. */
  27540. loadingUIBackgroundColor: string;
  27541. /**
  27542. * Gets or sets the text to display while loading
  27543. */
  27544. loadingUIText: string;
  27545. }
  27546. /**
  27547. * Class used for the default loading screen
  27548. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27549. */
  27550. export class DefaultLoadingScreen implements ILoadingScreen {
  27551. private _renderingCanvas;
  27552. private _loadingText;
  27553. private _loadingDivBackgroundColor;
  27554. private _loadingDiv;
  27555. private _loadingTextDiv;
  27556. /**
  27557. * Creates a new default loading screen
  27558. * @param _renderingCanvas defines the canvas used to render the scene
  27559. * @param _loadingText defines the default text to display
  27560. * @param _loadingDivBackgroundColor defines the default background color
  27561. */
  27562. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27563. /**
  27564. * Function called to display the loading screen
  27565. */
  27566. displayLoadingUI(): void;
  27567. /**
  27568. * Function called to hide the loading screen
  27569. */
  27570. hideLoadingUI(): void;
  27571. /**
  27572. * Gets or sets the text to display while loading
  27573. */
  27574. loadingUIText: string;
  27575. /**
  27576. * Gets or sets the color to use for the background
  27577. */
  27578. loadingUIBackgroundColor: string;
  27579. private _resizeLoadingUI;
  27580. }
  27581. }
  27582. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27583. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27584. import { Engine } from "babylonjs/Engines/engine";
  27585. import { Nullable } from "babylonjs/types";
  27586. /** @hidden */
  27587. export class WebGLPipelineContext implements IPipelineContext {
  27588. engine: Engine;
  27589. program: Nullable<WebGLProgram>;
  27590. context?: WebGLRenderingContext;
  27591. vertexShader?: WebGLShader;
  27592. fragmentShader?: WebGLShader;
  27593. isParallelCompiled: boolean;
  27594. onCompiled?: () => void;
  27595. transformFeedback?: WebGLTransformFeedback | null;
  27596. readonly isAsync: boolean;
  27597. readonly isReady: boolean;
  27598. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27599. }
  27600. }
  27601. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27602. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27603. /** @hidden */
  27604. export class WebGLDataBuffer extends DataBuffer {
  27605. private _buffer;
  27606. constructor(resource: WebGLBuffer);
  27607. readonly underlyingResource: any;
  27608. }
  27609. }
  27610. declare module "babylonjs/Materials/Textures/videoTexture" {
  27611. import { Observable } from "babylonjs/Misc/observable";
  27612. import { Nullable } from "babylonjs/types";
  27613. import { Scene } from "babylonjs/scene";
  27614. import { Texture } from "babylonjs/Materials/Textures/texture";
  27615. /**
  27616. * Settings for finer control over video usage
  27617. */
  27618. export interface VideoTextureSettings {
  27619. /**
  27620. * Applies `autoplay` to video, if specified
  27621. */
  27622. autoPlay?: boolean;
  27623. /**
  27624. * Applies `loop` to video, if specified
  27625. */
  27626. loop?: boolean;
  27627. /**
  27628. * Automatically updates internal texture from video at every frame in the render loop
  27629. */
  27630. autoUpdateTexture: boolean;
  27631. /**
  27632. * Image src displayed during the video loading or until the user interacts with the video.
  27633. */
  27634. poster?: string;
  27635. }
  27636. /**
  27637. * If you want to display a video in your scene, this is the special texture for that.
  27638. * This special texture works similar to other textures, with the exception of a few parameters.
  27639. * @see https://doc.babylonjs.com/how_to/video_texture
  27640. */
  27641. export class VideoTexture extends Texture {
  27642. /**
  27643. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27644. */
  27645. readonly autoUpdateTexture: boolean;
  27646. /**
  27647. * The video instance used by the texture internally
  27648. */
  27649. readonly video: HTMLVideoElement;
  27650. private _onUserActionRequestedObservable;
  27651. /**
  27652. * Event triggerd when a dom action is required by the user to play the video.
  27653. * This happens due to recent changes in browser policies preventing video to auto start.
  27654. */
  27655. readonly onUserActionRequestedObservable: Observable<Texture>;
  27656. private _generateMipMaps;
  27657. private _engine;
  27658. private _stillImageCaptured;
  27659. private _displayingPosterTexture;
  27660. private _settings;
  27661. private _createInternalTextureOnEvent;
  27662. /**
  27663. * Creates a video texture.
  27664. * If you want to display a video in your scene, this is the special texture for that.
  27665. * This special texture works similar to other textures, with the exception of a few parameters.
  27666. * @see https://doc.babylonjs.com/how_to/video_texture
  27667. * @param name optional name, will detect from video source, if not defined
  27668. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27669. * @param scene is obviously the current scene.
  27670. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27671. * @param invertY is false by default but can be used to invert video on Y axis
  27672. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27673. * @param settings allows finer control over video usage
  27674. */
  27675. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27676. private _getName;
  27677. private _getVideo;
  27678. private _createInternalTexture;
  27679. private reset;
  27680. /**
  27681. * @hidden Internal method to initiate `update`.
  27682. */
  27683. _rebuild(): void;
  27684. /**
  27685. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27686. */
  27687. update(): void;
  27688. /**
  27689. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27690. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27691. */
  27692. updateTexture(isVisible: boolean): void;
  27693. protected _updateInternalTexture: () => void;
  27694. /**
  27695. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27696. * @param url New url.
  27697. */
  27698. updateURL(url: string): void;
  27699. /**
  27700. * Dispose the texture and release its associated resources.
  27701. */
  27702. dispose(): void;
  27703. /**
  27704. * Creates a video texture straight from a stream.
  27705. * @param scene Define the scene the texture should be created in
  27706. * @param stream Define the stream the texture should be created from
  27707. * @returns The created video texture as a promise
  27708. */
  27709. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27710. /**
  27711. * Creates a video texture straight from your WebCam video feed.
  27712. * @param scene Define the scene the texture should be created in
  27713. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27714. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27715. * @returns The created video texture as a promise
  27716. */
  27717. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27718. minWidth: number;
  27719. maxWidth: number;
  27720. minHeight: number;
  27721. maxHeight: number;
  27722. deviceId: string;
  27723. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27724. /**
  27725. * Creates a video texture straight from your WebCam video feed.
  27726. * @param scene Define the scene the texture should be created in
  27727. * @param onReady Define a callback to triggered once the texture will be ready
  27728. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27729. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27730. */
  27731. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27732. minWidth: number;
  27733. maxWidth: number;
  27734. minHeight: number;
  27735. maxHeight: number;
  27736. deviceId: string;
  27737. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27738. }
  27739. }
  27740. declare module "babylonjs/Engines/engine" {
  27741. import { Observable } from "babylonjs/Misc/observable";
  27742. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27743. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27744. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27745. import { Camera } from "babylonjs/Cameras/camera";
  27746. import { Scene } from "babylonjs/scene";
  27747. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27748. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27749. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27750. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27751. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27752. import { Material } from "babylonjs/Materials/material";
  27753. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27754. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27756. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27757. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27758. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27759. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27760. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27761. import { WebRequest } from "babylonjs/Misc/webRequest";
  27762. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27763. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27764. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27765. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27766. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27767. /**
  27768. * Interface for attribute information associated with buffer instanciation
  27769. */
  27770. export class InstancingAttributeInfo {
  27771. /**
  27772. * Index/offset of the attribute in the vertex shader
  27773. */
  27774. index: number;
  27775. /**
  27776. * size of the attribute, 1, 2, 3 or 4
  27777. */
  27778. attributeSize: number;
  27779. /**
  27780. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27781. * default is FLOAT
  27782. */
  27783. attribyteType: number;
  27784. /**
  27785. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27786. */
  27787. normalized: boolean;
  27788. /**
  27789. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27790. */
  27791. offset: number;
  27792. /**
  27793. * Name of the GLSL attribute, for debugging purpose only
  27794. */
  27795. attributeName: string;
  27796. }
  27797. /**
  27798. * Define options used to create a depth texture
  27799. */
  27800. export class DepthTextureCreationOptions {
  27801. /** Specifies whether or not a stencil should be allocated in the texture */
  27802. generateStencil?: boolean;
  27803. /** Specifies whether or not bilinear filtering is enable on the texture */
  27804. bilinearFiltering?: boolean;
  27805. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27806. comparisonFunction?: number;
  27807. /** Specifies if the created texture is a cube texture */
  27808. isCube?: boolean;
  27809. }
  27810. /**
  27811. * Class used to describe the capabilities of the engine relatively to the current browser
  27812. */
  27813. export class EngineCapabilities {
  27814. /** Maximum textures units per fragment shader */
  27815. maxTexturesImageUnits: number;
  27816. /** Maximum texture units per vertex shader */
  27817. maxVertexTextureImageUnits: number;
  27818. /** Maximum textures units in the entire pipeline */
  27819. maxCombinedTexturesImageUnits: number;
  27820. /** Maximum texture size */
  27821. maxTextureSize: number;
  27822. /** Maximum cube texture size */
  27823. maxCubemapTextureSize: number;
  27824. /** Maximum render texture size */
  27825. maxRenderTextureSize: number;
  27826. /** Maximum number of vertex attributes */
  27827. maxVertexAttribs: number;
  27828. /** Maximum number of varyings */
  27829. maxVaryingVectors: number;
  27830. /** Maximum number of uniforms per vertex shader */
  27831. maxVertexUniformVectors: number;
  27832. /** Maximum number of uniforms per fragment shader */
  27833. maxFragmentUniformVectors: number;
  27834. /** Defines if standard derivates (dx/dy) are supported */
  27835. standardDerivatives: boolean;
  27836. /** Defines if s3tc texture compression is supported */
  27837. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27838. /** Defines if pvrtc texture compression is supported */
  27839. pvrtc: any;
  27840. /** Defines if etc1 texture compression is supported */
  27841. etc1: any;
  27842. /** Defines if etc2 texture compression is supported */
  27843. etc2: any;
  27844. /** Defines if astc texture compression is supported */
  27845. astc: any;
  27846. /** Defines if float textures are supported */
  27847. textureFloat: boolean;
  27848. /** Defines if vertex array objects are supported */
  27849. vertexArrayObject: boolean;
  27850. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27851. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27852. /** Gets the maximum level of anisotropy supported */
  27853. maxAnisotropy: number;
  27854. /** Defines if instancing is supported */
  27855. instancedArrays: boolean;
  27856. /** Defines if 32 bits indices are supported */
  27857. uintIndices: boolean;
  27858. /** Defines if high precision shaders are supported */
  27859. highPrecisionShaderSupported: boolean;
  27860. /** Defines if depth reading in the fragment shader is supported */
  27861. fragmentDepthSupported: boolean;
  27862. /** Defines if float texture linear filtering is supported*/
  27863. textureFloatLinearFiltering: boolean;
  27864. /** Defines if rendering to float textures is supported */
  27865. textureFloatRender: boolean;
  27866. /** Defines if half float textures are supported*/
  27867. textureHalfFloat: boolean;
  27868. /** Defines if half float texture linear filtering is supported*/
  27869. textureHalfFloatLinearFiltering: boolean;
  27870. /** Defines if rendering to half float textures is supported */
  27871. textureHalfFloatRender: boolean;
  27872. /** Defines if textureLOD shader command is supported */
  27873. textureLOD: boolean;
  27874. /** Defines if draw buffers extension is supported */
  27875. drawBuffersExtension: boolean;
  27876. /** Defines if depth textures are supported */
  27877. depthTextureExtension: boolean;
  27878. /** Defines if float color buffer are supported */
  27879. colorBufferFloat: boolean;
  27880. /** Gets disjoint timer query extension (null if not supported) */
  27881. timerQuery: EXT_disjoint_timer_query;
  27882. /** Defines if timestamp can be used with timer query */
  27883. canUseTimestampForTimerQuery: boolean;
  27884. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27885. multiview: any;
  27886. /** Function used to let the system compiles shaders in background */
  27887. parallelShaderCompile: {
  27888. COMPLETION_STATUS_KHR: number;
  27889. };
  27890. }
  27891. /** Interface defining initialization parameters for Engine class */
  27892. export interface EngineOptions extends WebGLContextAttributes {
  27893. /**
  27894. * Defines if the engine should no exceed a specified device ratio
  27895. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27896. */
  27897. limitDeviceRatio?: number;
  27898. /**
  27899. * Defines if webvr should be enabled automatically
  27900. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27901. */
  27902. autoEnableWebVR?: boolean;
  27903. /**
  27904. * Defines if webgl2 should be turned off even if supported
  27905. * @see http://doc.babylonjs.com/features/webgl2
  27906. */
  27907. disableWebGL2Support?: boolean;
  27908. /**
  27909. * Defines if webaudio should be initialized as well
  27910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27911. */
  27912. audioEngine?: boolean;
  27913. /**
  27914. * Defines if animations should run using a deterministic lock step
  27915. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27916. */
  27917. deterministicLockstep?: boolean;
  27918. /** Defines the maximum steps to use with deterministic lock step mode */
  27919. lockstepMaxSteps?: number;
  27920. /**
  27921. * Defines that engine should ignore context lost events
  27922. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27923. */
  27924. doNotHandleContextLost?: boolean;
  27925. /**
  27926. * Defines that engine should ignore modifying touch action attribute and style
  27927. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27928. */
  27929. doNotHandleTouchAction?: boolean;
  27930. /**
  27931. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27932. */
  27933. useHighPrecisionFloats?: boolean;
  27934. }
  27935. /**
  27936. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27937. */
  27938. export class Engine {
  27939. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27940. static ExceptionList: ({
  27941. key: string;
  27942. capture: string;
  27943. captureConstraint: number;
  27944. targets: string[];
  27945. } | {
  27946. key: string;
  27947. capture: null;
  27948. captureConstraint: null;
  27949. targets: string[];
  27950. })[];
  27951. /** Gets the list of created engines */
  27952. static readonly Instances: Engine[];
  27953. /**
  27954. * Gets the latest created engine
  27955. */
  27956. static readonly LastCreatedEngine: Nullable<Engine>;
  27957. /**
  27958. * Gets the latest created scene
  27959. */
  27960. static readonly LastCreatedScene: Nullable<Scene>;
  27961. /**
  27962. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27963. * @param flag defines which part of the materials must be marked as dirty
  27964. * @param predicate defines a predicate used to filter which materials should be affected
  27965. */
  27966. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27967. /**
  27968. * Hidden
  27969. */
  27970. static _TextureLoaders: IInternalTextureLoader[];
  27971. /** Defines that alpha blending is disabled */
  27972. static readonly ALPHA_DISABLE: number;
  27973. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27974. static readonly ALPHA_ADD: number;
  27975. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27976. static readonly ALPHA_COMBINE: number;
  27977. /** Defines that alpha blending to DEST - SRC * DEST */
  27978. static readonly ALPHA_SUBTRACT: number;
  27979. /** Defines that alpha blending to SRC * DEST */
  27980. static readonly ALPHA_MULTIPLY: number;
  27981. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27982. static readonly ALPHA_MAXIMIZED: number;
  27983. /** Defines that alpha blending to SRC + DEST */
  27984. static readonly ALPHA_ONEONE: number;
  27985. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27986. static readonly ALPHA_PREMULTIPLIED: number;
  27987. /**
  27988. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27989. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27990. */
  27991. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27992. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27993. static readonly ALPHA_INTERPOLATE: number;
  27994. /**
  27995. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27996. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27997. */
  27998. static readonly ALPHA_SCREENMODE: number;
  27999. /** Defines that the ressource is not delayed*/
  28000. static readonly DELAYLOADSTATE_NONE: number;
  28001. /** Defines that the ressource was successfully delay loaded */
  28002. static readonly DELAYLOADSTATE_LOADED: number;
  28003. /** Defines that the ressource is currently delay loading */
  28004. static readonly DELAYLOADSTATE_LOADING: number;
  28005. /** Defines that the ressource is delayed and has not started loading */
  28006. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28007. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28008. static readonly NEVER: number;
  28009. /** 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 */
  28010. static readonly ALWAYS: number;
  28011. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28012. static readonly LESS: number;
  28013. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28014. static readonly EQUAL: number;
  28015. /** 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 */
  28016. static readonly LEQUAL: number;
  28017. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28018. static readonly GREATER: number;
  28019. /** 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 */
  28020. static readonly GEQUAL: number;
  28021. /** 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 */
  28022. static readonly NOTEQUAL: number;
  28023. /** Passed to stencilOperation to specify that stencil value must be kept */
  28024. static readonly KEEP: number;
  28025. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28026. static readonly REPLACE: number;
  28027. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28028. static readonly INCR: number;
  28029. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28030. static readonly DECR: number;
  28031. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28032. static readonly INVERT: number;
  28033. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28034. static readonly INCR_WRAP: number;
  28035. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28036. static readonly DECR_WRAP: number;
  28037. /** Texture is not repeating outside of 0..1 UVs */
  28038. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28039. /** Texture is repeating outside of 0..1 UVs */
  28040. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28041. /** Texture is repeating and mirrored */
  28042. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28043. /** ALPHA */
  28044. static readonly TEXTUREFORMAT_ALPHA: number;
  28045. /** LUMINANCE */
  28046. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28047. /** LUMINANCE_ALPHA */
  28048. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28049. /** RGB */
  28050. static readonly TEXTUREFORMAT_RGB: number;
  28051. /** RGBA */
  28052. static readonly TEXTUREFORMAT_RGBA: number;
  28053. /** RED */
  28054. static readonly TEXTUREFORMAT_RED: number;
  28055. /** RED (2nd reference) */
  28056. static readonly TEXTUREFORMAT_R: number;
  28057. /** RG */
  28058. static readonly TEXTUREFORMAT_RG: number;
  28059. /** RED_INTEGER */
  28060. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28061. /** RED_INTEGER (2nd reference) */
  28062. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28063. /** RG_INTEGER */
  28064. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28065. /** RGB_INTEGER */
  28066. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28067. /** RGBA_INTEGER */
  28068. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28069. /** UNSIGNED_BYTE */
  28070. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28071. /** UNSIGNED_BYTE (2nd reference) */
  28072. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28073. /** FLOAT */
  28074. static readonly TEXTURETYPE_FLOAT: number;
  28075. /** HALF_FLOAT */
  28076. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28077. /** BYTE */
  28078. static readonly TEXTURETYPE_BYTE: number;
  28079. /** SHORT */
  28080. static readonly TEXTURETYPE_SHORT: number;
  28081. /** UNSIGNED_SHORT */
  28082. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28083. /** INT */
  28084. static readonly TEXTURETYPE_INT: number;
  28085. /** UNSIGNED_INT */
  28086. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28087. /** UNSIGNED_SHORT_4_4_4_4 */
  28088. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28089. /** UNSIGNED_SHORT_5_5_5_1 */
  28090. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28091. /** UNSIGNED_SHORT_5_6_5 */
  28092. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28093. /** UNSIGNED_INT_2_10_10_10_REV */
  28094. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28095. /** UNSIGNED_INT_24_8 */
  28096. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28097. /** UNSIGNED_INT_10F_11F_11F_REV */
  28098. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28099. /** UNSIGNED_INT_5_9_9_9_REV */
  28100. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28101. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28102. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28103. /** nearest is mag = nearest and min = nearest and mip = linear */
  28104. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28105. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28106. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28107. /** Trilinear is mag = linear and min = linear and mip = linear */
  28108. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28109. /** nearest is mag = nearest and min = nearest and mip = linear */
  28110. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28111. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28112. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28113. /** Trilinear is mag = linear and min = linear and mip = linear */
  28114. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28115. /** mag = nearest and min = nearest and mip = nearest */
  28116. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28117. /** mag = nearest and min = linear and mip = nearest */
  28118. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28119. /** mag = nearest and min = linear and mip = linear */
  28120. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28121. /** mag = nearest and min = linear and mip = none */
  28122. static readonly TEXTURE_NEAREST_LINEAR: number;
  28123. /** mag = nearest and min = nearest and mip = none */
  28124. static readonly TEXTURE_NEAREST_NEAREST: number;
  28125. /** mag = linear and min = nearest and mip = nearest */
  28126. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28127. /** mag = linear and min = nearest and mip = linear */
  28128. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28129. /** mag = linear and min = linear and mip = none */
  28130. static readonly TEXTURE_LINEAR_LINEAR: number;
  28131. /** mag = linear and min = nearest and mip = none */
  28132. static readonly TEXTURE_LINEAR_NEAREST: number;
  28133. /** Explicit coordinates mode */
  28134. static readonly TEXTURE_EXPLICIT_MODE: number;
  28135. /** Spherical coordinates mode */
  28136. static readonly TEXTURE_SPHERICAL_MODE: number;
  28137. /** Planar coordinates mode */
  28138. static readonly TEXTURE_PLANAR_MODE: number;
  28139. /** Cubic coordinates mode */
  28140. static readonly TEXTURE_CUBIC_MODE: number;
  28141. /** Projection coordinates mode */
  28142. static readonly TEXTURE_PROJECTION_MODE: number;
  28143. /** Skybox coordinates mode */
  28144. static readonly TEXTURE_SKYBOX_MODE: number;
  28145. /** Inverse Cubic coordinates mode */
  28146. static readonly TEXTURE_INVCUBIC_MODE: number;
  28147. /** Equirectangular coordinates mode */
  28148. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28149. /** Equirectangular Fixed coordinates mode */
  28150. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28151. /** Equirectangular Fixed Mirrored coordinates mode */
  28152. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28153. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28154. static readonly SCALEMODE_FLOOR: number;
  28155. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28156. static readonly SCALEMODE_NEAREST: number;
  28157. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28158. static readonly SCALEMODE_CEILING: number;
  28159. /**
  28160. * Returns the current npm package of the sdk
  28161. */
  28162. static readonly NpmPackage: string;
  28163. /**
  28164. * Returns the current version of the framework
  28165. */
  28166. static readonly Version: string;
  28167. /**
  28168. * Returns a string describing the current engine
  28169. */
  28170. readonly description: string;
  28171. /**
  28172. * Gets or sets the epsilon value used by collision engine
  28173. */
  28174. static CollisionsEpsilon: number;
  28175. /**
  28176. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28177. */
  28178. static ShadersRepository: string;
  28179. /**
  28180. * Method called to create the default loading screen.
  28181. * This can be overriden in your own app.
  28182. * @param canvas The rendering canvas element
  28183. * @returns The loading screen
  28184. */
  28185. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28186. /**
  28187. * Method called to create the default rescale post process on each engine.
  28188. */
  28189. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28190. /**
  28191. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28192. */
  28193. forcePOTTextures: boolean;
  28194. /**
  28195. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28196. */
  28197. isFullscreen: boolean;
  28198. /**
  28199. * Gets a boolean indicating if the pointer is currently locked
  28200. */
  28201. isPointerLock: boolean;
  28202. /**
  28203. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28204. */
  28205. cullBackFaces: boolean;
  28206. /**
  28207. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28208. */
  28209. renderEvenInBackground: boolean;
  28210. /**
  28211. * Gets or sets a boolean indicating that cache can be kept between frames
  28212. */
  28213. preventCacheWipeBetweenFrames: boolean;
  28214. /**
  28215. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28216. **/
  28217. enableOfflineSupport: boolean;
  28218. /**
  28219. * 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)
  28220. **/
  28221. disableManifestCheck: boolean;
  28222. /**
  28223. * Gets the list of created scenes
  28224. */
  28225. scenes: Scene[];
  28226. /**
  28227. * Event raised when a new scene is created
  28228. */
  28229. onNewSceneAddedObservable: Observable<Scene>;
  28230. /**
  28231. * Gets the list of created postprocesses
  28232. */
  28233. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28234. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28235. validateShaderPrograms: boolean;
  28236. /**
  28237. * Observable event triggered each time the rendering canvas is resized
  28238. */
  28239. onResizeObservable: Observable<Engine>;
  28240. /**
  28241. * Observable event triggered each time the canvas loses focus
  28242. */
  28243. onCanvasBlurObservable: Observable<Engine>;
  28244. /**
  28245. * Observable event triggered each time the canvas gains focus
  28246. */
  28247. onCanvasFocusObservable: Observable<Engine>;
  28248. /**
  28249. * Observable event triggered each time the canvas receives pointerout event
  28250. */
  28251. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28252. /**
  28253. * Observable event triggered before each texture is initialized
  28254. */
  28255. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28256. /**
  28257. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28258. */
  28259. disableUniformBuffers: boolean;
  28260. /** @hidden */
  28261. _uniformBuffers: UniformBuffer[];
  28262. /**
  28263. * Gets a boolean indicating that the engine supports uniform buffers
  28264. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28265. */
  28266. readonly supportsUniformBuffers: boolean;
  28267. /**
  28268. * Observable raised when the engine begins a new frame
  28269. */
  28270. onBeginFrameObservable: Observable<Engine>;
  28271. /**
  28272. * If set, will be used to request the next animation frame for the render loop
  28273. */
  28274. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28275. /**
  28276. * Observable raised when the engine ends the current frame
  28277. */
  28278. onEndFrameObservable: Observable<Engine>;
  28279. /**
  28280. * Observable raised when the engine is about to compile a shader
  28281. */
  28282. onBeforeShaderCompilationObservable: Observable<Engine>;
  28283. /**
  28284. * Observable raised when the engine has jsut compiled a shader
  28285. */
  28286. onAfterShaderCompilationObservable: Observable<Engine>;
  28287. /** @hidden */
  28288. _gl: WebGLRenderingContext;
  28289. private _renderingCanvas;
  28290. private _windowIsBackground;
  28291. private _webGLVersion;
  28292. protected _highPrecisionShadersAllowed: boolean;
  28293. /** @hidden */
  28294. readonly _shouldUseHighPrecisionShader: boolean;
  28295. /**
  28296. * Gets a boolean indicating that only power of 2 textures are supported
  28297. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28298. */
  28299. readonly needPOTTextures: boolean;
  28300. /** @hidden */
  28301. _badOS: boolean;
  28302. /** @hidden */
  28303. _badDesktopOS: boolean;
  28304. /**
  28305. * Gets the audio engine
  28306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28307. * @ignorenaming
  28308. */
  28309. static audioEngine: IAudioEngine;
  28310. /**
  28311. * Default AudioEngine factory responsible of creating the Audio Engine.
  28312. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28313. */
  28314. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28315. /**
  28316. * Default offline support factory responsible of creating a tool used to store data locally.
  28317. * By default, this will create a Database object if the workload has been embedded.
  28318. */
  28319. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28320. private _onFocus;
  28321. private _onBlur;
  28322. private _onCanvasPointerOut;
  28323. private _onCanvasBlur;
  28324. private _onCanvasFocus;
  28325. private _onFullscreenChange;
  28326. private _onPointerLockChange;
  28327. private _hardwareScalingLevel;
  28328. /** @hidden */
  28329. _caps: EngineCapabilities;
  28330. private _pointerLockRequested;
  28331. private _isStencilEnable;
  28332. private _colorWrite;
  28333. private _loadingScreen;
  28334. /** @hidden */
  28335. _drawCalls: PerfCounter;
  28336. private _glVersion;
  28337. private _glRenderer;
  28338. private _glVendor;
  28339. private _videoTextureSupported;
  28340. private _renderingQueueLaunched;
  28341. private _activeRenderLoops;
  28342. private _deterministicLockstep;
  28343. private _lockstepMaxSteps;
  28344. /**
  28345. * Observable signaled when a context lost event is raised
  28346. */
  28347. onContextLostObservable: Observable<Engine>;
  28348. /**
  28349. * Observable signaled when a context restored event is raised
  28350. */
  28351. onContextRestoredObservable: Observable<Engine>;
  28352. private _onContextLost;
  28353. private _onContextRestored;
  28354. private _contextWasLost;
  28355. /** @hidden */
  28356. _doNotHandleContextLost: boolean;
  28357. /**
  28358. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28360. */
  28361. doNotHandleContextLost: boolean;
  28362. private _performanceMonitor;
  28363. private _fps;
  28364. private _deltaTime;
  28365. /**
  28366. * Turn this value on if you want to pause FPS computation when in background
  28367. */
  28368. disablePerformanceMonitorInBackground: boolean;
  28369. /**
  28370. * Gets the performance monitor attached to this engine
  28371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28372. */
  28373. readonly performanceMonitor: PerformanceMonitor;
  28374. /**
  28375. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28376. */
  28377. disableVertexArrayObjects: boolean;
  28378. /** @hidden */
  28379. protected _depthCullingState: _DepthCullingState;
  28380. /** @hidden */
  28381. protected _stencilState: _StencilState;
  28382. /** @hidden */
  28383. protected _alphaState: _AlphaState;
  28384. /** @hidden */
  28385. protected _alphaMode: number;
  28386. /** @hidden */
  28387. _internalTexturesCache: InternalTexture[];
  28388. /** @hidden */
  28389. protected _activeChannel: number;
  28390. private _currentTextureChannel;
  28391. /** @hidden */
  28392. protected _boundTexturesCache: {
  28393. [key: string]: Nullable<InternalTexture>;
  28394. };
  28395. /** @hidden */
  28396. protected _currentEffect: Nullable<Effect>;
  28397. /** @hidden */
  28398. protected _currentProgram: Nullable<WebGLProgram>;
  28399. private _compiledEffects;
  28400. private _vertexAttribArraysEnabled;
  28401. /** @hidden */
  28402. protected _cachedViewport: Nullable<Viewport>;
  28403. private _cachedVertexArrayObject;
  28404. /** @hidden */
  28405. protected _cachedVertexBuffers: any;
  28406. /** @hidden */
  28407. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28408. /** @hidden */
  28409. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28410. /** @hidden */
  28411. _currentRenderTarget: Nullable<InternalTexture>;
  28412. private _uintIndicesCurrentlySet;
  28413. private _currentBoundBuffer;
  28414. /** @hidden */
  28415. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28416. private _currentBufferPointers;
  28417. private _currentInstanceLocations;
  28418. private _currentInstanceBuffers;
  28419. private _textureUnits;
  28420. /** @hidden */
  28421. _workingCanvas: Nullable<HTMLCanvasElement>;
  28422. /** @hidden */
  28423. _workingContext: Nullable<CanvasRenderingContext2D>;
  28424. private _rescalePostProcess;
  28425. private _dummyFramebuffer;
  28426. private _externalData;
  28427. /** @hidden */
  28428. _bindedRenderFunction: any;
  28429. private _vaoRecordInProgress;
  28430. private _mustWipeVertexAttributes;
  28431. private _emptyTexture;
  28432. private _emptyCubeTexture;
  28433. private _emptyTexture3D;
  28434. /** @hidden */
  28435. _frameHandler: number;
  28436. private _nextFreeTextureSlots;
  28437. private _maxSimultaneousTextures;
  28438. private _activeRequests;
  28439. private _texturesSupported;
  28440. /** @hidden */
  28441. _textureFormatInUse: Nullable<string>;
  28442. /**
  28443. * Gets the list of texture formats supported
  28444. */
  28445. readonly texturesSupported: Array<string>;
  28446. /**
  28447. * Gets the list of texture formats in use
  28448. */
  28449. readonly textureFormatInUse: Nullable<string>;
  28450. /**
  28451. * Gets the current viewport
  28452. */
  28453. readonly currentViewport: Nullable<Viewport>;
  28454. /**
  28455. * Gets the default empty texture
  28456. */
  28457. readonly emptyTexture: InternalTexture;
  28458. /**
  28459. * Gets the default empty 3D texture
  28460. */
  28461. readonly emptyTexture3D: InternalTexture;
  28462. /**
  28463. * Gets the default empty cube texture
  28464. */
  28465. readonly emptyCubeTexture: InternalTexture;
  28466. /**
  28467. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28468. */
  28469. readonly premultipliedAlpha: boolean;
  28470. /**
  28471. * Creates a new engine
  28472. * @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
  28473. * @param antialias defines enable antialiasing (default: false)
  28474. * @param options defines further options to be sent to the getContext() function
  28475. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28476. */
  28477. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28478. /**
  28479. * Initializes a webVR display and starts listening to display change events
  28480. * The onVRDisplayChangedObservable will be notified upon these changes
  28481. * @returns The onVRDisplayChangedObservable
  28482. */
  28483. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28484. /** @hidden */
  28485. _prepareVRComponent(): void;
  28486. /** @hidden */
  28487. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28488. /** @hidden */
  28489. _submitVRFrame(): void;
  28490. /**
  28491. * Call this function to leave webVR mode
  28492. * Will do nothing if webVR is not supported or if there is no webVR device
  28493. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28494. */
  28495. disableVR(): void;
  28496. /**
  28497. * Gets a boolean indicating that the system is in VR mode and is presenting
  28498. * @returns true if VR mode is engaged
  28499. */
  28500. isVRPresenting(): boolean;
  28501. /** @hidden */
  28502. _requestVRFrame(): void;
  28503. private _disableTouchAction;
  28504. private _rebuildInternalTextures;
  28505. private _rebuildEffects;
  28506. /**
  28507. * Gets a boolean indicating if all created effects are ready
  28508. * @returns true if all effects are ready
  28509. */
  28510. areAllEffectsReady(): boolean;
  28511. private _rebuildBuffers;
  28512. private _initGLContext;
  28513. /**
  28514. * Gets version of the current webGL context
  28515. */
  28516. readonly webGLVersion: number;
  28517. /**
  28518. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28519. */
  28520. readonly isStencilEnable: boolean;
  28521. /** @hidden */
  28522. _prepareWorkingCanvas(): void;
  28523. /**
  28524. * Reset the texture cache to empty state
  28525. */
  28526. resetTextureCache(): void;
  28527. /**
  28528. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28530. * @returns true if engine is in deterministic lock step mode
  28531. */
  28532. isDeterministicLockStep(): boolean;
  28533. /**
  28534. * Gets the max steps when engine is running in deterministic lock step
  28535. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28536. * @returns the max steps
  28537. */
  28538. getLockstepMaxSteps(): number;
  28539. /**
  28540. * Gets an object containing information about the current webGL context
  28541. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28542. */
  28543. getGlInfo(): {
  28544. vendor: string;
  28545. renderer: string;
  28546. version: string;
  28547. };
  28548. /**
  28549. * Gets current aspect ratio
  28550. * @param camera defines the camera to use to get the aspect ratio
  28551. * @param useScreen defines if screen size must be used (or the current render target if any)
  28552. * @returns a number defining the aspect ratio
  28553. */
  28554. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28555. /**
  28556. * Gets current screen aspect ratio
  28557. * @returns a number defining the aspect ratio
  28558. */
  28559. getScreenAspectRatio(): number;
  28560. /**
  28561. * Gets the current render width
  28562. * @param useScreen defines if screen size must be used (or the current render target if any)
  28563. * @returns a number defining the current render width
  28564. */
  28565. getRenderWidth(useScreen?: boolean): number;
  28566. /**
  28567. * Gets the current render height
  28568. * @param useScreen defines if screen size must be used (or the current render target if any)
  28569. * @returns a number defining the current render height
  28570. */
  28571. getRenderHeight(useScreen?: boolean): number;
  28572. /**
  28573. * Gets the HTML canvas attached with the current webGL context
  28574. * @returns a HTML canvas
  28575. */
  28576. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28577. /**
  28578. * Gets the client rect of the HTML canvas attached with the current webGL context
  28579. * @returns a client rectanglee
  28580. */
  28581. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28582. /**
  28583. * Defines the hardware scaling level.
  28584. * By default the hardware scaling level is computed from the window device ratio.
  28585. * 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.
  28586. * @param level defines the level to use
  28587. */
  28588. setHardwareScalingLevel(level: number): void;
  28589. /**
  28590. * Gets the current hardware scaling level.
  28591. * By default the hardware scaling level is computed from the window device ratio.
  28592. * 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.
  28593. * @returns a number indicating the current hardware scaling level
  28594. */
  28595. getHardwareScalingLevel(): number;
  28596. /**
  28597. * Gets the list of loaded textures
  28598. * @returns an array containing all loaded textures
  28599. */
  28600. getLoadedTexturesCache(): InternalTexture[];
  28601. /**
  28602. * Gets the object containing all engine capabilities
  28603. * @returns the EngineCapabilities object
  28604. */
  28605. getCaps(): EngineCapabilities;
  28606. /**
  28607. * Gets the current depth function
  28608. * @returns a number defining the depth function
  28609. */
  28610. getDepthFunction(): Nullable<number>;
  28611. /**
  28612. * Sets the current depth function
  28613. * @param depthFunc defines the function to use
  28614. */
  28615. setDepthFunction(depthFunc: number): void;
  28616. /**
  28617. * Sets the current depth function to GREATER
  28618. */
  28619. setDepthFunctionToGreater(): void;
  28620. /**
  28621. * Sets the current depth function to GEQUAL
  28622. */
  28623. setDepthFunctionToGreaterOrEqual(): void;
  28624. /**
  28625. * Sets the current depth function to LESS
  28626. */
  28627. setDepthFunctionToLess(): void;
  28628. private _cachedStencilBuffer;
  28629. private _cachedStencilFunction;
  28630. private _cachedStencilMask;
  28631. private _cachedStencilOperationPass;
  28632. private _cachedStencilOperationFail;
  28633. private _cachedStencilOperationDepthFail;
  28634. private _cachedStencilReference;
  28635. /**
  28636. * Caches the the state of the stencil buffer
  28637. */
  28638. cacheStencilState(): void;
  28639. /**
  28640. * Restores the state of the stencil buffer
  28641. */
  28642. restoreStencilState(): void;
  28643. /**
  28644. * Sets the current depth function to LEQUAL
  28645. */
  28646. setDepthFunctionToLessOrEqual(): void;
  28647. /**
  28648. * Gets a boolean indicating if stencil buffer is enabled
  28649. * @returns the current stencil buffer state
  28650. */
  28651. getStencilBuffer(): boolean;
  28652. /**
  28653. * Enable or disable the stencil buffer
  28654. * @param enable defines if the stencil buffer must be enabled or disabled
  28655. */
  28656. setStencilBuffer(enable: boolean): void;
  28657. /**
  28658. * Gets the current stencil mask
  28659. * @returns a number defining the new stencil mask to use
  28660. */
  28661. getStencilMask(): number;
  28662. /**
  28663. * Sets the current stencil mask
  28664. * @param mask defines the new stencil mask to use
  28665. */
  28666. setStencilMask(mask: number): void;
  28667. /**
  28668. * Gets the current stencil function
  28669. * @returns a number defining the stencil function to use
  28670. */
  28671. getStencilFunction(): number;
  28672. /**
  28673. * Gets the current stencil reference value
  28674. * @returns a number defining the stencil reference value to use
  28675. */
  28676. getStencilFunctionReference(): number;
  28677. /**
  28678. * Gets the current stencil mask
  28679. * @returns a number defining the stencil mask to use
  28680. */
  28681. getStencilFunctionMask(): number;
  28682. /**
  28683. * Sets the current stencil function
  28684. * @param stencilFunc defines the new stencil function to use
  28685. */
  28686. setStencilFunction(stencilFunc: number): void;
  28687. /**
  28688. * Sets the current stencil reference
  28689. * @param reference defines the new stencil reference to use
  28690. */
  28691. setStencilFunctionReference(reference: number): void;
  28692. /**
  28693. * Sets the current stencil mask
  28694. * @param mask defines the new stencil mask to use
  28695. */
  28696. setStencilFunctionMask(mask: number): void;
  28697. /**
  28698. * Gets the current stencil operation when stencil fails
  28699. * @returns a number defining stencil operation to use when stencil fails
  28700. */
  28701. getStencilOperationFail(): number;
  28702. /**
  28703. * Gets the current stencil operation when depth fails
  28704. * @returns a number defining stencil operation to use when depth fails
  28705. */
  28706. getStencilOperationDepthFail(): number;
  28707. /**
  28708. * Gets the current stencil operation when stencil passes
  28709. * @returns a number defining stencil operation to use when stencil passes
  28710. */
  28711. getStencilOperationPass(): number;
  28712. /**
  28713. * Sets the stencil operation to use when stencil fails
  28714. * @param operation defines the stencil operation to use when stencil fails
  28715. */
  28716. setStencilOperationFail(operation: number): void;
  28717. /**
  28718. * Sets the stencil operation to use when depth fails
  28719. * @param operation defines the stencil operation to use when depth fails
  28720. */
  28721. setStencilOperationDepthFail(operation: number): void;
  28722. /**
  28723. * Sets the stencil operation to use when stencil passes
  28724. * @param operation defines the stencil operation to use when stencil passes
  28725. */
  28726. setStencilOperationPass(operation: number): void;
  28727. /**
  28728. * Sets a boolean indicating if the dithering state is enabled or disabled
  28729. * @param value defines the dithering state
  28730. */
  28731. setDitheringState(value: boolean): void;
  28732. /**
  28733. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28734. * @param value defines the rasterizer state
  28735. */
  28736. setRasterizerState(value: boolean): void;
  28737. /**
  28738. * stop executing a render loop function and remove it from the execution array
  28739. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28740. */
  28741. stopRenderLoop(renderFunction?: () => void): void;
  28742. /** @hidden */
  28743. _renderLoop(): void;
  28744. /**
  28745. * Register and execute a render loop. The engine can have more than one render function
  28746. * @param renderFunction defines the function to continuously execute
  28747. */
  28748. runRenderLoop(renderFunction: () => void): void;
  28749. /**
  28750. * Toggle full screen mode
  28751. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28752. */
  28753. switchFullscreen(requestPointerLock: boolean): void;
  28754. /**
  28755. * Enters full screen mode
  28756. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28757. */
  28758. enterFullscreen(requestPointerLock: boolean): void;
  28759. /**
  28760. * Exits full screen mode
  28761. */
  28762. exitFullscreen(): void;
  28763. /**
  28764. * Clear the current render buffer or the current render target (if any is set up)
  28765. * @param color defines the color to use
  28766. * @param backBuffer defines if the back buffer must be cleared
  28767. * @param depth defines if the depth buffer must be cleared
  28768. * @param stencil defines if the stencil buffer must be cleared
  28769. */
  28770. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28771. /**
  28772. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28773. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28774. * @param y defines the y-coordinate of the corner of the clear rectangle
  28775. * @param width defines the width of the clear rectangle
  28776. * @param height defines the height of the clear rectangle
  28777. * @param clearColor defines the clear color
  28778. */
  28779. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28780. /**
  28781. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28782. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28783. * @param y defines the y-coordinate of the corner of the clear rectangle
  28784. * @param width defines the width of the clear rectangle
  28785. * @param height defines the height of the clear rectangle
  28786. */
  28787. enableScissor(x: number, y: number, width: number, height: number): void;
  28788. /**
  28789. * Disable previously set scissor test rectangle
  28790. */
  28791. disableScissor(): void;
  28792. private _viewportCached;
  28793. /** @hidden */
  28794. _viewport(x: number, y: number, width: number, height: number): void;
  28795. /**
  28796. * Set the WebGL's viewport
  28797. * @param viewport defines the viewport element to be used
  28798. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28799. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28800. */
  28801. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28802. /**
  28803. * Directly set the WebGL Viewport
  28804. * @param x defines the x coordinate of the viewport (in screen space)
  28805. * @param y defines the y coordinate of the viewport (in screen space)
  28806. * @param width defines the width of the viewport (in screen space)
  28807. * @param height defines the height of the viewport (in screen space)
  28808. * @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
  28809. */
  28810. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28811. /**
  28812. * Begin a new frame
  28813. */
  28814. beginFrame(): void;
  28815. /**
  28816. * Enf the current frame
  28817. */
  28818. endFrame(): void;
  28819. /**
  28820. * Resize the view according to the canvas' size
  28821. */
  28822. resize(): void;
  28823. /**
  28824. * Force a specific size of the canvas
  28825. * @param width defines the new canvas' width
  28826. * @param height defines the new canvas' height
  28827. */
  28828. setSize(width: number, height: number): void;
  28829. /**
  28830. * Binds the frame buffer to the specified texture.
  28831. * @param texture The texture to render to or null for the default canvas
  28832. * @param faceIndex The face of the texture to render to in case of cube texture
  28833. * @param requiredWidth The width of the target to render to
  28834. * @param requiredHeight The height of the target to render to
  28835. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28836. * @param depthStencilTexture The depth stencil texture to use to render
  28837. * @param lodLevel defines le lod level to bind to the frame buffer
  28838. */
  28839. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28840. /** @hidden */
  28841. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28842. /**
  28843. * Unbind the current render target texture from the webGL context
  28844. * @param texture defines the render target texture to unbind
  28845. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28846. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28847. */
  28848. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28849. /**
  28850. * Force the mipmap generation for the given render target texture
  28851. * @param texture defines the render target texture to use
  28852. */
  28853. generateMipMapsForCubemap(texture: InternalTexture): void;
  28854. /**
  28855. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28856. */
  28857. flushFramebuffer(): void;
  28858. /**
  28859. * Unbind the current render target and bind the default framebuffer
  28860. */
  28861. restoreDefaultFramebuffer(): void;
  28862. /**
  28863. * Create an uniform buffer
  28864. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28865. * @param elements defines the content of the uniform buffer
  28866. * @returns the webGL uniform buffer
  28867. */
  28868. createUniformBuffer(elements: FloatArray): DataBuffer;
  28869. /**
  28870. * Create a dynamic uniform buffer
  28871. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28872. * @param elements defines the content of the uniform buffer
  28873. * @returns the webGL uniform buffer
  28874. */
  28875. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28876. /**
  28877. * Update an existing uniform buffer
  28878. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28879. * @param uniformBuffer defines the target uniform buffer
  28880. * @param elements defines the content to update
  28881. * @param offset defines the offset in the uniform buffer where update should start
  28882. * @param count defines the size of the data to update
  28883. */
  28884. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28885. private _resetVertexBufferBinding;
  28886. /**
  28887. * Creates a vertex buffer
  28888. * @param data the data for the vertex buffer
  28889. * @returns the new WebGL static buffer
  28890. */
  28891. createVertexBuffer(data: DataArray): DataBuffer;
  28892. /**
  28893. * Creates a dynamic vertex buffer
  28894. * @param data the data for the dynamic vertex buffer
  28895. * @returns the new WebGL dynamic buffer
  28896. */
  28897. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28898. /**
  28899. * Update a dynamic index buffer
  28900. * @param indexBuffer defines the target index buffer
  28901. * @param indices defines the data to update
  28902. * @param offset defines the offset in the target index buffer where update should start
  28903. */
  28904. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28905. /**
  28906. * Updates a dynamic vertex buffer.
  28907. * @param vertexBuffer the vertex buffer to update
  28908. * @param data the data used to update the vertex buffer
  28909. * @param byteOffset the byte offset of the data
  28910. * @param byteLength the byte length of the data
  28911. */
  28912. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28913. private _resetIndexBufferBinding;
  28914. /**
  28915. * Creates a new index buffer
  28916. * @param indices defines the content of the index buffer
  28917. * @param updatable defines if the index buffer must be updatable
  28918. * @returns a new webGL buffer
  28919. */
  28920. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28921. /**
  28922. * Bind a webGL buffer to the webGL context
  28923. * @param buffer defines the buffer to bind
  28924. */
  28925. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28926. /**
  28927. * Bind an uniform buffer to the current webGL context
  28928. * @param buffer defines the buffer to bind
  28929. */
  28930. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28931. /**
  28932. * Bind a buffer to the current webGL context at a given location
  28933. * @param buffer defines the buffer to bind
  28934. * @param location defines the index where to bind the buffer
  28935. */
  28936. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28937. /**
  28938. * Bind a specific block at a given index in a specific shader program
  28939. * @param pipelineContext defines the pipeline context to use
  28940. * @param blockName defines the block name
  28941. * @param index defines the index where to bind the block
  28942. */
  28943. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28944. private bindIndexBuffer;
  28945. private bindBuffer;
  28946. /**
  28947. * update the bound buffer with the given data
  28948. * @param data defines the data to update
  28949. */
  28950. updateArrayBuffer(data: Float32Array): void;
  28951. private _vertexAttribPointer;
  28952. private _bindIndexBufferWithCache;
  28953. private _bindVertexBuffersAttributes;
  28954. /**
  28955. * Records a vertex array object
  28956. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28957. * @param vertexBuffers defines the list of vertex buffers to store
  28958. * @param indexBuffer defines the index buffer to store
  28959. * @param effect defines the effect to store
  28960. * @returns the new vertex array object
  28961. */
  28962. recordVertexArrayObject(vertexBuffers: {
  28963. [key: string]: VertexBuffer;
  28964. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28965. /**
  28966. * Bind a specific vertex array object
  28967. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28968. * @param vertexArrayObject defines the vertex array object to bind
  28969. * @param indexBuffer defines the index buffer to bind
  28970. */
  28971. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28972. /**
  28973. * Bind webGl buffers directly to the webGL context
  28974. * @param vertexBuffer defines the vertex buffer to bind
  28975. * @param indexBuffer defines the index buffer to bind
  28976. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28977. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28978. * @param effect defines the effect associated with the vertex buffer
  28979. */
  28980. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28981. private _unbindVertexArrayObject;
  28982. /**
  28983. * Bind a list of vertex buffers to the webGL context
  28984. * @param vertexBuffers defines the list of vertex buffers to bind
  28985. * @param indexBuffer defines the index buffer to bind
  28986. * @param effect defines the effect associated with the vertex buffers
  28987. */
  28988. bindBuffers(vertexBuffers: {
  28989. [key: string]: Nullable<VertexBuffer>;
  28990. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28991. /**
  28992. * Unbind all instance attributes
  28993. */
  28994. unbindInstanceAttributes(): void;
  28995. /**
  28996. * Release and free the memory of a vertex array object
  28997. * @param vao defines the vertex array object to delete
  28998. */
  28999. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29000. /** @hidden */
  29001. _releaseBuffer(buffer: DataBuffer): boolean;
  29002. /**
  29003. * Creates a webGL buffer to use with instanciation
  29004. * @param capacity defines the size of the buffer
  29005. * @returns the webGL buffer
  29006. */
  29007. createInstancesBuffer(capacity: number): DataBuffer;
  29008. /**
  29009. * Delete a webGL buffer used with instanciation
  29010. * @param buffer defines the webGL buffer to delete
  29011. */
  29012. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29013. /**
  29014. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29015. * @param instancesBuffer defines the webGL buffer to update and bind
  29016. * @param data defines the data to store in the buffer
  29017. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29018. */
  29019. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29020. /**
  29021. * Apply all cached states (depth, culling, stencil and alpha)
  29022. */
  29023. applyStates(): void;
  29024. /**
  29025. * Send a draw order
  29026. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29027. * @param indexStart defines the starting index
  29028. * @param indexCount defines the number of index to draw
  29029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29030. */
  29031. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29032. /**
  29033. * Draw a list of points
  29034. * @param verticesStart defines the index of first vertex to draw
  29035. * @param verticesCount defines the count of vertices to draw
  29036. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29037. */
  29038. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29039. /**
  29040. * Draw a list of unindexed primitives
  29041. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29042. * @param verticesStart defines the index of first vertex to draw
  29043. * @param verticesCount defines the count of vertices to draw
  29044. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29045. */
  29046. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29047. /**
  29048. * Draw a list of indexed primitives
  29049. * @param fillMode defines the primitive to use
  29050. * @param indexStart defines the starting index
  29051. * @param indexCount defines the number of index to draw
  29052. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29053. */
  29054. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29055. /**
  29056. * Draw a list of unindexed primitives
  29057. * @param fillMode defines the primitive to use
  29058. * @param verticesStart defines the index of first vertex to draw
  29059. * @param verticesCount defines the count of vertices to draw
  29060. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29061. */
  29062. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29063. private _drawMode;
  29064. /** @hidden */
  29065. _releaseEffect(effect: Effect): void;
  29066. /** @hidden */
  29067. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29068. /**
  29069. * Create a new effect (used to store vertex/fragment shaders)
  29070. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29071. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29072. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29073. * @param samplers defines an array of string used to represent textures
  29074. * @param defines defines the string containing the defines to use to compile the shaders
  29075. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29076. * @param onCompiled defines a function to call when the effect creation is successful
  29077. * @param onError defines a function to call when the effect creation has failed
  29078. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29079. * @returns the new Effect
  29080. */
  29081. 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;
  29082. private _compileShader;
  29083. private _compileRawShader;
  29084. /**
  29085. * Directly creates a webGL program
  29086. * @param pipelineContext defines the pipeline context to attach to
  29087. * @param vertexCode defines the vertex shader code to use
  29088. * @param fragmentCode defines the fragment shader code to use
  29089. * @param context defines the webGL context to use (if not set, the current one will be used)
  29090. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29091. * @returns the new webGL program
  29092. */
  29093. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29094. /**
  29095. * Creates a webGL program
  29096. * @param pipelineContext defines the pipeline context to attach to
  29097. * @param vertexCode defines the vertex shader code to use
  29098. * @param fragmentCode defines the fragment shader code to use
  29099. * @param defines defines the string containing the defines to use to compile the shaders
  29100. * @param context defines the webGL context to use (if not set, the current one will be used)
  29101. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29102. * @returns the new webGL program
  29103. */
  29104. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29105. /**
  29106. * Creates a new pipeline context
  29107. * @returns the new pipeline
  29108. */
  29109. createPipelineContext(): WebGLPipelineContext;
  29110. private _createShaderProgram;
  29111. private _finalizePipelineContext;
  29112. /** @hidden */
  29113. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29114. /** @hidden */
  29115. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29116. /** @hidden */
  29117. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29118. /**
  29119. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29120. * @param pipelineContext defines the pipeline context to use
  29121. * @param uniformsNames defines the list of uniform names
  29122. * @returns an array of webGL uniform locations
  29123. */
  29124. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29125. /**
  29126. * Gets the lsit of active attributes for a given webGL program
  29127. * @param pipelineContext defines the pipeline context to use
  29128. * @param attributesNames defines the list of attribute names to get
  29129. * @returns an array of indices indicating the offset of each attribute
  29130. */
  29131. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29132. /**
  29133. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29134. * @param effect defines the effect to activate
  29135. */
  29136. enableEffect(effect: Nullable<Effect>): void;
  29137. /**
  29138. * Set the value of an uniform to an array of int32
  29139. * @param uniform defines the webGL uniform location where to store the value
  29140. * @param array defines the array of int32 to store
  29141. */
  29142. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29143. /**
  29144. * Set the value of an uniform to an array of int32 (stored as vec2)
  29145. * @param uniform defines the webGL uniform location where to store the value
  29146. * @param array defines the array of int32 to store
  29147. */
  29148. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29149. /**
  29150. * Set the value of an uniform to an array of int32 (stored as vec3)
  29151. * @param uniform defines the webGL uniform location where to store the value
  29152. * @param array defines the array of int32 to store
  29153. */
  29154. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29155. /**
  29156. * Set the value of an uniform to an array of int32 (stored as vec4)
  29157. * @param uniform defines the webGL uniform location where to store the value
  29158. * @param array defines the array of int32 to store
  29159. */
  29160. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29161. /**
  29162. * Set the value of an uniform to an array of float32
  29163. * @param uniform defines the webGL uniform location where to store the value
  29164. * @param array defines the array of float32 to store
  29165. */
  29166. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29167. /**
  29168. * Set the value of an uniform to an array of float32 (stored as vec2)
  29169. * @param uniform defines the webGL uniform location where to store the value
  29170. * @param array defines the array of float32 to store
  29171. */
  29172. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29173. /**
  29174. * Set the value of an uniform to an array of float32 (stored as vec3)
  29175. * @param uniform defines the webGL uniform location where to store the value
  29176. * @param array defines the array of float32 to store
  29177. */
  29178. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29179. /**
  29180. * Set the value of an uniform to an array of float32 (stored as vec4)
  29181. * @param uniform defines the webGL uniform location where to store the value
  29182. * @param array defines the array of float32 to store
  29183. */
  29184. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29185. /**
  29186. * Set the value of an uniform to an array of number
  29187. * @param uniform defines the webGL uniform location where to store the value
  29188. * @param array defines the array of number to store
  29189. */
  29190. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29191. /**
  29192. * Set the value of an uniform to an array of number (stored as vec2)
  29193. * @param uniform defines the webGL uniform location where to store the value
  29194. * @param array defines the array of number to store
  29195. */
  29196. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29197. /**
  29198. * Set the value of an uniform to an array of number (stored as vec3)
  29199. * @param uniform defines the webGL uniform location where to store the value
  29200. * @param array defines the array of number to store
  29201. */
  29202. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29203. /**
  29204. * Set the value of an uniform to an array of number (stored as vec4)
  29205. * @param uniform defines the webGL uniform location where to store the value
  29206. * @param array defines the array of number to store
  29207. */
  29208. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29209. /**
  29210. * Set the value of an uniform to an array of float32 (stored as matrices)
  29211. * @param uniform defines the webGL uniform location where to store the value
  29212. * @param matrices defines the array of float32 to store
  29213. */
  29214. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29215. /**
  29216. * Set the value of an uniform to a matrix
  29217. * @param uniform defines the webGL uniform location where to store the value
  29218. * @param matrix defines the matrix to store
  29219. */
  29220. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29221. /**
  29222. * Set the value of an uniform to a matrix (3x3)
  29223. * @param uniform defines the webGL uniform location where to store the value
  29224. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29225. */
  29226. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29227. /**
  29228. * Set the value of an uniform to a matrix (2x2)
  29229. * @param uniform defines the webGL uniform location where to store the value
  29230. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29231. */
  29232. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29233. /**
  29234. * Set the value of an uniform to a number (int)
  29235. * @param uniform defines the webGL uniform location where to store the value
  29236. * @param value defines the int number to store
  29237. */
  29238. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29239. /**
  29240. * Set the value of an uniform to a number (float)
  29241. * @param uniform defines the webGL uniform location where to store the value
  29242. * @param value defines the float number to store
  29243. */
  29244. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29245. /**
  29246. * Set the value of an uniform to a vec2
  29247. * @param uniform defines the webGL uniform location where to store the value
  29248. * @param x defines the 1st component of the value
  29249. * @param y defines the 2nd component of the value
  29250. */
  29251. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29252. /**
  29253. * Set the value of an uniform to a vec3
  29254. * @param uniform defines the webGL uniform location where to store the value
  29255. * @param x defines the 1st component of the value
  29256. * @param y defines the 2nd component of the value
  29257. * @param z defines the 3rd component of the value
  29258. */
  29259. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29260. /**
  29261. * Set the value of an uniform to a boolean
  29262. * @param uniform defines the webGL uniform location where to store the value
  29263. * @param bool defines the boolean to store
  29264. */
  29265. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29266. /**
  29267. * Set the value of an uniform to a vec4
  29268. * @param uniform defines the webGL uniform location where to store the value
  29269. * @param x defines the 1st component of the value
  29270. * @param y defines the 2nd component of the value
  29271. * @param z defines the 3rd component of the value
  29272. * @param w defines the 4th component of the value
  29273. */
  29274. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29275. /**
  29276. * Set the value of an uniform to a Color3
  29277. * @param uniform defines the webGL uniform location where to store the value
  29278. * @param color3 defines the color to store
  29279. */
  29280. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29281. /**
  29282. * Set the value of an uniform to a Color3 and an alpha value
  29283. * @param uniform defines the webGL uniform location where to store the value
  29284. * @param color3 defines the color to store
  29285. * @param alpha defines the alpha component to store
  29286. */
  29287. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29288. /**
  29289. * Sets a Color4 on a uniform variable
  29290. * @param uniform defines the uniform location
  29291. * @param color4 defines the value to be set
  29292. */
  29293. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29294. /**
  29295. * Set various states to the webGL context
  29296. * @param culling defines backface culling state
  29297. * @param zOffset defines the value to apply to zOffset (0 by default)
  29298. * @param force defines if states must be applied even if cache is up to date
  29299. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29300. */
  29301. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29302. /**
  29303. * Set the z offset to apply to current rendering
  29304. * @param value defines the offset to apply
  29305. */
  29306. setZOffset(value: number): void;
  29307. /**
  29308. * Gets the current value of the zOffset
  29309. * @returns the current zOffset state
  29310. */
  29311. getZOffset(): number;
  29312. /**
  29313. * Enable or disable depth buffering
  29314. * @param enable defines the state to set
  29315. */
  29316. setDepthBuffer(enable: boolean): void;
  29317. /**
  29318. * Gets a boolean indicating if depth writing is enabled
  29319. * @returns the current depth writing state
  29320. */
  29321. getDepthWrite(): boolean;
  29322. /**
  29323. * Enable or disable depth writing
  29324. * @param enable defines the state to set
  29325. */
  29326. setDepthWrite(enable: boolean): void;
  29327. /**
  29328. * Enable or disable color writing
  29329. * @param enable defines the state to set
  29330. */
  29331. setColorWrite(enable: boolean): void;
  29332. /**
  29333. * Gets a boolean indicating if color writing is enabled
  29334. * @returns the current color writing state
  29335. */
  29336. getColorWrite(): boolean;
  29337. /**
  29338. * Sets alpha constants used by some alpha blending modes
  29339. * @param r defines the red component
  29340. * @param g defines the green component
  29341. * @param b defines the blue component
  29342. * @param a defines the alpha component
  29343. */
  29344. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29345. /**
  29346. * Sets the current alpha mode
  29347. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29348. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29349. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29350. */
  29351. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29352. /**
  29353. * Gets the current alpha mode
  29354. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29355. * @returns the current alpha mode
  29356. */
  29357. getAlphaMode(): number;
  29358. /**
  29359. * Clears the list of texture accessible through engine.
  29360. * This can help preventing texture load conflict due to name collision.
  29361. */
  29362. clearInternalTexturesCache(): void;
  29363. /**
  29364. * Force the entire cache to be cleared
  29365. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29366. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29367. */
  29368. wipeCaches(bruteForce?: boolean): void;
  29369. /**
  29370. * Set the compressed texture format to use, based on the formats you have, and the formats
  29371. * supported by the hardware / browser.
  29372. *
  29373. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29374. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29375. * to API arguments needed to compressed textures. This puts the burden on the container
  29376. * generator to house the arcane code for determining these for current & future formats.
  29377. *
  29378. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29379. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29380. *
  29381. * Note: The result of this call is not taken into account when a texture is base64.
  29382. *
  29383. * @param formatsAvailable defines the list of those format families you have created
  29384. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29385. *
  29386. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29387. * @returns The extension selected.
  29388. */
  29389. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29390. /** @hidden */
  29391. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29392. min: number;
  29393. mag: number;
  29394. };
  29395. /** @hidden */
  29396. _createTexture(): WebGLTexture;
  29397. /**
  29398. * Usually called from Texture.ts.
  29399. * Passed information to create a WebGLTexture
  29400. * @param urlArg defines a value which contains one of the following:
  29401. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29402. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29403. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29404. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29405. * @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)
  29406. * @param scene needed for loading to the correct scene
  29407. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29408. * @param onLoad optional callback to be called upon successful completion
  29409. * @param onError optional callback to be called upon failure
  29410. * @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
  29411. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29412. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29413. * @param forcedExtension defines the extension to use to pick the right loader
  29414. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29415. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29416. */
  29417. 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;
  29418. private _rescaleTexture;
  29419. private _unpackFlipYCached;
  29420. /**
  29421. * In case you are sharing the context with other applications, it might
  29422. * be interested to not cache the unpack flip y state to ensure a consistent
  29423. * value would be set.
  29424. */
  29425. enableUnpackFlipYCached: boolean;
  29426. /** @hidden */
  29427. _unpackFlipY(value: boolean): void;
  29428. /** @hidden */
  29429. _getUnpackAlignement(): number;
  29430. /**
  29431. * Creates a dynamic texture
  29432. * @param width defines the width of the texture
  29433. * @param height defines the height of the texture
  29434. * @param generateMipMaps defines if the engine should generate the mip levels
  29435. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29436. * @returns the dynamic texture inside an InternalTexture
  29437. */
  29438. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29439. /**
  29440. * Update the sampling mode of a given texture
  29441. * @param samplingMode defines the required sampling mode
  29442. * @param texture defines the texture to update
  29443. */
  29444. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29445. /**
  29446. * Update the content of a dynamic texture
  29447. * @param texture defines the texture to update
  29448. * @param canvas defines the canvas containing the source
  29449. * @param invertY defines if data must be stored with Y axis inverted
  29450. * @param premulAlpha defines if alpha is stored as premultiplied
  29451. * @param format defines the format of the data
  29452. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29453. */
  29454. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29455. /**
  29456. * Update a video texture
  29457. * @param texture defines the texture to update
  29458. * @param video defines the video element to use
  29459. * @param invertY defines if data must be stored with Y axis inverted
  29460. */
  29461. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29462. /**
  29463. * Updates a depth texture Comparison Mode and Function.
  29464. * If the comparison Function is equal to 0, the mode will be set to none.
  29465. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29466. * @param texture The texture to set the comparison function for
  29467. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29468. */
  29469. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29470. /** @hidden */
  29471. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29472. width: number;
  29473. height: number;
  29474. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29475. /**
  29476. * Creates a depth stencil texture.
  29477. * This is only available in WebGL 2 or with the depth texture extension available.
  29478. * @param size The size of face edge in the texture.
  29479. * @param options The options defining the texture.
  29480. * @returns The texture
  29481. */
  29482. createDepthStencilTexture(size: number | {
  29483. width: number;
  29484. height: number;
  29485. }, options: DepthTextureCreationOptions): InternalTexture;
  29486. /**
  29487. * Creates a depth stencil texture.
  29488. * This is only available in WebGL 2 or with the depth texture extension available.
  29489. * @param size The size of face edge in the texture.
  29490. * @param options The options defining the texture.
  29491. * @returns The texture
  29492. */
  29493. private _createDepthStencilTexture;
  29494. /**
  29495. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29496. * @param renderTarget The render target to set the frame buffer for
  29497. */
  29498. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29499. /**
  29500. * Creates a new render target texture
  29501. * @param size defines the size of the texture
  29502. * @param options defines the options used to create the texture
  29503. * @returns a new render target texture stored in an InternalTexture
  29504. */
  29505. createRenderTargetTexture(size: number | {
  29506. width: number;
  29507. height: number;
  29508. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29509. /** @hidden */
  29510. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29511. /**
  29512. * Updates the sample count of a render target texture
  29513. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29514. * @param texture defines the texture to update
  29515. * @param samples defines the sample count to set
  29516. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29517. */
  29518. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29519. /** @hidden */
  29520. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29521. /** @hidden */
  29522. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29523. /** @hidden */
  29524. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29525. /** @hidden */
  29526. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29527. /**
  29528. * @hidden
  29529. */
  29530. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29531. private _prepareWebGLTextureContinuation;
  29532. private _prepareWebGLTexture;
  29533. /** @hidden */
  29534. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29535. /** @hidden */
  29536. _releaseFramebufferObjects(texture: InternalTexture): void;
  29537. /** @hidden */
  29538. _releaseTexture(texture: InternalTexture): void;
  29539. private setProgram;
  29540. private _boundUniforms;
  29541. /**
  29542. * Binds an effect to the webGL context
  29543. * @param effect defines the effect to bind
  29544. */
  29545. bindSamplers(effect: Effect): void;
  29546. private _activateCurrentTexture;
  29547. /** @hidden */
  29548. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29549. /** @hidden */
  29550. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29551. /**
  29552. * Sets a texture to the webGL context from a postprocess
  29553. * @param channel defines the channel to use
  29554. * @param postProcess defines the source postprocess
  29555. */
  29556. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29557. /**
  29558. * Binds the output of the passed in post process to the texture channel specified
  29559. * @param channel The channel the texture should be bound to
  29560. * @param postProcess The post process which's output should be bound
  29561. */
  29562. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29563. /**
  29564. * Unbind all textures from the webGL context
  29565. */
  29566. unbindAllTextures(): void;
  29567. /**
  29568. * Sets a texture to the according uniform.
  29569. * @param channel The texture channel
  29570. * @param uniform The uniform to set
  29571. * @param texture The texture to apply
  29572. */
  29573. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29574. /**
  29575. * Sets a depth stencil texture from a render target to the according uniform.
  29576. * @param channel The texture channel
  29577. * @param uniform The uniform to set
  29578. * @param texture The render target texture containing the depth stencil texture to apply
  29579. */
  29580. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29581. private _bindSamplerUniformToChannel;
  29582. private _getTextureWrapMode;
  29583. private _setTexture;
  29584. /**
  29585. * Sets an array of texture to the webGL context
  29586. * @param channel defines the channel where the texture array must be set
  29587. * @param uniform defines the associated uniform location
  29588. * @param textures defines the array of textures to bind
  29589. */
  29590. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29591. /** @hidden */
  29592. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29593. private _setTextureParameterFloat;
  29594. private _setTextureParameterInteger;
  29595. /**
  29596. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29597. * @param x defines the x coordinate of the rectangle where pixels must be read
  29598. * @param y defines the y coordinate of the rectangle where pixels must be read
  29599. * @param width defines the width of the rectangle where pixels must be read
  29600. * @param height defines the height of the rectangle where pixels must be read
  29601. * @returns a Uint8Array containing RGBA colors
  29602. */
  29603. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29604. /**
  29605. * Add an externaly attached data from its key.
  29606. * This method call will fail and return false, if such key already exists.
  29607. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29608. * @param key the unique key that identifies the data
  29609. * @param data the data object to associate to the key for this Engine instance
  29610. * @return true if no such key were already present and the data was added successfully, false otherwise
  29611. */
  29612. addExternalData<T>(key: string, data: T): boolean;
  29613. /**
  29614. * Get an externaly attached data from its key
  29615. * @param key the unique key that identifies the data
  29616. * @return the associated data, if present (can be null), or undefined if not present
  29617. */
  29618. getExternalData<T>(key: string): T;
  29619. /**
  29620. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29621. * @param key the unique key that identifies the data
  29622. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29623. * @return the associated data, can be null if the factory returned null.
  29624. */
  29625. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29626. /**
  29627. * Remove an externaly attached data from the Engine instance
  29628. * @param key the unique key that identifies the data
  29629. * @return true if the data was successfully removed, false if it doesn't exist
  29630. */
  29631. removeExternalData(key: string): boolean;
  29632. /**
  29633. * Unbind all vertex attributes from the webGL context
  29634. */
  29635. unbindAllAttributes(): void;
  29636. /**
  29637. * 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
  29638. */
  29639. releaseEffects(): void;
  29640. /**
  29641. * Dispose and release all associated resources
  29642. */
  29643. dispose(): void;
  29644. /**
  29645. * Display the loading screen
  29646. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29647. */
  29648. displayLoadingUI(): void;
  29649. /**
  29650. * Hide the loading screen
  29651. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29652. */
  29653. hideLoadingUI(): void;
  29654. /**
  29655. * Gets the current loading screen object
  29656. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29657. */
  29658. /**
  29659. * Sets the current loading screen object
  29660. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29661. */
  29662. loadingScreen: ILoadingScreen;
  29663. /**
  29664. * Sets the current loading screen text
  29665. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29666. */
  29667. loadingUIText: string;
  29668. /**
  29669. * Sets the current loading screen background color
  29670. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29671. */
  29672. loadingUIBackgroundColor: string;
  29673. /**
  29674. * Attach a new callback raised when context lost event is fired
  29675. * @param callback defines the callback to call
  29676. */
  29677. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29678. /**
  29679. * Attach a new callback raised when context restored event is fired
  29680. * @param callback defines the callback to call
  29681. */
  29682. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29683. /**
  29684. * Gets the source code of the vertex shader associated with a specific webGL program
  29685. * @param program defines the program to use
  29686. * @returns a string containing the source code of the vertex shader associated with the program
  29687. */
  29688. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29689. /**
  29690. * Gets the source code of the fragment shader associated with a specific webGL program
  29691. * @param program defines the program to use
  29692. * @returns a string containing the source code of the fragment shader associated with the program
  29693. */
  29694. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29695. /**
  29696. * Get the current error code of the webGL context
  29697. * @returns the error code
  29698. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29699. */
  29700. getError(): number;
  29701. /**
  29702. * Gets the current framerate
  29703. * @returns a number representing the framerate
  29704. */
  29705. getFps(): number;
  29706. /**
  29707. * Gets the time spent between current and previous frame
  29708. * @returns a number representing the delta time in ms
  29709. */
  29710. getDeltaTime(): number;
  29711. private _measureFps;
  29712. /** @hidden */
  29713. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29714. private _canRenderToFloatFramebuffer;
  29715. private _canRenderToHalfFloatFramebuffer;
  29716. private _canRenderToFramebuffer;
  29717. /** @hidden */
  29718. _getWebGLTextureType(type: number): number;
  29719. /** @hidden */
  29720. _getInternalFormat(format: number): number;
  29721. /** @hidden */
  29722. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29723. /** @hidden */
  29724. _getRGBAMultiSampleBufferFormat(type: number): number;
  29725. /** @hidden */
  29726. _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;
  29727. /** @hidden */
  29728. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29729. /**
  29730. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29731. * @returns true if the engine can be created
  29732. * @ignorenaming
  29733. */
  29734. static isSupported(): boolean;
  29735. }
  29736. }
  29737. declare module "babylonjs/Materials/effect" {
  29738. import { Observable } from "babylonjs/Misc/observable";
  29739. import { Nullable } from "babylonjs/types";
  29740. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29741. import { IDisposable } from "babylonjs/scene";
  29742. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29743. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29744. import { Engine } from "babylonjs/Engines/engine";
  29745. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29748. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29750. /**
  29751. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29752. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29753. */
  29754. export class EffectFallbacks {
  29755. private _defines;
  29756. private _currentRank;
  29757. private _maxRank;
  29758. private _mesh;
  29759. /**
  29760. * Removes the fallback from the bound mesh.
  29761. */
  29762. unBindMesh(): void;
  29763. /**
  29764. * Adds a fallback on the specified property.
  29765. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29766. * @param define The name of the define in the shader
  29767. */
  29768. addFallback(rank: number, define: string): void;
  29769. /**
  29770. * Sets the mesh to use CPU skinning when needing to fallback.
  29771. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29772. * @param mesh The mesh to use the fallbacks.
  29773. */
  29774. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29775. /**
  29776. * Checks to see if more fallbacks are still availible.
  29777. */
  29778. readonly isMoreFallbacks: boolean;
  29779. /**
  29780. * Removes the defines that shoould be removed when falling back.
  29781. * @param currentDefines defines the current define statements for the shader.
  29782. * @param effect defines the current effect we try to compile
  29783. * @returns The resulting defines with defines of the current rank removed.
  29784. */
  29785. reduce(currentDefines: string, effect: Effect): string;
  29786. }
  29787. /**
  29788. * Options to be used when creating an effect.
  29789. */
  29790. export class EffectCreationOptions {
  29791. /**
  29792. * Atrributes that will be used in the shader.
  29793. */
  29794. attributes: string[];
  29795. /**
  29796. * Uniform varible names that will be set in the shader.
  29797. */
  29798. uniformsNames: string[];
  29799. /**
  29800. * Uniform buffer varible names that will be set in the shader.
  29801. */
  29802. uniformBuffersNames: string[];
  29803. /**
  29804. * Sampler texture variable names that will be set in the shader.
  29805. */
  29806. samplers: string[];
  29807. /**
  29808. * Define statements that will be set in the shader.
  29809. */
  29810. defines: any;
  29811. /**
  29812. * Possible fallbacks for this effect to improve performance when needed.
  29813. */
  29814. fallbacks: Nullable<EffectFallbacks>;
  29815. /**
  29816. * Callback that will be called when the shader is compiled.
  29817. */
  29818. onCompiled: Nullable<(effect: Effect) => void>;
  29819. /**
  29820. * Callback that will be called if an error occurs during shader compilation.
  29821. */
  29822. onError: Nullable<(effect: Effect, errors: string) => void>;
  29823. /**
  29824. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29825. */
  29826. indexParameters: any;
  29827. /**
  29828. * Max number of lights that can be used in the shader.
  29829. */
  29830. maxSimultaneousLights: number;
  29831. /**
  29832. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29833. */
  29834. transformFeedbackVaryings: Nullable<string[]>;
  29835. }
  29836. /**
  29837. * Effect containing vertex and fragment shader that can be executed on an object.
  29838. */
  29839. export class Effect implements IDisposable {
  29840. /**
  29841. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29842. */
  29843. static ShadersRepository: string;
  29844. /**
  29845. * Name of the effect.
  29846. */
  29847. name: any;
  29848. /**
  29849. * String container all the define statements that should be set on the shader.
  29850. */
  29851. defines: string;
  29852. /**
  29853. * Callback that will be called when the shader is compiled.
  29854. */
  29855. onCompiled: Nullable<(effect: Effect) => void>;
  29856. /**
  29857. * Callback that will be called if an error occurs during shader compilation.
  29858. */
  29859. onError: Nullable<(effect: Effect, errors: string) => void>;
  29860. /**
  29861. * Callback that will be called when effect is bound.
  29862. */
  29863. onBind: Nullable<(effect: Effect) => void>;
  29864. /**
  29865. * Unique ID of the effect.
  29866. */
  29867. uniqueId: number;
  29868. /**
  29869. * Observable that will be called when the shader is compiled.
  29870. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29871. */
  29872. onCompileObservable: Observable<Effect>;
  29873. /**
  29874. * Observable that will be called if an error occurs during shader compilation.
  29875. */
  29876. onErrorObservable: Observable<Effect>;
  29877. /** @hidden */
  29878. _onBindObservable: Nullable<Observable<Effect>>;
  29879. /**
  29880. * Observable that will be called when effect is bound.
  29881. */
  29882. readonly onBindObservable: Observable<Effect>;
  29883. /** @hidden */
  29884. _bonesComputationForcedToCPU: boolean;
  29885. private static _uniqueIdSeed;
  29886. private _engine;
  29887. private _uniformBuffersNames;
  29888. private _uniformsNames;
  29889. private _samplerList;
  29890. private _samplers;
  29891. private _isReady;
  29892. private _compilationError;
  29893. private _attributesNames;
  29894. private _attributes;
  29895. private _uniforms;
  29896. /**
  29897. * Key for the effect.
  29898. * @hidden
  29899. */
  29900. _key: string;
  29901. private _indexParameters;
  29902. private _fallbacks;
  29903. private _vertexSourceCode;
  29904. private _fragmentSourceCode;
  29905. private _vertexSourceCodeOverride;
  29906. private _fragmentSourceCodeOverride;
  29907. private _transformFeedbackVaryings;
  29908. /**
  29909. * Compiled shader to webGL program.
  29910. * @hidden
  29911. */
  29912. _pipelineContext: IPipelineContext;
  29913. private _valueCache;
  29914. private static _baseCache;
  29915. /**
  29916. * Instantiates an effect.
  29917. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29918. * @param baseName Name of the effect.
  29919. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29920. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29921. * @param samplers List of sampler variables that will be passed to the shader.
  29922. * @param engine Engine to be used to render the effect
  29923. * @param defines Define statements to be added to the shader.
  29924. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29925. * @param onCompiled Callback that will be called when the shader is compiled.
  29926. * @param onError Callback that will be called if an error occurs during shader compilation.
  29927. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29928. */
  29929. 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);
  29930. /**
  29931. * Unique key for this effect
  29932. */
  29933. readonly key: string;
  29934. /**
  29935. * If the effect has been compiled and prepared.
  29936. * @returns if the effect is compiled and prepared.
  29937. */
  29938. isReady(): boolean;
  29939. /**
  29940. * The engine the effect was initialized with.
  29941. * @returns the engine.
  29942. */
  29943. getEngine(): Engine;
  29944. /**
  29945. * The pipeline context for this effect
  29946. * @returns the associated pipeline context
  29947. */
  29948. getPipelineContext(): IPipelineContext;
  29949. /**
  29950. * The set of names of attribute variables for the shader.
  29951. * @returns An array of attribute names.
  29952. */
  29953. getAttributesNames(): string[];
  29954. /**
  29955. * Returns the attribute at the given index.
  29956. * @param index The index of the attribute.
  29957. * @returns The location of the attribute.
  29958. */
  29959. getAttributeLocation(index: number): number;
  29960. /**
  29961. * Returns the attribute based on the name of the variable.
  29962. * @param name of the attribute to look up.
  29963. * @returns the attribute location.
  29964. */
  29965. getAttributeLocationByName(name: string): number;
  29966. /**
  29967. * The number of attributes.
  29968. * @returns the numnber of attributes.
  29969. */
  29970. getAttributesCount(): number;
  29971. /**
  29972. * Gets the index of a uniform variable.
  29973. * @param uniformName of the uniform to look up.
  29974. * @returns the index.
  29975. */
  29976. getUniformIndex(uniformName: string): number;
  29977. /**
  29978. * Returns the attribute based on the name of the variable.
  29979. * @param uniformName of the uniform to look up.
  29980. * @returns the location of the uniform.
  29981. */
  29982. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29983. /**
  29984. * Returns an array of sampler variable names
  29985. * @returns The array of sampler variable neames.
  29986. */
  29987. getSamplers(): string[];
  29988. /**
  29989. * The error from the last compilation.
  29990. * @returns the error string.
  29991. */
  29992. getCompilationError(): string;
  29993. /**
  29994. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29995. * @param func The callback to be used.
  29996. */
  29997. executeWhenCompiled(func: (effect: Effect) => void): void;
  29998. private _checkIsReady;
  29999. /** @hidden */
  30000. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30001. /** @hidden */
  30002. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30003. /** @hidden */
  30004. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30005. private _processShaderConversion;
  30006. private _processIncludes;
  30007. private _processPrecision;
  30008. /**
  30009. * Recompiles the webGL program
  30010. * @param vertexSourceCode The source code for the vertex shader.
  30011. * @param fragmentSourceCode The source code for the fragment shader.
  30012. * @param onCompiled Callback called when completed.
  30013. * @param onError Callback called on error.
  30014. * @hidden
  30015. */
  30016. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30017. /**
  30018. * Prepares the effect
  30019. * @hidden
  30020. */
  30021. _prepareEffect(): void;
  30022. /**
  30023. * Checks if the effect is supported. (Must be called after compilation)
  30024. */
  30025. readonly isSupported: boolean;
  30026. /**
  30027. * Binds a texture to the engine to be used as output of the shader.
  30028. * @param channel Name of the output variable.
  30029. * @param texture Texture to bind.
  30030. * @hidden
  30031. */
  30032. _bindTexture(channel: string, texture: InternalTexture): void;
  30033. /**
  30034. * Sets a texture on the engine to be used in the shader.
  30035. * @param channel Name of the sampler variable.
  30036. * @param texture Texture to set.
  30037. */
  30038. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30039. /**
  30040. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30041. * @param channel Name of the sampler variable.
  30042. * @param texture Texture to set.
  30043. */
  30044. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30045. /**
  30046. * Sets an array of textures on the engine to be used in the shader.
  30047. * @param channel Name of the variable.
  30048. * @param textures Textures to set.
  30049. */
  30050. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30051. /**
  30052. * 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)
  30053. * @param channel Name of the sampler variable.
  30054. * @param postProcess Post process to get the input texture from.
  30055. */
  30056. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30057. /**
  30058. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30059. * 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)
  30060. * @param channel Name of the sampler variable.
  30061. * @param postProcess Post process to get the output texture from.
  30062. */
  30063. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30064. /** @hidden */
  30065. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30066. /** @hidden */
  30067. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30068. /** @hidden */
  30069. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30070. /** @hidden */
  30071. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30072. /**
  30073. * Binds a buffer to a uniform.
  30074. * @param buffer Buffer to bind.
  30075. * @param name Name of the uniform variable to bind to.
  30076. */
  30077. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30078. /**
  30079. * Binds block to a uniform.
  30080. * @param blockName Name of the block to bind.
  30081. * @param index Index to bind.
  30082. */
  30083. bindUniformBlock(blockName: string, index: number): void;
  30084. /**
  30085. * Sets an interger value on a uniform variable.
  30086. * @param uniformName Name of the variable.
  30087. * @param value Value to be set.
  30088. * @returns this effect.
  30089. */
  30090. setInt(uniformName: string, value: number): Effect;
  30091. /**
  30092. * Sets an int array on a uniform variable.
  30093. * @param uniformName Name of the variable.
  30094. * @param array array to be set.
  30095. * @returns this effect.
  30096. */
  30097. setIntArray(uniformName: string, array: Int32Array): Effect;
  30098. /**
  30099. * 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)
  30100. * @param uniformName Name of the variable.
  30101. * @param array array to be set.
  30102. * @returns this effect.
  30103. */
  30104. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30105. /**
  30106. * 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)
  30107. * @param uniformName Name of the variable.
  30108. * @param array array to be set.
  30109. * @returns this effect.
  30110. */
  30111. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30112. /**
  30113. * 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)
  30114. * @param uniformName Name of the variable.
  30115. * @param array array to be set.
  30116. * @returns this effect.
  30117. */
  30118. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30119. /**
  30120. * Sets an float array on a uniform variable.
  30121. * @param uniformName Name of the variable.
  30122. * @param array array to be set.
  30123. * @returns this effect.
  30124. */
  30125. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30126. /**
  30127. * 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)
  30128. * @param uniformName Name of the variable.
  30129. * @param array array to be set.
  30130. * @returns this effect.
  30131. */
  30132. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30133. /**
  30134. * 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)
  30135. * @param uniformName Name of the variable.
  30136. * @param array array to be set.
  30137. * @returns this effect.
  30138. */
  30139. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30140. /**
  30141. * 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)
  30142. * @param uniformName Name of the variable.
  30143. * @param array array to be set.
  30144. * @returns this effect.
  30145. */
  30146. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30147. /**
  30148. * Sets an array on a uniform variable.
  30149. * @param uniformName Name of the variable.
  30150. * @param array array to be set.
  30151. * @returns this effect.
  30152. */
  30153. setArray(uniformName: string, array: number[]): Effect;
  30154. /**
  30155. * 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)
  30156. * @param uniformName Name of the variable.
  30157. * @param array array to be set.
  30158. * @returns this effect.
  30159. */
  30160. setArray2(uniformName: string, array: number[]): Effect;
  30161. /**
  30162. * 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)
  30163. * @param uniformName Name of the variable.
  30164. * @param array array to be set.
  30165. * @returns this effect.
  30166. */
  30167. setArray3(uniformName: string, array: number[]): Effect;
  30168. /**
  30169. * 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)
  30170. * @param uniformName Name of the variable.
  30171. * @param array array to be set.
  30172. * @returns this effect.
  30173. */
  30174. setArray4(uniformName: string, array: number[]): Effect;
  30175. /**
  30176. * Sets matrices on a uniform variable.
  30177. * @param uniformName Name of the variable.
  30178. * @param matrices matrices to be set.
  30179. * @returns this effect.
  30180. */
  30181. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30182. /**
  30183. * Sets matrix on a uniform variable.
  30184. * @param uniformName Name of the variable.
  30185. * @param matrix matrix to be set.
  30186. * @returns this effect.
  30187. */
  30188. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30189. /**
  30190. * 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)
  30191. * @param uniformName Name of the variable.
  30192. * @param matrix matrix to be set.
  30193. * @returns this effect.
  30194. */
  30195. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30196. /**
  30197. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30198. * @param uniformName Name of the variable.
  30199. * @param matrix matrix to be set.
  30200. * @returns this effect.
  30201. */
  30202. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30203. /**
  30204. * Sets a float on a uniform variable.
  30205. * @param uniformName Name of the variable.
  30206. * @param value value to be set.
  30207. * @returns this effect.
  30208. */
  30209. setFloat(uniformName: string, value: number): Effect;
  30210. /**
  30211. * Sets a boolean on a uniform variable.
  30212. * @param uniformName Name of the variable.
  30213. * @param bool value to be set.
  30214. * @returns this effect.
  30215. */
  30216. setBool(uniformName: string, bool: boolean): Effect;
  30217. /**
  30218. * Sets a Vector2 on a uniform variable.
  30219. * @param uniformName Name of the variable.
  30220. * @param vector2 vector2 to be set.
  30221. * @returns this effect.
  30222. */
  30223. setVector2(uniformName: string, vector2: Vector2): Effect;
  30224. /**
  30225. * Sets a float2 on a uniform variable.
  30226. * @param uniformName Name of the variable.
  30227. * @param x First float in float2.
  30228. * @param y Second float in float2.
  30229. * @returns this effect.
  30230. */
  30231. setFloat2(uniformName: string, x: number, y: number): Effect;
  30232. /**
  30233. * Sets a Vector3 on a uniform variable.
  30234. * @param uniformName Name of the variable.
  30235. * @param vector3 Value to be set.
  30236. * @returns this effect.
  30237. */
  30238. setVector3(uniformName: string, vector3: Vector3): Effect;
  30239. /**
  30240. * Sets a float3 on a uniform variable.
  30241. * @param uniformName Name of the variable.
  30242. * @param x First float in float3.
  30243. * @param y Second float in float3.
  30244. * @param z Third float in float3.
  30245. * @returns this effect.
  30246. */
  30247. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30248. /**
  30249. * Sets a Vector4 on a uniform variable.
  30250. * @param uniformName Name of the variable.
  30251. * @param vector4 Value to be set.
  30252. * @returns this effect.
  30253. */
  30254. setVector4(uniformName: string, vector4: Vector4): Effect;
  30255. /**
  30256. * Sets a float4 on a uniform variable.
  30257. * @param uniformName Name of the variable.
  30258. * @param x First float in float4.
  30259. * @param y Second float in float4.
  30260. * @param z Third float in float4.
  30261. * @param w Fourth float in float4.
  30262. * @returns this effect.
  30263. */
  30264. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30265. /**
  30266. * Sets a Color3 on a uniform variable.
  30267. * @param uniformName Name of the variable.
  30268. * @param color3 Value to be set.
  30269. * @returns this effect.
  30270. */
  30271. setColor3(uniformName: string, color3: Color3): Effect;
  30272. /**
  30273. * Sets a Color4 on a uniform variable.
  30274. * @param uniformName Name of the variable.
  30275. * @param color3 Value to be set.
  30276. * @param alpha Alpha value to be set.
  30277. * @returns this effect.
  30278. */
  30279. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30280. /**
  30281. * Sets a Color4 on a uniform variable
  30282. * @param uniformName defines the name of the variable
  30283. * @param color4 defines the value to be set
  30284. * @returns this effect.
  30285. */
  30286. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30287. /** Release all associated resources */
  30288. dispose(): void;
  30289. /**
  30290. * This function will add a new shader to the shader store
  30291. * @param name the name of the shader
  30292. * @param pixelShader optional pixel shader content
  30293. * @param vertexShader optional vertex shader content
  30294. */
  30295. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30296. /**
  30297. * Store of each shader (The can be looked up using effect.key)
  30298. */
  30299. static ShadersStore: {
  30300. [key: string]: string;
  30301. };
  30302. /**
  30303. * Store of each included file for a shader (The can be looked up using effect.key)
  30304. */
  30305. static IncludesShadersStore: {
  30306. [key: string]: string;
  30307. };
  30308. /**
  30309. * Resets the cache of effects.
  30310. */
  30311. static ResetCache(): void;
  30312. }
  30313. }
  30314. declare module "babylonjs/Materials/colorCurves" {
  30315. import { Effect } from "babylonjs/Materials/effect";
  30316. /**
  30317. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30318. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30319. * 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;
  30320. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30321. */
  30322. export class ColorCurves {
  30323. private _dirty;
  30324. private _tempColor;
  30325. private _globalCurve;
  30326. private _highlightsCurve;
  30327. private _midtonesCurve;
  30328. private _shadowsCurve;
  30329. private _positiveCurve;
  30330. private _negativeCurve;
  30331. private _globalHue;
  30332. private _globalDensity;
  30333. private _globalSaturation;
  30334. private _globalExposure;
  30335. /**
  30336. * Gets the global Hue value.
  30337. * 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).
  30338. */
  30339. /**
  30340. * Sets the global Hue value.
  30341. * 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).
  30342. */
  30343. globalHue: number;
  30344. /**
  30345. * Gets the global Density value.
  30346. * 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.
  30347. * Values less than zero provide a filter of opposite hue.
  30348. */
  30349. /**
  30350. * Sets the global Density value.
  30351. * 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.
  30352. * Values less than zero provide a filter of opposite hue.
  30353. */
  30354. globalDensity: number;
  30355. /**
  30356. * Gets the global Saturation value.
  30357. * 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.
  30358. */
  30359. /**
  30360. * Sets the global Saturation value.
  30361. * 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.
  30362. */
  30363. globalSaturation: number;
  30364. /**
  30365. * Gets the global Exposure value.
  30366. * 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.
  30367. */
  30368. /**
  30369. * Sets the global Exposure value.
  30370. * 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.
  30371. */
  30372. globalExposure: number;
  30373. private _highlightsHue;
  30374. private _highlightsDensity;
  30375. private _highlightsSaturation;
  30376. private _highlightsExposure;
  30377. /**
  30378. * Gets the highlights Hue value.
  30379. * 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).
  30380. */
  30381. /**
  30382. * Sets the highlights Hue value.
  30383. * 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).
  30384. */
  30385. highlightsHue: number;
  30386. /**
  30387. * Gets the highlights Density value.
  30388. * 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.
  30389. * Values less than zero provide a filter of opposite hue.
  30390. */
  30391. /**
  30392. * Sets the highlights Density value.
  30393. * 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.
  30394. * Values less than zero provide a filter of opposite hue.
  30395. */
  30396. highlightsDensity: number;
  30397. /**
  30398. * Gets the highlights Saturation value.
  30399. * 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.
  30400. */
  30401. /**
  30402. * Sets the highlights Saturation value.
  30403. * 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.
  30404. */
  30405. highlightsSaturation: number;
  30406. /**
  30407. * Gets the highlights Exposure value.
  30408. * 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.
  30409. */
  30410. /**
  30411. * Sets the highlights Exposure value.
  30412. * 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.
  30413. */
  30414. highlightsExposure: number;
  30415. private _midtonesHue;
  30416. private _midtonesDensity;
  30417. private _midtonesSaturation;
  30418. private _midtonesExposure;
  30419. /**
  30420. * Gets the midtones Hue value.
  30421. * 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).
  30422. */
  30423. /**
  30424. * Sets the midtones Hue value.
  30425. * 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).
  30426. */
  30427. midtonesHue: number;
  30428. /**
  30429. * Gets the midtones Density value.
  30430. * 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.
  30431. * Values less than zero provide a filter of opposite hue.
  30432. */
  30433. /**
  30434. * Sets the midtones Density value.
  30435. * 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.
  30436. * Values less than zero provide a filter of opposite hue.
  30437. */
  30438. midtonesDensity: number;
  30439. /**
  30440. * Gets the midtones Saturation value.
  30441. * 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.
  30442. */
  30443. /**
  30444. * Sets the midtones Saturation value.
  30445. * 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.
  30446. */
  30447. midtonesSaturation: number;
  30448. /**
  30449. * Gets the midtones Exposure value.
  30450. * 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.
  30451. */
  30452. /**
  30453. * Sets the midtones Exposure value.
  30454. * 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.
  30455. */
  30456. midtonesExposure: number;
  30457. private _shadowsHue;
  30458. private _shadowsDensity;
  30459. private _shadowsSaturation;
  30460. private _shadowsExposure;
  30461. /**
  30462. * Gets the shadows Hue value.
  30463. * 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).
  30464. */
  30465. /**
  30466. * Sets the shadows Hue value.
  30467. * 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).
  30468. */
  30469. shadowsHue: number;
  30470. /**
  30471. * Gets the shadows Density value.
  30472. * 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.
  30473. * Values less than zero provide a filter of opposite hue.
  30474. */
  30475. /**
  30476. * Sets the shadows Density value.
  30477. * 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.
  30478. * Values less than zero provide a filter of opposite hue.
  30479. */
  30480. shadowsDensity: number;
  30481. /**
  30482. * Gets the shadows Saturation value.
  30483. * 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.
  30484. */
  30485. /**
  30486. * Sets the shadows Saturation value.
  30487. * 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.
  30488. */
  30489. shadowsSaturation: number;
  30490. /**
  30491. * Gets the shadows Exposure value.
  30492. * 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.
  30493. */
  30494. /**
  30495. * Sets the shadows Exposure value.
  30496. * 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.
  30497. */
  30498. shadowsExposure: number;
  30499. /**
  30500. * Returns the class name
  30501. * @returns The class name
  30502. */
  30503. getClassName(): string;
  30504. /**
  30505. * Binds the color curves to the shader.
  30506. * @param colorCurves The color curve to bind
  30507. * @param effect The effect to bind to
  30508. * @param positiveUniform The positive uniform shader parameter
  30509. * @param neutralUniform The neutral uniform shader parameter
  30510. * @param negativeUniform The negative uniform shader parameter
  30511. */
  30512. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30513. /**
  30514. * Prepare the list of uniforms associated with the ColorCurves effects.
  30515. * @param uniformsList The list of uniforms used in the effect
  30516. */
  30517. static PrepareUniforms(uniformsList: string[]): void;
  30518. /**
  30519. * Returns color grading data based on a hue, density, saturation and exposure value.
  30520. * @param filterHue The hue of the color filter.
  30521. * @param filterDensity The density of the color filter.
  30522. * @param saturation The saturation.
  30523. * @param exposure The exposure.
  30524. * @param result The result data container.
  30525. */
  30526. private getColorGradingDataToRef;
  30527. /**
  30528. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30529. * @param value The input slider value in range [-100,100].
  30530. * @returns Adjusted value.
  30531. */
  30532. private static applyColorGradingSliderNonlinear;
  30533. /**
  30534. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30535. * @param hue The hue (H) input.
  30536. * @param saturation The saturation (S) input.
  30537. * @param brightness The brightness (B) input.
  30538. * @result An RGBA color represented as Vector4.
  30539. */
  30540. private static fromHSBToRef;
  30541. /**
  30542. * Returns a value clamped between min and max
  30543. * @param value The value to clamp
  30544. * @param min The minimum of value
  30545. * @param max The maximum of value
  30546. * @returns The clamped value.
  30547. */
  30548. private static clamp;
  30549. /**
  30550. * Clones the current color curve instance.
  30551. * @return The cloned curves
  30552. */
  30553. clone(): ColorCurves;
  30554. /**
  30555. * Serializes the current color curve instance to a json representation.
  30556. * @return a JSON representation
  30557. */
  30558. serialize(): any;
  30559. /**
  30560. * Parses the color curve from a json representation.
  30561. * @param source the JSON source to parse
  30562. * @return The parsed curves
  30563. */
  30564. static Parse(source: any): ColorCurves;
  30565. }
  30566. }
  30567. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30568. import { Observable } from "babylonjs/Misc/observable";
  30569. import { Nullable } from "babylonjs/types";
  30570. import { Color4 } from "babylonjs/Maths/math";
  30571. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30572. import { Effect } from "babylonjs/Materials/effect";
  30573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30574. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30575. /**
  30576. * Interface to follow in your material defines to integrate easily the
  30577. * Image proccessing functions.
  30578. * @hidden
  30579. */
  30580. export interface IImageProcessingConfigurationDefines {
  30581. IMAGEPROCESSING: boolean;
  30582. VIGNETTE: boolean;
  30583. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30584. VIGNETTEBLENDMODEOPAQUE: boolean;
  30585. TONEMAPPING: boolean;
  30586. TONEMAPPING_ACES: boolean;
  30587. CONTRAST: boolean;
  30588. EXPOSURE: boolean;
  30589. COLORCURVES: boolean;
  30590. COLORGRADING: boolean;
  30591. COLORGRADING3D: boolean;
  30592. SAMPLER3DGREENDEPTH: boolean;
  30593. SAMPLER3DBGRMAP: boolean;
  30594. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30595. }
  30596. /**
  30597. * @hidden
  30598. */
  30599. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30600. IMAGEPROCESSING: boolean;
  30601. VIGNETTE: boolean;
  30602. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30603. VIGNETTEBLENDMODEOPAQUE: boolean;
  30604. TONEMAPPING: boolean;
  30605. TONEMAPPING_ACES: boolean;
  30606. CONTRAST: boolean;
  30607. COLORCURVES: boolean;
  30608. COLORGRADING: boolean;
  30609. COLORGRADING3D: boolean;
  30610. SAMPLER3DGREENDEPTH: boolean;
  30611. SAMPLER3DBGRMAP: boolean;
  30612. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30613. EXPOSURE: boolean;
  30614. constructor();
  30615. }
  30616. /**
  30617. * This groups together the common properties used for image processing either in direct forward pass
  30618. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30619. * or not.
  30620. */
  30621. export class ImageProcessingConfiguration {
  30622. /**
  30623. * Default tone mapping applied in BabylonJS.
  30624. */
  30625. static readonly TONEMAPPING_STANDARD: number;
  30626. /**
  30627. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30628. * to other engines rendering to increase portability.
  30629. */
  30630. static readonly TONEMAPPING_ACES: number;
  30631. /**
  30632. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30633. */
  30634. colorCurves: Nullable<ColorCurves>;
  30635. private _colorCurvesEnabled;
  30636. /**
  30637. * Gets wether the color curves effect is enabled.
  30638. */
  30639. /**
  30640. * Sets wether the color curves effect is enabled.
  30641. */
  30642. colorCurvesEnabled: boolean;
  30643. private _colorGradingTexture;
  30644. /**
  30645. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30646. */
  30647. /**
  30648. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30649. */
  30650. colorGradingTexture: Nullable<BaseTexture>;
  30651. private _colorGradingEnabled;
  30652. /**
  30653. * Gets wether the color grading effect is enabled.
  30654. */
  30655. /**
  30656. * Sets wether the color grading effect is enabled.
  30657. */
  30658. colorGradingEnabled: boolean;
  30659. private _colorGradingWithGreenDepth;
  30660. /**
  30661. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30662. */
  30663. /**
  30664. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30665. */
  30666. colorGradingWithGreenDepth: boolean;
  30667. private _colorGradingBGR;
  30668. /**
  30669. * Gets wether the color grading texture contains BGR values.
  30670. */
  30671. /**
  30672. * Sets wether the color grading texture contains BGR values.
  30673. */
  30674. colorGradingBGR: boolean;
  30675. /** @hidden */
  30676. _exposure: number;
  30677. /**
  30678. * Gets the Exposure used in the effect.
  30679. */
  30680. /**
  30681. * Sets the Exposure used in the effect.
  30682. */
  30683. exposure: number;
  30684. private _toneMappingEnabled;
  30685. /**
  30686. * Gets wether the tone mapping effect is enabled.
  30687. */
  30688. /**
  30689. * Sets wether the tone mapping effect is enabled.
  30690. */
  30691. toneMappingEnabled: boolean;
  30692. private _toneMappingType;
  30693. /**
  30694. * Gets the type of tone mapping effect.
  30695. */
  30696. /**
  30697. * Sets the type of tone mapping effect used in BabylonJS.
  30698. */
  30699. toneMappingType: number;
  30700. protected _contrast: number;
  30701. /**
  30702. * Gets the contrast used in the effect.
  30703. */
  30704. /**
  30705. * Sets the contrast used in the effect.
  30706. */
  30707. contrast: number;
  30708. /**
  30709. * Vignette stretch size.
  30710. */
  30711. vignetteStretch: number;
  30712. /**
  30713. * Vignette centre X Offset.
  30714. */
  30715. vignetteCentreX: number;
  30716. /**
  30717. * Vignette centre Y Offset.
  30718. */
  30719. vignetteCentreY: number;
  30720. /**
  30721. * Vignette weight or intensity of the vignette effect.
  30722. */
  30723. vignetteWeight: number;
  30724. /**
  30725. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30726. * if vignetteEnabled is set to true.
  30727. */
  30728. vignetteColor: Color4;
  30729. /**
  30730. * Camera field of view used by the Vignette effect.
  30731. */
  30732. vignetteCameraFov: number;
  30733. private _vignetteBlendMode;
  30734. /**
  30735. * Gets the vignette blend mode allowing different kind of effect.
  30736. */
  30737. /**
  30738. * Sets the vignette blend mode allowing different kind of effect.
  30739. */
  30740. vignetteBlendMode: number;
  30741. private _vignetteEnabled;
  30742. /**
  30743. * Gets wether the vignette effect is enabled.
  30744. */
  30745. /**
  30746. * Sets wether the vignette effect is enabled.
  30747. */
  30748. vignetteEnabled: boolean;
  30749. private _applyByPostProcess;
  30750. /**
  30751. * Gets wether the image processing is applied through a post process or not.
  30752. */
  30753. /**
  30754. * Sets wether the image processing is applied through a post process or not.
  30755. */
  30756. applyByPostProcess: boolean;
  30757. private _isEnabled;
  30758. /**
  30759. * Gets wether the image processing is enabled or not.
  30760. */
  30761. /**
  30762. * Sets wether the image processing is enabled or not.
  30763. */
  30764. isEnabled: boolean;
  30765. /**
  30766. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30767. */
  30768. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30769. /**
  30770. * Method called each time the image processing information changes requires to recompile the effect.
  30771. */
  30772. protected _updateParameters(): void;
  30773. /**
  30774. * Gets the current class name.
  30775. * @return "ImageProcessingConfiguration"
  30776. */
  30777. getClassName(): string;
  30778. /**
  30779. * Prepare the list of uniforms associated with the Image Processing effects.
  30780. * @param uniforms The list of uniforms used in the effect
  30781. * @param defines the list of defines currently in use
  30782. */
  30783. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30784. /**
  30785. * Prepare the list of samplers associated with the Image Processing effects.
  30786. * @param samplersList The list of uniforms used in the effect
  30787. * @param defines the list of defines currently in use
  30788. */
  30789. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30790. /**
  30791. * Prepare the list of defines associated to the shader.
  30792. * @param defines the list of defines to complete
  30793. * @param forPostProcess Define if we are currently in post process mode or not
  30794. */
  30795. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30796. /**
  30797. * Returns true if all the image processing information are ready.
  30798. * @returns True if ready, otherwise, false
  30799. */
  30800. isReady(): boolean;
  30801. /**
  30802. * Binds the image processing to the shader.
  30803. * @param effect The effect to bind to
  30804. * @param aspectRatio Define the current aspect ratio of the effect
  30805. */
  30806. bind(effect: Effect, aspectRatio?: number): void;
  30807. /**
  30808. * Clones the current image processing instance.
  30809. * @return The cloned image processing
  30810. */
  30811. clone(): ImageProcessingConfiguration;
  30812. /**
  30813. * Serializes the current image processing instance to a json representation.
  30814. * @return a JSON representation
  30815. */
  30816. serialize(): any;
  30817. /**
  30818. * Parses the image processing from a json representation.
  30819. * @param source the JSON source to parse
  30820. * @return The parsed image processing
  30821. */
  30822. static Parse(source: any): ImageProcessingConfiguration;
  30823. private static _VIGNETTEMODE_MULTIPLY;
  30824. private static _VIGNETTEMODE_OPAQUE;
  30825. /**
  30826. * Used to apply the vignette as a mix with the pixel color.
  30827. */
  30828. static readonly VIGNETTEMODE_MULTIPLY: number;
  30829. /**
  30830. * Used to apply the vignette as a replacement of the pixel color.
  30831. */
  30832. static readonly VIGNETTEMODE_OPAQUE: number;
  30833. }
  30834. }
  30835. declare module "babylonjs/Materials/fresnelParameters" {
  30836. import { Color3 } from "babylonjs/Maths/math";
  30837. /**
  30838. * This represents all the required information to add a fresnel effect on a material:
  30839. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30840. */
  30841. export class FresnelParameters {
  30842. private _isEnabled;
  30843. /**
  30844. * Define if the fresnel effect is enable or not.
  30845. */
  30846. isEnabled: boolean;
  30847. /**
  30848. * Define the color used on edges (grazing angle)
  30849. */
  30850. leftColor: Color3;
  30851. /**
  30852. * Define the color used on center
  30853. */
  30854. rightColor: Color3;
  30855. /**
  30856. * Define bias applied to computed fresnel term
  30857. */
  30858. bias: number;
  30859. /**
  30860. * Defined the power exponent applied to fresnel term
  30861. */
  30862. power: number;
  30863. /**
  30864. * Clones the current fresnel and its valuues
  30865. * @returns a clone fresnel configuration
  30866. */
  30867. clone(): FresnelParameters;
  30868. /**
  30869. * Serializes the current fresnel parameters to a JSON representation.
  30870. * @return the JSON serialization
  30871. */
  30872. serialize(): any;
  30873. /**
  30874. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30875. * @param parsedFresnelParameters Define the JSON representation
  30876. * @returns the parsed parameters
  30877. */
  30878. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30879. }
  30880. }
  30881. declare module "babylonjs/Misc/decorators" {
  30882. import { Nullable } from "babylonjs/types";
  30883. import { Scene } from "babylonjs/scene";
  30884. import { IAnimatable } from "babylonjs/Misc/tools";
  30885. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30886. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30887. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30888. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30889. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30890. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30891. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30892. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30893. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30894. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30895. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30896. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30897. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30898. /**
  30899. * Decorator used to define property that can be serialized as reference to a camera
  30900. * @param sourceName defines the name of the property to decorate
  30901. */
  30902. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30903. /**
  30904. * Class used to help serialization objects
  30905. */
  30906. export class SerializationHelper {
  30907. /** hidden */
  30908. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30909. /** hidden */
  30910. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30911. /** hidden */
  30912. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30913. /** hidden */
  30914. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30915. /**
  30916. * Appends the serialized animations from the source animations
  30917. * @param source Source containing the animations
  30918. * @param destination Target to store the animations
  30919. */
  30920. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30921. /**
  30922. * Static function used to serialized a specific entity
  30923. * @param entity defines the entity to serialize
  30924. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30925. * @returns a JSON compatible object representing the serialization of the entity
  30926. */
  30927. static Serialize<T>(entity: T, serializationObject?: any): any;
  30928. /**
  30929. * Creates a new entity from a serialization data object
  30930. * @param creationFunction defines a function used to instanciated the new entity
  30931. * @param source defines the source serialization data
  30932. * @param scene defines the hosting scene
  30933. * @param rootUrl defines the root url for resources
  30934. * @returns a new entity
  30935. */
  30936. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30937. /**
  30938. * Clones an object
  30939. * @param creationFunction defines the function used to instanciate the new object
  30940. * @param source defines the source object
  30941. * @returns the cloned object
  30942. */
  30943. static Clone<T>(creationFunction: () => T, source: T): T;
  30944. /**
  30945. * Instanciates a new object based on a source one (some data will be shared between both object)
  30946. * @param creationFunction defines the function used to instanciate the new object
  30947. * @param source defines the source object
  30948. * @returns the new object
  30949. */
  30950. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30951. }
  30952. }
  30953. declare module "babylonjs/Cameras/camera" {
  30954. import { SmartArray } from "babylonjs/Misc/smartArray";
  30955. import { Observable } from "babylonjs/Misc/observable";
  30956. import { Nullable } from "babylonjs/types";
  30957. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30958. import { Scene } from "babylonjs/scene";
  30959. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30960. import { Node } from "babylonjs/node";
  30961. import { Mesh } from "babylonjs/Meshes/mesh";
  30962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30963. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30964. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30966. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30967. import { Ray } from "babylonjs/Culling/ray";
  30968. /**
  30969. * This is the base class of all the camera used in the application.
  30970. * @see http://doc.babylonjs.com/features/cameras
  30971. */
  30972. export class Camera extends Node {
  30973. /** @hidden */
  30974. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30975. /**
  30976. * This is the default projection mode used by the cameras.
  30977. * It helps recreating a feeling of perspective and better appreciate depth.
  30978. * This is the best way to simulate real life cameras.
  30979. */
  30980. static readonly PERSPECTIVE_CAMERA: number;
  30981. /**
  30982. * This helps creating camera with an orthographic mode.
  30983. * 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.
  30984. */
  30985. static readonly ORTHOGRAPHIC_CAMERA: number;
  30986. /**
  30987. * This is the default FOV mode for perspective cameras.
  30988. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30989. */
  30990. static readonly FOVMODE_VERTICAL_FIXED: number;
  30991. /**
  30992. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30993. */
  30994. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30995. /**
  30996. * This specifies ther is no need for a camera rig.
  30997. * Basically only one eye is rendered corresponding to the camera.
  30998. */
  30999. static readonly RIG_MODE_NONE: number;
  31000. /**
  31001. * Simulates a camera Rig with one blue eye and one red eye.
  31002. * This can be use with 3d blue and red glasses.
  31003. */
  31004. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31005. /**
  31006. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31007. */
  31008. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31009. /**
  31010. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31011. */
  31012. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31013. /**
  31014. * Defines that both eyes of the camera will be rendered over under each other.
  31015. */
  31016. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31017. /**
  31018. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31019. */
  31020. static readonly RIG_MODE_VR: number;
  31021. /**
  31022. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31023. */
  31024. static readonly RIG_MODE_WEBVR: number;
  31025. /**
  31026. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31027. */
  31028. static readonly RIG_MODE_CUSTOM: number;
  31029. /**
  31030. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31031. */
  31032. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31033. /**
  31034. * Define the input manager associated with the camera.
  31035. */
  31036. inputs: CameraInputsManager<Camera>;
  31037. /** @hidden */
  31038. _position: Vector3;
  31039. /**
  31040. * Define the current local position of the camera in the scene
  31041. */
  31042. position: Vector3;
  31043. /**
  31044. * The vector the camera should consider as up.
  31045. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31046. */
  31047. upVector: Vector3;
  31048. /**
  31049. * Define the current limit on the left side for an orthographic camera
  31050. * In scene unit
  31051. */
  31052. orthoLeft: Nullable<number>;
  31053. /**
  31054. * Define the current limit on the right side for an orthographic camera
  31055. * In scene unit
  31056. */
  31057. orthoRight: Nullable<number>;
  31058. /**
  31059. * Define the current limit on the bottom side for an orthographic camera
  31060. * In scene unit
  31061. */
  31062. orthoBottom: Nullable<number>;
  31063. /**
  31064. * Define the current limit on the top side for an orthographic camera
  31065. * In scene unit
  31066. */
  31067. orthoTop: Nullable<number>;
  31068. /**
  31069. * Field Of View is set in Radians. (default is 0.8)
  31070. */
  31071. fov: number;
  31072. /**
  31073. * Define the minimum distance the camera can see from.
  31074. * This is important to note that the depth buffer are not infinite and the closer it starts
  31075. * the more your scene might encounter depth fighting issue.
  31076. */
  31077. minZ: number;
  31078. /**
  31079. * Define the maximum distance the camera can see to.
  31080. * This is important to note that the depth buffer are not infinite and the further it end
  31081. * the more your scene might encounter depth fighting issue.
  31082. */
  31083. maxZ: number;
  31084. /**
  31085. * Define the default inertia of the camera.
  31086. * This helps giving a smooth feeling to the camera movement.
  31087. */
  31088. inertia: number;
  31089. /**
  31090. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31091. */
  31092. mode: number;
  31093. /**
  31094. * Define wether the camera is intermediate.
  31095. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31096. */
  31097. isIntermediate: boolean;
  31098. /**
  31099. * Define the viewport of the camera.
  31100. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31101. */
  31102. viewport: Viewport;
  31103. /**
  31104. * Restricts the camera to viewing objects with the same layerMask.
  31105. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31106. */
  31107. layerMask: number;
  31108. /**
  31109. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31110. */
  31111. fovMode: number;
  31112. /**
  31113. * Rig mode of the camera.
  31114. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31115. * This is normally controlled byt the camera themselves as internal use.
  31116. */
  31117. cameraRigMode: number;
  31118. /**
  31119. * Defines the distance between both "eyes" in case of a RIG
  31120. */
  31121. interaxialDistance: number;
  31122. /**
  31123. * Defines if stereoscopic rendering is done side by side or over under.
  31124. */
  31125. isStereoscopicSideBySide: boolean;
  31126. /**
  31127. * 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
  31128. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31129. * else in the scene.
  31130. */
  31131. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31132. /**
  31133. * When set, the camera will render to this render target instead of the default canvas
  31134. */
  31135. outputRenderTarget: Nullable<RenderTargetTexture>;
  31136. /**
  31137. * Observable triggered when the camera view matrix has changed.
  31138. */
  31139. onViewMatrixChangedObservable: Observable<Camera>;
  31140. /**
  31141. * Observable triggered when the camera Projection matrix has changed.
  31142. */
  31143. onProjectionMatrixChangedObservable: Observable<Camera>;
  31144. /**
  31145. * Observable triggered when the inputs have been processed.
  31146. */
  31147. onAfterCheckInputsObservable: Observable<Camera>;
  31148. /**
  31149. * Observable triggered when reset has been called and applied to the camera.
  31150. */
  31151. onRestoreStateObservable: Observable<Camera>;
  31152. /** @hidden */
  31153. _cameraRigParams: any;
  31154. /** @hidden */
  31155. _rigCameras: Camera[];
  31156. /** @hidden */
  31157. _rigPostProcess: Nullable<PostProcess>;
  31158. protected _webvrViewMatrix: Matrix;
  31159. /** @hidden */
  31160. _skipRendering: boolean;
  31161. /** @hidden */
  31162. _projectionMatrix: Matrix;
  31163. /** @hidden */
  31164. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31165. /** @hidden */
  31166. _activeMeshes: SmartArray<AbstractMesh>;
  31167. protected _globalPosition: Vector3;
  31168. /** hidden */
  31169. _computedViewMatrix: Matrix;
  31170. private _doNotComputeProjectionMatrix;
  31171. private _transformMatrix;
  31172. private _frustumPlanes;
  31173. private _refreshFrustumPlanes;
  31174. private _storedFov;
  31175. private _stateStored;
  31176. /**
  31177. * Instantiates a new camera object.
  31178. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31179. * @see http://doc.babylonjs.com/features/cameras
  31180. * @param name Defines the name of the camera in the scene
  31181. * @param position Defines the position of the camera
  31182. * @param scene Defines the scene the camera belongs too
  31183. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31184. */
  31185. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31186. /**
  31187. * Store current camera state (fov, position, etc..)
  31188. * @returns the camera
  31189. */
  31190. storeState(): Camera;
  31191. /**
  31192. * Restores the camera state values if it has been stored. You must call storeState() first
  31193. */
  31194. protected _restoreStateValues(): boolean;
  31195. /**
  31196. * Restored camera state. You must call storeState() first.
  31197. * @returns true if restored and false otherwise
  31198. */
  31199. restoreState(): boolean;
  31200. /**
  31201. * Gets the class name of the camera.
  31202. * @returns the class name
  31203. */
  31204. getClassName(): string;
  31205. /** @hidden */
  31206. readonly _isCamera: boolean;
  31207. /**
  31208. * Gets a string representation of the camera useful for debug purpose.
  31209. * @param fullDetails Defines that a more verboe level of logging is required
  31210. * @returns the string representation
  31211. */
  31212. toString(fullDetails?: boolean): string;
  31213. /**
  31214. * Gets the current world space position of the camera.
  31215. */
  31216. readonly globalPosition: Vector3;
  31217. /**
  31218. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31219. * @returns the active meshe list
  31220. */
  31221. getActiveMeshes(): SmartArray<AbstractMesh>;
  31222. /**
  31223. * Check wether a mesh is part of the current active mesh list of the camera
  31224. * @param mesh Defines the mesh to check
  31225. * @returns true if active, false otherwise
  31226. */
  31227. isActiveMesh(mesh: Mesh): boolean;
  31228. /**
  31229. * Is this camera ready to be used/rendered
  31230. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31231. * @return true if the camera is ready
  31232. */
  31233. isReady(completeCheck?: boolean): boolean;
  31234. /** @hidden */
  31235. _initCache(): void;
  31236. /** @hidden */
  31237. _updateCache(ignoreParentClass?: boolean): void;
  31238. /** @hidden */
  31239. _isSynchronized(): boolean;
  31240. /** @hidden */
  31241. _isSynchronizedViewMatrix(): boolean;
  31242. /** @hidden */
  31243. _isSynchronizedProjectionMatrix(): boolean;
  31244. /**
  31245. * Attach the input controls to a specific dom element to get the input from.
  31246. * @param element Defines the element the controls should be listened from
  31247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31248. */
  31249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31250. /**
  31251. * Detach the current controls from the specified dom element.
  31252. * @param element Defines the element to stop listening the inputs from
  31253. */
  31254. detachControl(element: HTMLElement): void;
  31255. /**
  31256. * Update the camera state according to the different inputs gathered during the frame.
  31257. */
  31258. update(): void;
  31259. /** @hidden */
  31260. _checkInputs(): void;
  31261. /** @hidden */
  31262. readonly rigCameras: Camera[];
  31263. /**
  31264. * Gets the post process used by the rig cameras
  31265. */
  31266. readonly rigPostProcess: Nullable<PostProcess>;
  31267. /**
  31268. * Internal, gets the first post proces.
  31269. * @returns the first post process to be run on this camera.
  31270. */
  31271. _getFirstPostProcess(): Nullable<PostProcess>;
  31272. private _cascadePostProcessesToRigCams;
  31273. /**
  31274. * Attach a post process to the camera.
  31275. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31276. * @param postProcess The post process to attach to the camera
  31277. * @param insertAt The position of the post process in case several of them are in use in the scene
  31278. * @returns the position the post process has been inserted at
  31279. */
  31280. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31281. /**
  31282. * Detach a post process to the camera.
  31283. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31284. * @param postProcess The post process to detach from the camera
  31285. */
  31286. detachPostProcess(postProcess: PostProcess): void;
  31287. /**
  31288. * Gets the current world matrix of the camera
  31289. */
  31290. getWorldMatrix(): Matrix;
  31291. /** @hidden */
  31292. _getViewMatrix(): Matrix;
  31293. /**
  31294. * Gets the current view matrix of the camera.
  31295. * @param force forces the camera to recompute the matrix without looking at the cached state
  31296. * @returns the view matrix
  31297. */
  31298. getViewMatrix(force?: boolean): Matrix;
  31299. /**
  31300. * Freeze the projection matrix.
  31301. * It will prevent the cache check of the camera projection compute and can speed up perf
  31302. * if no parameter of the camera are meant to change
  31303. * @param projection Defines manually a projection if necessary
  31304. */
  31305. freezeProjectionMatrix(projection?: Matrix): void;
  31306. /**
  31307. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31308. */
  31309. unfreezeProjectionMatrix(): void;
  31310. /**
  31311. * Gets the current projection matrix of the camera.
  31312. * @param force forces the camera to recompute the matrix without looking at the cached state
  31313. * @returns the projection matrix
  31314. */
  31315. getProjectionMatrix(force?: boolean): Matrix;
  31316. /**
  31317. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31318. * @returns a Matrix
  31319. */
  31320. getTransformationMatrix(): Matrix;
  31321. private _updateFrustumPlanes;
  31322. /**
  31323. * Checks if a cullable object (mesh...) is in the camera frustum
  31324. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31325. * @param target The object to check
  31326. * @returns true if the object is in frustum otherwise false
  31327. */
  31328. isInFrustum(target: ICullable): boolean;
  31329. /**
  31330. * Checks if a cullable object (mesh...) is in the camera frustum
  31331. * Unlike isInFrustum this cheks the full bounding box
  31332. * @param target The object to check
  31333. * @returns true if the object is in frustum otherwise false
  31334. */
  31335. isCompletelyInFrustum(target: ICullable): boolean;
  31336. /**
  31337. * Gets a ray in the forward direction from the camera.
  31338. * @param length Defines the length of the ray to create
  31339. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31340. * @param origin Defines the start point of the ray which defaults to the camera position
  31341. * @returns the forward ray
  31342. */
  31343. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31344. /**
  31345. * Releases resources associated with this node.
  31346. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31347. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31348. */
  31349. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31350. /** @hidden */
  31351. _isLeftCamera: boolean;
  31352. /**
  31353. * Gets the left camera of a rig setup in case of Rigged Camera
  31354. */
  31355. readonly isLeftCamera: boolean;
  31356. /** @hidden */
  31357. _isRightCamera: boolean;
  31358. /**
  31359. * Gets the right camera of a rig setup in case of Rigged Camera
  31360. */
  31361. readonly isRightCamera: boolean;
  31362. /**
  31363. * Gets the left camera of a rig setup in case of Rigged Camera
  31364. */
  31365. readonly leftCamera: Nullable<FreeCamera>;
  31366. /**
  31367. * Gets the right camera of a rig setup in case of Rigged Camera
  31368. */
  31369. readonly rightCamera: Nullable<FreeCamera>;
  31370. /**
  31371. * Gets the left camera target of a rig setup in case of Rigged Camera
  31372. * @returns the target position
  31373. */
  31374. getLeftTarget(): Nullable<Vector3>;
  31375. /**
  31376. * Gets the right camera target of a rig setup in case of Rigged Camera
  31377. * @returns the target position
  31378. */
  31379. getRightTarget(): Nullable<Vector3>;
  31380. /**
  31381. * @hidden
  31382. */
  31383. setCameraRigMode(mode: number, rigParams: any): void;
  31384. /** @hidden */
  31385. static _setStereoscopicRigMode(camera: Camera): void;
  31386. /** @hidden */
  31387. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31388. /** @hidden */
  31389. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31390. /** @hidden */
  31391. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31392. /** @hidden */
  31393. _getVRProjectionMatrix(): Matrix;
  31394. protected _updateCameraRotationMatrix(): void;
  31395. protected _updateWebVRCameraRotationMatrix(): void;
  31396. /**
  31397. * This function MUST be overwritten by the different WebVR cameras available.
  31398. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31399. * @hidden
  31400. */
  31401. _getWebVRProjectionMatrix(): Matrix;
  31402. /**
  31403. * This function MUST be overwritten by the different WebVR cameras available.
  31404. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31405. * @hidden
  31406. */
  31407. _getWebVRViewMatrix(): Matrix;
  31408. /** @hidden */
  31409. setCameraRigParameter(name: string, value: any): void;
  31410. /**
  31411. * needs to be overridden by children so sub has required properties to be copied
  31412. * @hidden
  31413. */
  31414. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31415. /**
  31416. * May need to be overridden by children
  31417. * @hidden
  31418. */
  31419. _updateRigCameras(): void;
  31420. /** @hidden */
  31421. _setupInputs(): void;
  31422. /**
  31423. * Serialiaze the camera setup to a json represention
  31424. * @returns the JSON representation
  31425. */
  31426. serialize(): any;
  31427. /**
  31428. * Clones the current camera.
  31429. * @param name The cloned camera name
  31430. * @returns the cloned camera
  31431. */
  31432. clone(name: string): Camera;
  31433. /**
  31434. * Gets the direction of the camera relative to a given local axis.
  31435. * @param localAxis Defines the reference axis to provide a relative direction.
  31436. * @return the direction
  31437. */
  31438. getDirection(localAxis: Vector3): Vector3;
  31439. /**
  31440. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31441. * @param localAxis Defines the reference axis to provide a relative direction.
  31442. * @param result Defines the vector to store the result in
  31443. */
  31444. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31445. /**
  31446. * Gets a camera constructor for a given camera type
  31447. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31448. * @param name The name of the camera the result will be able to instantiate
  31449. * @param scene The scene the result will construct the camera in
  31450. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31451. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31452. * @returns a factory method to construc the camera
  31453. */
  31454. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31455. /**
  31456. * Compute the world matrix of the camera.
  31457. * @returns the camera workd matrix
  31458. */
  31459. computeWorldMatrix(): Matrix;
  31460. /**
  31461. * Parse a JSON and creates the camera from the parsed information
  31462. * @param parsedCamera The JSON to parse
  31463. * @param scene The scene to instantiate the camera in
  31464. * @returns the newly constructed camera
  31465. */
  31466. static Parse(parsedCamera: any, scene: Scene): Camera;
  31467. }
  31468. }
  31469. declare module "babylonjs/Misc/tools" {
  31470. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31471. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31472. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31473. import { Observable } from "babylonjs/Misc/observable";
  31474. import { DomManagement } from "babylonjs/Misc/domManagement";
  31475. import { WebRequest } from "babylonjs/Misc/webRequest";
  31476. import { Camera } from "babylonjs/Cameras/camera";
  31477. import { Engine } from "babylonjs/Engines/engine";
  31478. import { Animation } from "babylonjs/Animations/animation";
  31479. /**
  31480. * Interface for any object that can request an animation frame
  31481. */
  31482. export interface ICustomAnimationFrameRequester {
  31483. /**
  31484. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31485. */
  31486. renderFunction?: Function;
  31487. /**
  31488. * Called to request the next frame to render to
  31489. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31490. */
  31491. requestAnimationFrame: Function;
  31492. /**
  31493. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31494. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31495. */
  31496. requestID?: number;
  31497. }
  31498. /**
  31499. * Interface containing an array of animations
  31500. */
  31501. export interface IAnimatable {
  31502. /**
  31503. * Array of animations
  31504. */
  31505. animations: Nullable<Array<Animation>>;
  31506. }
  31507. /** Interface used by value gradients (color, factor, ...) */
  31508. export interface IValueGradient {
  31509. /**
  31510. * Gets or sets the gradient value (between 0 and 1)
  31511. */
  31512. gradient: number;
  31513. }
  31514. /** Class used to store color4 gradient */
  31515. export class ColorGradient implements IValueGradient {
  31516. /**
  31517. * Gets or sets the gradient value (between 0 and 1)
  31518. */
  31519. gradient: number;
  31520. /**
  31521. * Gets or sets first associated color
  31522. */
  31523. color1: Color4;
  31524. /**
  31525. * Gets or sets second associated color
  31526. */
  31527. color2?: Color4;
  31528. /**
  31529. * Will get a color picked randomly between color1 and color2.
  31530. * If color2 is undefined then color1 will be used
  31531. * @param result defines the target Color4 to store the result in
  31532. */
  31533. getColorToRef(result: Color4): void;
  31534. }
  31535. /** Class used to store color 3 gradient */
  31536. export class Color3Gradient implements IValueGradient {
  31537. /**
  31538. * Gets or sets the gradient value (between 0 and 1)
  31539. */
  31540. gradient: number;
  31541. /**
  31542. * Gets or sets the associated color
  31543. */
  31544. color: Color3;
  31545. }
  31546. /** Class used to store factor gradient */
  31547. export class FactorGradient implements IValueGradient {
  31548. /**
  31549. * Gets or sets the gradient value (between 0 and 1)
  31550. */
  31551. gradient: number;
  31552. /**
  31553. * Gets or sets first associated factor
  31554. */
  31555. factor1: number;
  31556. /**
  31557. * Gets or sets second associated factor
  31558. */
  31559. factor2?: number;
  31560. /**
  31561. * Will get a number picked randomly between factor1 and factor2.
  31562. * If factor2 is undefined then factor1 will be used
  31563. * @returns the picked number
  31564. */
  31565. getFactor(): number;
  31566. }
  31567. /**
  31568. * @ignore
  31569. * Application error to support additional information when loading a file
  31570. */
  31571. export class LoadFileError extends Error {
  31572. /** defines the optional web request */
  31573. request?: WebRequest | undefined;
  31574. private static _setPrototypeOf;
  31575. /**
  31576. * Creates a new LoadFileError
  31577. * @param message defines the message of the error
  31578. * @param request defines the optional web request
  31579. */
  31580. constructor(message: string,
  31581. /** defines the optional web request */
  31582. request?: WebRequest | undefined);
  31583. }
  31584. /**
  31585. * Class used to define a retry strategy when error happens while loading assets
  31586. */
  31587. export class RetryStrategy {
  31588. /**
  31589. * Function used to defines an exponential back off strategy
  31590. * @param maxRetries defines the maximum number of retries (3 by default)
  31591. * @param baseInterval defines the interval between retries
  31592. * @returns the strategy function to use
  31593. */
  31594. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31595. }
  31596. /**
  31597. * File request interface
  31598. */
  31599. export interface IFileRequest {
  31600. /**
  31601. * Raised when the request is complete (success or error).
  31602. */
  31603. onCompleteObservable: Observable<IFileRequest>;
  31604. /**
  31605. * Aborts the request for a file.
  31606. */
  31607. abort: () => void;
  31608. }
  31609. /**
  31610. * Class containing a set of static utilities functions
  31611. */
  31612. export class Tools {
  31613. /**
  31614. * Gets or sets the base URL to use to load assets
  31615. */
  31616. static BaseUrl: string;
  31617. /**
  31618. * Enable/Disable Custom HTTP Request Headers globally.
  31619. * default = false
  31620. * @see CustomRequestHeaders
  31621. */
  31622. static UseCustomRequestHeaders: boolean;
  31623. /**
  31624. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31625. * i.e. when loading files, where the server/service expects an Authorization header
  31626. */
  31627. static CustomRequestHeaders: {
  31628. [key: string]: string;
  31629. };
  31630. /**
  31631. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31632. */
  31633. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31634. /**
  31635. * Default behaviour for cors in the application.
  31636. * It can be a string if the expected behavior is identical in the entire app.
  31637. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31638. */
  31639. static CorsBehavior: string | ((url: string | string[]) => string);
  31640. /**
  31641. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31642. * @ignorenaming
  31643. */
  31644. static UseFallbackTexture: boolean;
  31645. /**
  31646. * Use this object to register external classes like custom textures or material
  31647. * to allow the laoders to instantiate them
  31648. */
  31649. static RegisteredExternalClasses: {
  31650. [key: string]: Object;
  31651. };
  31652. /**
  31653. * Texture content used if a texture cannot loaded
  31654. * @ignorenaming
  31655. */
  31656. static fallbackTexture: string;
  31657. /**
  31658. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31659. * @param u defines the coordinate on X axis
  31660. * @param v defines the coordinate on Y axis
  31661. * @param width defines the width of the source data
  31662. * @param height defines the height of the source data
  31663. * @param pixels defines the source byte array
  31664. * @param color defines the output color
  31665. */
  31666. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31667. /**
  31668. * Interpolates between a and b via alpha
  31669. * @param a The lower value (returned when alpha = 0)
  31670. * @param b The upper value (returned when alpha = 1)
  31671. * @param alpha The interpolation-factor
  31672. * @return The mixed value
  31673. */
  31674. static Mix(a: number, b: number, alpha: number): number;
  31675. /**
  31676. * Tries to instantiate a new object from a given class name
  31677. * @param className defines the class name to instantiate
  31678. * @returns the new object or null if the system was not able to do the instantiation
  31679. */
  31680. static Instantiate(className: string): any;
  31681. /**
  31682. * Provides a slice function that will work even on IE
  31683. * @param data defines the array to slice
  31684. * @param start defines the start of the data (optional)
  31685. * @param end defines the end of the data (optional)
  31686. * @returns the new sliced array
  31687. */
  31688. static Slice<T>(data: T, start?: number, end?: number): T;
  31689. /**
  31690. * Polyfill for setImmediate
  31691. * @param action defines the action to execute after the current execution block
  31692. */
  31693. static SetImmediate(action: () => void): void;
  31694. /**
  31695. * Function indicating if a number is an exponent of 2
  31696. * @param value defines the value to test
  31697. * @returns true if the value is an exponent of 2
  31698. */
  31699. static IsExponentOfTwo(value: number): boolean;
  31700. private static _tmpFloatArray;
  31701. /**
  31702. * Returns the nearest 32-bit single precision float representation of a Number
  31703. * @param value A Number. If the parameter is of a different type, it will get converted
  31704. * to a number or to NaN if it cannot be converted
  31705. * @returns number
  31706. */
  31707. static FloatRound(value: number): number;
  31708. /**
  31709. * Find the next highest power of two.
  31710. * @param x Number to start search from.
  31711. * @return Next highest power of two.
  31712. */
  31713. static CeilingPOT(x: number): number;
  31714. /**
  31715. * Find the next lowest power of two.
  31716. * @param x Number to start search from.
  31717. * @return Next lowest power of two.
  31718. */
  31719. static FloorPOT(x: number): number;
  31720. /**
  31721. * Find the nearest power of two.
  31722. * @param x Number to start search from.
  31723. * @return Next nearest power of two.
  31724. */
  31725. static NearestPOT(x: number): number;
  31726. /**
  31727. * Get the closest exponent of two
  31728. * @param value defines the value to approximate
  31729. * @param max defines the maximum value to return
  31730. * @param mode defines how to define the closest value
  31731. * @returns closest exponent of two of the given value
  31732. */
  31733. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31734. /**
  31735. * Extracts the filename from a path
  31736. * @param path defines the path to use
  31737. * @returns the filename
  31738. */
  31739. static GetFilename(path: string): string;
  31740. /**
  31741. * Extracts the "folder" part of a path (everything before the filename).
  31742. * @param uri The URI to extract the info from
  31743. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31744. * @returns The "folder" part of the path
  31745. */
  31746. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31747. /**
  31748. * Extracts text content from a DOM element hierarchy
  31749. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31750. */
  31751. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31752. /**
  31753. * Convert an angle in radians to degrees
  31754. * @param angle defines the angle to convert
  31755. * @returns the angle in degrees
  31756. */
  31757. static ToDegrees(angle: number): number;
  31758. /**
  31759. * Convert an angle in degrees to radians
  31760. * @param angle defines the angle to convert
  31761. * @returns the angle in radians
  31762. */
  31763. static ToRadians(angle: number): number;
  31764. /**
  31765. * Encode a buffer to a base64 string
  31766. * @param buffer defines the buffer to encode
  31767. * @returns the encoded string
  31768. */
  31769. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31770. /**
  31771. * Extracts minimum and maximum values from a list of indexed positions
  31772. * @param positions defines the positions to use
  31773. * @param indices defines the indices to the positions
  31774. * @param indexStart defines the start index
  31775. * @param indexCount defines the end index
  31776. * @param bias defines bias value to add to the result
  31777. * @return minimum and maximum values
  31778. */
  31779. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31780. minimum: Vector3;
  31781. maximum: Vector3;
  31782. };
  31783. /**
  31784. * Extracts minimum and maximum values from a list of positions
  31785. * @param positions defines the positions to use
  31786. * @param start defines the start index in the positions array
  31787. * @param count defines the number of positions to handle
  31788. * @param bias defines bias value to add to the result
  31789. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31790. * @return minimum and maximum values
  31791. */
  31792. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31793. minimum: Vector3;
  31794. maximum: Vector3;
  31795. };
  31796. /**
  31797. * Returns an array if obj is not an array
  31798. * @param obj defines the object to evaluate as an array
  31799. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31800. * @returns either obj directly if obj is an array or a new array containing obj
  31801. */
  31802. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31803. /**
  31804. * Gets the pointer prefix to use
  31805. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31806. */
  31807. static GetPointerPrefix(): string;
  31808. /**
  31809. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31810. * @param func - the function to be called
  31811. * @param requester - the object that will request the next frame. Falls back to window.
  31812. * @returns frame number
  31813. */
  31814. static QueueNewFrame(func: () => void, requester?: any): number;
  31815. /**
  31816. * Ask the browser to promote the current element to fullscreen rendering mode
  31817. * @param element defines the DOM element to promote
  31818. */
  31819. static RequestFullscreen(element: HTMLElement): void;
  31820. /**
  31821. * Asks the browser to exit fullscreen mode
  31822. */
  31823. static ExitFullscreen(): void;
  31824. /**
  31825. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31826. * @param url define the url we are trying
  31827. * @param element define the dom element where to configure the cors policy
  31828. */
  31829. static SetCorsBehavior(url: string | string[], element: {
  31830. crossOrigin: string | null;
  31831. }): void;
  31832. /**
  31833. * Removes unwanted characters from an url
  31834. * @param url defines the url to clean
  31835. * @returns the cleaned url
  31836. */
  31837. static CleanUrl(url: string): string;
  31838. /**
  31839. * Gets or sets a function used to pre-process url before using them to load assets
  31840. */
  31841. static PreprocessUrl: (url: string) => string;
  31842. /**
  31843. * Loads an image as an HTMLImageElement.
  31844. * @param input url string, ArrayBuffer, or Blob to load
  31845. * @param onLoad callback called when the image successfully loads
  31846. * @param onError callback called when the image fails to load
  31847. * @param offlineProvider offline provider for caching
  31848. * @returns the HTMLImageElement of the loaded image
  31849. */
  31850. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31851. /**
  31852. * Loads a file
  31853. * @param url url string, ArrayBuffer, or Blob to load
  31854. * @param onSuccess callback called when the file successfully loads
  31855. * @param onProgress callback called while file is loading (if the server supports this mode)
  31856. * @param offlineProvider defines the offline provider for caching
  31857. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31858. * @param onError callback called when the file fails to load
  31859. * @returns a file request object
  31860. */
  31861. 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;
  31862. /**
  31863. * Load a script (identified by an url). When the url returns, the
  31864. * content of this file is added into a new script element, attached to the DOM (body element)
  31865. * @param scriptUrl defines the url of the script to laod
  31866. * @param onSuccess defines the callback called when the script is loaded
  31867. * @param onError defines the callback to call if an error occurs
  31868. * @param scriptId defines the id of the script element
  31869. */
  31870. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31871. /**
  31872. * Load an asynchronous script (identified by an url). When the url returns, the
  31873. * content of this file is added into a new script element, attached to the DOM (body element)
  31874. * @param scriptUrl defines the url of the script to laod
  31875. * @param scriptId defines the id of the script element
  31876. * @returns a promise request object
  31877. */
  31878. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31879. /**
  31880. * Loads a file from a blob
  31881. * @param fileToLoad defines the blob to use
  31882. * @param callback defines the callback to call when data is loaded
  31883. * @param progressCallback defines the callback to call during loading process
  31884. * @returns a file request object
  31885. */
  31886. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31887. /**
  31888. * Loads a file
  31889. * @param fileToLoad defines the file to load
  31890. * @param callback defines the callback to call when data is loaded
  31891. * @param progressCallBack defines the callback to call during loading process
  31892. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31893. * @returns a file request object
  31894. */
  31895. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31896. /**
  31897. * Creates a data url from a given string content
  31898. * @param content defines the content to convert
  31899. * @returns the new data url link
  31900. */
  31901. static FileAsURL(content: string): string;
  31902. /**
  31903. * Format the given number to a specific decimal format
  31904. * @param value defines the number to format
  31905. * @param decimals defines the number of decimals to use
  31906. * @returns the formatted string
  31907. */
  31908. static Format(value: number, decimals?: number): string;
  31909. /**
  31910. * Checks if a given vector is inside a specific range
  31911. * @param v defines the vector to test
  31912. * @param min defines the minimum range
  31913. * @param max defines the maximum range
  31914. */
  31915. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31916. /**
  31917. * Tries to copy an object by duplicating every property
  31918. * @param source defines the source object
  31919. * @param destination defines the target object
  31920. * @param doNotCopyList defines a list of properties to avoid
  31921. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31922. */
  31923. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31924. /**
  31925. * Gets a boolean indicating if the given object has no own property
  31926. * @param obj defines the object to test
  31927. * @returns true if object has no own property
  31928. */
  31929. static IsEmpty(obj: any): boolean;
  31930. /**
  31931. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31932. * @param str Source string
  31933. * @param suffix Suffix to search for in the source string
  31934. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31935. */
  31936. static EndsWith(str: string, suffix: string): boolean;
  31937. /**
  31938. * Function used to register events at window level
  31939. * @param events defines the events to register
  31940. */
  31941. static RegisterTopRootEvents(events: {
  31942. name: string;
  31943. handler: Nullable<(e: FocusEvent) => any>;
  31944. }[]): void;
  31945. /**
  31946. * Function used to unregister events from window level
  31947. * @param events defines the events to unregister
  31948. */
  31949. static UnregisterTopRootEvents(events: {
  31950. name: string;
  31951. handler: Nullable<(e: FocusEvent) => any>;
  31952. }[]): void;
  31953. /**
  31954. * @ignore
  31955. */
  31956. static _ScreenshotCanvas: HTMLCanvasElement;
  31957. /**
  31958. * Dumps the current bound framebuffer
  31959. * @param width defines the rendering width
  31960. * @param height defines the rendering height
  31961. * @param engine defines the hosting engine
  31962. * @param successCallback defines the callback triggered once the data are available
  31963. * @param mimeType defines the mime type of the result
  31964. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31965. */
  31966. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31967. /**
  31968. * Converts the canvas data to blob.
  31969. * This acts as a polyfill for browsers not supporting the to blob function.
  31970. * @param canvas Defines the canvas to extract the data from
  31971. * @param successCallback Defines the callback triggered once the data are available
  31972. * @param mimeType Defines the mime type of the result
  31973. */
  31974. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31975. /**
  31976. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31977. * @param successCallback defines the callback triggered once the data are available
  31978. * @param mimeType defines the mime type of the result
  31979. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31980. */
  31981. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31982. /**
  31983. * Downloads a blob in the browser
  31984. * @param blob defines the blob to download
  31985. * @param fileName defines the name of the downloaded file
  31986. */
  31987. static Download(blob: Blob, fileName: string): void;
  31988. /**
  31989. * Captures a screenshot of the current rendering
  31990. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31991. * @param engine defines the rendering engine
  31992. * @param camera defines the source camera
  31993. * @param size This parameter can be set to a single number or to an object with the
  31994. * following (optional) properties: precision, width, height. If a single number is passed,
  31995. * it will be used for both width and height. If an object is passed, the screenshot size
  31996. * will be derived from the parameters. The precision property is a multiplier allowing
  31997. * rendering at a higher or lower resolution
  31998. * @param successCallback defines the callback receives a single parameter which contains the
  31999. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32000. * src parameter of an <img> to display it
  32001. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32002. * Check your browser for supported MIME types
  32003. */
  32004. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32005. /**
  32006. * Generates an image screenshot from the specified camera.
  32007. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32008. * @param engine The engine to use for rendering
  32009. * @param camera The camera to use for rendering
  32010. * @param size This parameter can be set to a single number or to an object with the
  32011. * following (optional) properties: precision, width, height. If a single number is passed,
  32012. * it will be used for both width and height. If an object is passed, the screenshot size
  32013. * will be derived from the parameters. The precision property is a multiplier allowing
  32014. * rendering at a higher or lower resolution
  32015. * @param successCallback The callback receives a single parameter which contains the
  32016. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32017. * src parameter of an <img> to display it
  32018. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32019. * Check your browser for supported MIME types
  32020. * @param samples Texture samples (default: 1)
  32021. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32022. * @param fileName A name for for the downloaded file.
  32023. */
  32024. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32025. /**
  32026. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32027. * Be aware Math.random() could cause collisions, but:
  32028. * "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"
  32029. * @returns a pseudo random id
  32030. */
  32031. static RandomId(): string;
  32032. /**
  32033. * Test if the given uri is a base64 string
  32034. * @param uri The uri to test
  32035. * @return True if the uri is a base64 string or false otherwise
  32036. */
  32037. static IsBase64(uri: string): boolean;
  32038. /**
  32039. * Decode the given base64 uri.
  32040. * @param uri The uri to decode
  32041. * @return The decoded base64 data.
  32042. */
  32043. static DecodeBase64(uri: string): ArrayBuffer;
  32044. /**
  32045. * Gets the absolute url.
  32046. * @param url the input url
  32047. * @return the absolute url
  32048. */
  32049. static GetAbsoluteUrl(url: string): string;
  32050. /**
  32051. * No log
  32052. */
  32053. static readonly NoneLogLevel: number;
  32054. /**
  32055. * Only message logs
  32056. */
  32057. static readonly MessageLogLevel: number;
  32058. /**
  32059. * Only warning logs
  32060. */
  32061. static readonly WarningLogLevel: number;
  32062. /**
  32063. * Only error logs
  32064. */
  32065. static readonly ErrorLogLevel: number;
  32066. /**
  32067. * All logs
  32068. */
  32069. static readonly AllLogLevel: number;
  32070. /**
  32071. * Gets a value indicating the number of loading errors
  32072. * @ignorenaming
  32073. */
  32074. static readonly errorsCount: number;
  32075. /**
  32076. * Callback called when a new log is added
  32077. */
  32078. static OnNewCacheEntry: (entry: string) => void;
  32079. /**
  32080. * Log a message to the console
  32081. * @param message defines the message to log
  32082. */
  32083. static Log(message: string): void;
  32084. /**
  32085. * Write a warning message to the console
  32086. * @param message defines the message to log
  32087. */
  32088. static Warn(message: string): void;
  32089. /**
  32090. * Write an error message to the console
  32091. * @param message defines the message to log
  32092. */
  32093. static Error(message: string): void;
  32094. /**
  32095. * Gets current log cache (list of logs)
  32096. */
  32097. static readonly LogCache: string;
  32098. /**
  32099. * Clears the log cache
  32100. */
  32101. static ClearLogCache(): void;
  32102. /**
  32103. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32104. */
  32105. static LogLevels: number;
  32106. /**
  32107. * Checks if the loaded document was accessed via `file:`-Protocol.
  32108. * @returns boolean
  32109. */
  32110. static IsFileURL(): boolean;
  32111. /**
  32112. * Checks if the window object exists
  32113. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32114. */
  32115. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32116. /**
  32117. * No performance log
  32118. */
  32119. static readonly PerformanceNoneLogLevel: number;
  32120. /**
  32121. * Use user marks to log performance
  32122. */
  32123. static readonly PerformanceUserMarkLogLevel: number;
  32124. /**
  32125. * Log performance to the console
  32126. */
  32127. static readonly PerformanceConsoleLogLevel: number;
  32128. private static _performance;
  32129. /**
  32130. * Sets the current performance log level
  32131. */
  32132. static PerformanceLogLevel: number;
  32133. private static _StartPerformanceCounterDisabled;
  32134. private static _EndPerformanceCounterDisabled;
  32135. private static _StartUserMark;
  32136. private static _EndUserMark;
  32137. private static _StartPerformanceConsole;
  32138. private static _EndPerformanceConsole;
  32139. /**
  32140. * Starts a performance counter
  32141. */
  32142. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32143. /**
  32144. * Ends a specific performance coutner
  32145. */
  32146. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32147. /**
  32148. * Gets either window.performance.now() if supported or Date.now() else
  32149. */
  32150. static readonly Now: number;
  32151. /**
  32152. * This method will return the name of the class used to create the instance of the given object.
  32153. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32154. * @param object the object to get the class name from
  32155. * @param isType defines if the object is actually a type
  32156. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32157. */
  32158. static GetClassName(object: any, isType?: boolean): string;
  32159. /**
  32160. * Gets the first element of an array satisfying a given predicate
  32161. * @param array defines the array to browse
  32162. * @param predicate defines the predicate to use
  32163. * @returns null if not found or the element
  32164. */
  32165. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32166. /**
  32167. * This method will return the name of the full name of the class, including its owning module (if any).
  32168. * 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).
  32169. * @param object the object to get the class name from
  32170. * @param isType defines if the object is actually a type
  32171. * @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.
  32172. * @ignorenaming
  32173. */
  32174. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32175. /**
  32176. * Returns a promise that resolves after the given amount of time.
  32177. * @param delay Number of milliseconds to delay
  32178. * @returns Promise that resolves after the given amount of time
  32179. */
  32180. static DelayAsync(delay: number): Promise<void>;
  32181. /**
  32182. * Gets the current gradient from an array of IValueGradient
  32183. * @param ratio defines the current ratio to get
  32184. * @param gradients defines the array of IValueGradient
  32185. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32186. */
  32187. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32188. }
  32189. /**
  32190. * This class is used to track a performance counter which is number based.
  32191. * The user has access to many properties which give statistics of different nature.
  32192. *
  32193. * The implementer can track two kinds of Performance Counter: time and count.
  32194. * 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.
  32195. * 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.
  32196. */
  32197. export class PerfCounter {
  32198. /**
  32199. * Gets or sets a global boolean to turn on and off all the counters
  32200. */
  32201. static Enabled: boolean;
  32202. /**
  32203. * Returns the smallest value ever
  32204. */
  32205. readonly min: number;
  32206. /**
  32207. * Returns the biggest value ever
  32208. */
  32209. readonly max: number;
  32210. /**
  32211. * Returns the average value since the performance counter is running
  32212. */
  32213. readonly average: number;
  32214. /**
  32215. * Returns the average value of the last second the counter was monitored
  32216. */
  32217. readonly lastSecAverage: number;
  32218. /**
  32219. * Returns the current value
  32220. */
  32221. readonly current: number;
  32222. /**
  32223. * Gets the accumulated total
  32224. */
  32225. readonly total: number;
  32226. /**
  32227. * Gets the total value count
  32228. */
  32229. readonly count: number;
  32230. /**
  32231. * Creates a new counter
  32232. */
  32233. constructor();
  32234. /**
  32235. * Call this method to start monitoring a new frame.
  32236. * 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.
  32237. */
  32238. fetchNewFrame(): void;
  32239. /**
  32240. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32241. * @param newCount the count value to add to the monitored count
  32242. * @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.
  32243. */
  32244. addCount(newCount: number, fetchResult: boolean): void;
  32245. /**
  32246. * Start monitoring this performance counter
  32247. */
  32248. beginMonitoring(): void;
  32249. /**
  32250. * Compute the time lapsed since the previous beginMonitoring() call.
  32251. * @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
  32252. */
  32253. endMonitoring(newFrame?: boolean): void;
  32254. private _fetchResult;
  32255. private _startMonitoringTime;
  32256. private _min;
  32257. private _max;
  32258. private _average;
  32259. private _current;
  32260. private _totalValueCount;
  32261. private _totalAccumulated;
  32262. private _lastSecAverage;
  32263. private _lastSecAccumulated;
  32264. private _lastSecTime;
  32265. private _lastSecValueCount;
  32266. }
  32267. /**
  32268. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32269. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32270. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32271. * @param name The name of the class, case should be preserved
  32272. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32273. */
  32274. export function className(name: string, module?: string): (target: Object) => void;
  32275. /**
  32276. * An implementation of a loop for asynchronous functions.
  32277. */
  32278. export class AsyncLoop {
  32279. /**
  32280. * Defines the number of iterations for the loop
  32281. */
  32282. iterations: number;
  32283. /**
  32284. * Defines the current index of the loop.
  32285. */
  32286. index: number;
  32287. private _done;
  32288. private _fn;
  32289. private _successCallback;
  32290. /**
  32291. * Constructor.
  32292. * @param iterations the number of iterations.
  32293. * @param func the function to run each iteration
  32294. * @param successCallback the callback that will be called upon succesful execution
  32295. * @param offset starting offset.
  32296. */
  32297. constructor(
  32298. /**
  32299. * Defines the number of iterations for the loop
  32300. */
  32301. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32302. /**
  32303. * Execute the next iteration. Must be called after the last iteration was finished.
  32304. */
  32305. executeNext(): void;
  32306. /**
  32307. * Break the loop and run the success callback.
  32308. */
  32309. breakLoop(): void;
  32310. /**
  32311. * Create and run an async loop.
  32312. * @param iterations the number of iterations.
  32313. * @param fn the function to run each iteration
  32314. * @param successCallback the callback that will be called upon succesful execution
  32315. * @param offset starting offset.
  32316. * @returns the created async loop object
  32317. */
  32318. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32319. /**
  32320. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32321. * @param iterations total number of iterations
  32322. * @param syncedIterations number of synchronous iterations in each async iteration.
  32323. * @param fn the function to call each iteration.
  32324. * @param callback a success call back that will be called when iterating stops.
  32325. * @param breakFunction a break condition (optional)
  32326. * @param timeout timeout settings for the setTimeout function. default - 0.
  32327. * @returns the created async loop object
  32328. */
  32329. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32330. }
  32331. }
  32332. declare module "babylonjs/Collisions/collisionCoordinator" {
  32333. import { Nullable } from "babylonjs/types";
  32334. import { Scene } from "babylonjs/scene";
  32335. import { Vector3 } from "babylonjs/Maths/math";
  32336. import { Collider } from "babylonjs/Collisions/collider";
  32337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32338. /** @hidden */
  32339. export interface ICollisionCoordinator {
  32340. createCollider(): Collider;
  32341. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32342. init(scene: Scene): void;
  32343. }
  32344. /** @hidden */
  32345. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32346. private _scene;
  32347. private _scaledPosition;
  32348. private _scaledVelocity;
  32349. private _finalPosition;
  32350. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32351. createCollider(): Collider;
  32352. init(scene: Scene): void;
  32353. private _collideWithWorld;
  32354. }
  32355. }
  32356. declare module "babylonjs/Inputs/scene.inputManager" {
  32357. import { Nullable } from "babylonjs/types";
  32358. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32359. import { Vector2 } from "babylonjs/Maths/math";
  32360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32361. import { Scene } from "babylonjs/scene";
  32362. /**
  32363. * Class used to manage all inputs for the scene.
  32364. */
  32365. export class InputManager {
  32366. /** The distance in pixel that you have to move to prevent some events */
  32367. static DragMovementThreshold: number;
  32368. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32369. static LongPressDelay: number;
  32370. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32371. static DoubleClickDelay: number;
  32372. /** If you need to check double click without raising a single click at first click, enable this flag */
  32373. static ExclusiveDoubleClickMode: boolean;
  32374. private _wheelEventName;
  32375. private _onPointerMove;
  32376. private _onPointerDown;
  32377. private _onPointerUp;
  32378. private _initClickEvent;
  32379. private _initActionManager;
  32380. private _delayedSimpleClick;
  32381. private _delayedSimpleClickTimeout;
  32382. private _previousDelayedSimpleClickTimeout;
  32383. private _meshPickProceed;
  32384. private _previousButtonPressed;
  32385. private _currentPickResult;
  32386. private _previousPickResult;
  32387. private _totalPointersPressed;
  32388. private _doubleClickOccured;
  32389. private _pointerOverMesh;
  32390. private _pickedDownMesh;
  32391. private _pickedUpMesh;
  32392. private _pointerX;
  32393. private _pointerY;
  32394. private _unTranslatedPointerX;
  32395. private _unTranslatedPointerY;
  32396. private _startingPointerPosition;
  32397. private _previousStartingPointerPosition;
  32398. private _startingPointerTime;
  32399. private _previousStartingPointerTime;
  32400. private _pointerCaptures;
  32401. private _onKeyDown;
  32402. private _onKeyUp;
  32403. private _onCanvasFocusObserver;
  32404. private _onCanvasBlurObserver;
  32405. private _scene;
  32406. /**
  32407. * Creates a new InputManager
  32408. * @param scene defines the hosting scene
  32409. */
  32410. constructor(scene: Scene);
  32411. /**
  32412. * Gets the mesh that is currently under the pointer
  32413. */
  32414. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32415. /**
  32416. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32417. */
  32418. readonly unTranslatedPointer: Vector2;
  32419. /**
  32420. * Gets or sets the current on-screen X position of the pointer
  32421. */
  32422. pointerX: number;
  32423. /**
  32424. * Gets or sets the current on-screen Y position of the pointer
  32425. */
  32426. pointerY: number;
  32427. private _updatePointerPosition;
  32428. private _processPointerMove;
  32429. private _setRayOnPointerInfo;
  32430. private _checkPrePointerObservable;
  32431. /**
  32432. * Use this method to simulate a pointer move on a mesh
  32433. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32434. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32435. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32436. */
  32437. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32438. /**
  32439. * Use this method to simulate a pointer down on a mesh
  32440. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32441. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32442. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32443. */
  32444. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32445. private _processPointerDown;
  32446. /** @hidden */
  32447. _isPointerSwiping(): boolean;
  32448. /**
  32449. * Use this method to simulate a pointer up on a mesh
  32450. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32451. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32452. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32453. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32454. */
  32455. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32456. private _processPointerUp;
  32457. /**
  32458. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32459. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32460. * @returns true if the pointer was captured
  32461. */
  32462. isPointerCaptured(pointerId?: number): boolean;
  32463. /**
  32464. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32465. * @param attachUp defines if you want to attach events to pointerup
  32466. * @param attachDown defines if you want to attach events to pointerdown
  32467. * @param attachMove defines if you want to attach events to pointermove
  32468. */
  32469. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32470. /**
  32471. * Detaches all event handlers
  32472. */
  32473. detachControl(): void;
  32474. /**
  32475. * Force the value of meshUnderPointer
  32476. * @param mesh defines the mesh to use
  32477. */
  32478. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32479. /**
  32480. * Gets the mesh under the pointer
  32481. * @returns a Mesh or null if no mesh is under the pointer
  32482. */
  32483. getPointerOverMesh(): Nullable<AbstractMesh>;
  32484. }
  32485. }
  32486. declare module "babylonjs/Animations/animationGroup" {
  32487. import { Animatable } from "babylonjs/Animations/animatable";
  32488. import { Animation } from "babylonjs/Animations/animation";
  32489. import { Scene, IDisposable } from "babylonjs/scene";
  32490. import { Observable } from "babylonjs/Misc/observable";
  32491. import { Nullable } from "babylonjs/types";
  32492. /**
  32493. * This class defines the direct association between an animation and a target
  32494. */
  32495. export class TargetedAnimation {
  32496. /**
  32497. * Animation to perform
  32498. */
  32499. animation: Animation;
  32500. /**
  32501. * Target to animate
  32502. */
  32503. target: any;
  32504. }
  32505. /**
  32506. * Use this class to create coordinated animations on multiple targets
  32507. */
  32508. export class AnimationGroup implements IDisposable {
  32509. /** The name of the animation group */
  32510. name: string;
  32511. private _scene;
  32512. private _targetedAnimations;
  32513. private _animatables;
  32514. private _from;
  32515. private _to;
  32516. private _isStarted;
  32517. private _isPaused;
  32518. private _speedRatio;
  32519. /**
  32520. * Gets or sets the unique id of the node
  32521. */
  32522. uniqueId: number;
  32523. /**
  32524. * This observable will notify when one animation have ended
  32525. */
  32526. onAnimationEndObservable: Observable<TargetedAnimation>;
  32527. /**
  32528. * Observer raised when one animation loops
  32529. */
  32530. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32531. /**
  32532. * This observable will notify when all animations have ended.
  32533. */
  32534. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32535. /**
  32536. * This observable will notify when all animations have paused.
  32537. */
  32538. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32539. /**
  32540. * This observable will notify when all animations are playing.
  32541. */
  32542. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32543. /**
  32544. * Gets the first frame
  32545. */
  32546. readonly from: number;
  32547. /**
  32548. * Gets the last frame
  32549. */
  32550. readonly to: number;
  32551. /**
  32552. * Define if the animations are started
  32553. */
  32554. readonly isStarted: boolean;
  32555. /**
  32556. * Gets a value indicating that the current group is playing
  32557. */
  32558. readonly isPlaying: boolean;
  32559. /**
  32560. * Gets or sets the speed ratio to use for all animations
  32561. */
  32562. /**
  32563. * Gets or sets the speed ratio to use for all animations
  32564. */
  32565. speedRatio: number;
  32566. /**
  32567. * Gets the targeted animations for this animation group
  32568. */
  32569. readonly targetedAnimations: Array<TargetedAnimation>;
  32570. /**
  32571. * returning the list of animatables controlled by this animation group.
  32572. */
  32573. readonly animatables: Array<Animatable>;
  32574. /**
  32575. * Instantiates a new Animation Group.
  32576. * This helps managing several animations at once.
  32577. * @see http://doc.babylonjs.com/how_to/group
  32578. * @param name Defines the name of the group
  32579. * @param scene Defines the scene the group belongs to
  32580. */
  32581. constructor(
  32582. /** The name of the animation group */
  32583. name: string, scene?: Nullable<Scene>);
  32584. /**
  32585. * Add an animation (with its target) in the group
  32586. * @param animation defines the animation we want to add
  32587. * @param target defines the target of the animation
  32588. * @returns the TargetedAnimation object
  32589. */
  32590. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32591. /**
  32592. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32593. * It can add constant keys at begin or end
  32594. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32595. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32596. * @returns the animation group
  32597. */
  32598. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32599. /**
  32600. * Start all animations on given targets
  32601. * @param loop defines if animations must loop
  32602. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32603. * @param from defines the from key (optional)
  32604. * @param to defines the to key (optional)
  32605. * @returns the current animation group
  32606. */
  32607. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32608. /**
  32609. * Pause all animations
  32610. * @returns the animation group
  32611. */
  32612. pause(): AnimationGroup;
  32613. /**
  32614. * Play all animations to initial state
  32615. * This function will start() the animations if they were not started or will restart() them if they were paused
  32616. * @param loop defines if animations must loop
  32617. * @returns the animation group
  32618. */
  32619. play(loop?: boolean): AnimationGroup;
  32620. /**
  32621. * Reset all animations to initial state
  32622. * @returns the animation group
  32623. */
  32624. reset(): AnimationGroup;
  32625. /**
  32626. * Restart animations from key 0
  32627. * @returns the animation group
  32628. */
  32629. restart(): AnimationGroup;
  32630. /**
  32631. * Stop all animations
  32632. * @returns the animation group
  32633. */
  32634. stop(): AnimationGroup;
  32635. /**
  32636. * Set animation weight for all animatables
  32637. * @param weight defines the weight to use
  32638. * @return the animationGroup
  32639. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32640. */
  32641. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32642. /**
  32643. * Synchronize and normalize all animatables with a source animatable
  32644. * @param root defines the root animatable to synchronize with
  32645. * @return the animationGroup
  32646. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32647. */
  32648. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32649. /**
  32650. * Goes to a specific frame in this animation group
  32651. * @param frame the frame number to go to
  32652. * @return the animationGroup
  32653. */
  32654. goToFrame(frame: number): AnimationGroup;
  32655. /**
  32656. * Dispose all associated resources
  32657. */
  32658. dispose(): void;
  32659. private _checkAnimationGroupEnded;
  32660. /**
  32661. * Clone the current animation group and returns a copy
  32662. * @param newName defines the name of the new group
  32663. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32664. * @returns the new aniamtion group
  32665. */
  32666. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32667. /**
  32668. * Returns a new AnimationGroup object parsed from the source provided.
  32669. * @param parsedAnimationGroup defines the source
  32670. * @param scene defines the scene that will receive the animationGroup
  32671. * @returns a new AnimationGroup
  32672. */
  32673. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32674. /**
  32675. * Returns the string "AnimationGroup"
  32676. * @returns "AnimationGroup"
  32677. */
  32678. getClassName(): string;
  32679. /**
  32680. * Creates a detailled string about the object
  32681. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32682. * @returns a string representing the object
  32683. */
  32684. toString(fullDetails?: boolean): string;
  32685. }
  32686. }
  32687. declare module "babylonjs/scene" {
  32688. import { Nullable } from "babylonjs/types";
  32689. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32690. import { Observable } from "babylonjs/Misc/observable";
  32691. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32692. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32693. import { Geometry } from "babylonjs/Meshes/geometry";
  32694. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32695. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32697. import { Mesh } from "babylonjs/Meshes/mesh";
  32698. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32699. import { Bone } from "babylonjs/Bones/bone";
  32700. import { Skeleton } from "babylonjs/Bones/skeleton";
  32701. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32702. import { Camera } from "babylonjs/Cameras/camera";
  32703. import { AbstractScene } from "babylonjs/abstractScene";
  32704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32705. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32706. import { Material } from "babylonjs/Materials/material";
  32707. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32708. import { Effect } from "babylonjs/Materials/effect";
  32709. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32710. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32711. import { Light } from "babylonjs/Lights/light";
  32712. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32713. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32714. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32715. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32716. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32717. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32718. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32719. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32720. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32721. import { Engine } from "babylonjs/Engines/engine";
  32722. import { Node } from "babylonjs/node";
  32723. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32724. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32725. import { WebRequest } from "babylonjs/Misc/webRequest";
  32726. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32727. import { Ray } from "babylonjs/Culling/ray";
  32728. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32729. import { Animation } from "babylonjs/Animations/animation";
  32730. import { Animatable } from "babylonjs/Animations/animatable";
  32731. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32732. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32733. import { Collider } from "babylonjs/Collisions/collider";
  32734. /**
  32735. * Define an interface for all classes that will hold resources
  32736. */
  32737. export interface IDisposable {
  32738. /**
  32739. * Releases all held resources
  32740. */
  32741. dispose(): void;
  32742. }
  32743. /** Interface defining initialization parameters for Scene class */
  32744. export interface SceneOptions {
  32745. /**
  32746. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32747. * It will improve performance when the number of geometries becomes important.
  32748. */
  32749. useGeometryUniqueIdsMap?: boolean;
  32750. /**
  32751. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32752. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32753. */
  32754. useMaterialMeshMap?: boolean;
  32755. /**
  32756. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32757. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32758. */
  32759. useClonedMeshhMap?: boolean;
  32760. }
  32761. /**
  32762. * Represents a scene to be rendered by the engine.
  32763. * @see http://doc.babylonjs.com/features/scene
  32764. */
  32765. export class Scene extends AbstractScene implements IAnimatable {
  32766. private static _uniqueIdCounter;
  32767. /** The fog is deactivated */
  32768. static readonly FOGMODE_NONE: number;
  32769. /** The fog density is following an exponential function */
  32770. static readonly FOGMODE_EXP: number;
  32771. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32772. static readonly FOGMODE_EXP2: number;
  32773. /** The fog density is following a linear function. */
  32774. static readonly FOGMODE_LINEAR: number;
  32775. /**
  32776. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32777. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32778. */
  32779. static MinDeltaTime: number;
  32780. /**
  32781. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32782. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32783. */
  32784. static MaxDeltaTime: number;
  32785. /**
  32786. * Factory used to create the default material.
  32787. * @param name The name of the material to create
  32788. * @param scene The scene to create the material for
  32789. * @returns The default material
  32790. */
  32791. static DefaultMaterialFactory(scene: Scene): Material;
  32792. /**
  32793. * Factory used to create the a collision coordinator.
  32794. * @returns The collision coordinator
  32795. */
  32796. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32797. /** @hidden */
  32798. _inputManager: InputManager;
  32799. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32800. cameraToUseForPointers: Nullable<Camera>;
  32801. /** @hidden */
  32802. readonly _isScene: boolean;
  32803. /**
  32804. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32805. */
  32806. autoClear: boolean;
  32807. /**
  32808. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32809. */
  32810. autoClearDepthAndStencil: boolean;
  32811. /**
  32812. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32813. */
  32814. clearColor: Color4;
  32815. /**
  32816. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32817. */
  32818. ambientColor: Color3;
  32819. /**
  32820. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32821. * It should only be one of the following (if not the default embedded one):
  32822. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32823. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32824. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32825. * The material properties need to be setup according to the type of texture in use.
  32826. */
  32827. environmentBRDFTexture: BaseTexture;
  32828. /** @hidden */
  32829. protected _environmentTexture: Nullable<BaseTexture>;
  32830. /**
  32831. * Texture used in all pbr material as the reflection texture.
  32832. * As in the majority of the scene they are the same (exception for multi room and so on),
  32833. * this is easier to reference from here than from all the materials.
  32834. */
  32835. /**
  32836. * Texture used in all pbr material as the reflection texture.
  32837. * As in the majority of the scene they are the same (exception for multi room and so on),
  32838. * this is easier to set here than in all the materials.
  32839. */
  32840. environmentTexture: Nullable<BaseTexture>;
  32841. /** @hidden */
  32842. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32843. /**
  32844. * Default image processing configuration used either in the rendering
  32845. * Forward main pass or through the imageProcessingPostProcess if present.
  32846. * As in the majority of the scene they are the same (exception for multi camera),
  32847. * this is easier to reference from here than from all the materials and post process.
  32848. *
  32849. * No setter as we it is a shared configuration, you can set the values instead.
  32850. */
  32851. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32852. private _forceWireframe;
  32853. /**
  32854. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32855. */
  32856. forceWireframe: boolean;
  32857. private _forcePointsCloud;
  32858. /**
  32859. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32860. */
  32861. forcePointsCloud: boolean;
  32862. /**
  32863. * Gets or sets the active clipplane 1
  32864. */
  32865. clipPlane: Nullable<Plane>;
  32866. /**
  32867. * Gets or sets the active clipplane 2
  32868. */
  32869. clipPlane2: Nullable<Plane>;
  32870. /**
  32871. * Gets or sets the active clipplane 3
  32872. */
  32873. clipPlane3: Nullable<Plane>;
  32874. /**
  32875. * Gets or sets the active clipplane 4
  32876. */
  32877. clipPlane4: Nullable<Plane>;
  32878. /**
  32879. * Gets or sets a boolean indicating if animations are enabled
  32880. */
  32881. animationsEnabled: boolean;
  32882. private _animationPropertiesOverride;
  32883. /**
  32884. * Gets or sets the animation properties override
  32885. */
  32886. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32887. /**
  32888. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32889. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32890. */
  32891. useConstantAnimationDeltaTime: boolean;
  32892. /**
  32893. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32894. * Please note that it requires to run a ray cast through the scene on every frame
  32895. */
  32896. constantlyUpdateMeshUnderPointer: boolean;
  32897. /**
  32898. * Defines the HTML cursor to use when hovering over interactive elements
  32899. */
  32900. hoverCursor: string;
  32901. /**
  32902. * Defines the HTML default cursor to use (empty by default)
  32903. */
  32904. defaultCursor: string;
  32905. /**
  32906. * This is used to call preventDefault() on pointer down
  32907. * in order to block unwanted artifacts like system double clicks
  32908. */
  32909. preventDefaultOnPointerDown: boolean;
  32910. /**
  32911. * This is used to call preventDefault() on pointer up
  32912. * in order to block unwanted artifacts like system double clicks
  32913. */
  32914. preventDefaultOnPointerUp: boolean;
  32915. /**
  32916. * Gets or sets user defined metadata
  32917. */
  32918. metadata: any;
  32919. /**
  32920. * For internal use only. Please do not use.
  32921. */
  32922. reservedDataStore: any;
  32923. /**
  32924. * Gets the name of the plugin used to load this scene (null by default)
  32925. */
  32926. loadingPluginName: string;
  32927. /**
  32928. * Use this array to add regular expressions used to disable offline support for specific urls
  32929. */
  32930. disableOfflineSupportExceptionRules: RegExp[];
  32931. /**
  32932. * An event triggered when the scene is disposed.
  32933. */
  32934. onDisposeObservable: Observable<Scene>;
  32935. private _onDisposeObserver;
  32936. /** Sets a function to be executed when this scene is disposed. */
  32937. onDispose: () => void;
  32938. /**
  32939. * An event triggered before rendering the scene (right after animations and physics)
  32940. */
  32941. onBeforeRenderObservable: Observable<Scene>;
  32942. private _onBeforeRenderObserver;
  32943. /** Sets a function to be executed before rendering this scene */
  32944. beforeRender: Nullable<() => void>;
  32945. /**
  32946. * An event triggered after rendering the scene
  32947. */
  32948. onAfterRenderObservable: Observable<Scene>;
  32949. private _onAfterRenderObserver;
  32950. /** Sets a function to be executed after rendering this scene */
  32951. afterRender: Nullable<() => void>;
  32952. /**
  32953. * An event triggered before animating the scene
  32954. */
  32955. onBeforeAnimationsObservable: Observable<Scene>;
  32956. /**
  32957. * An event triggered after animations processing
  32958. */
  32959. onAfterAnimationsObservable: Observable<Scene>;
  32960. /**
  32961. * An event triggered before draw calls are ready to be sent
  32962. */
  32963. onBeforeDrawPhaseObservable: Observable<Scene>;
  32964. /**
  32965. * An event triggered after draw calls have been sent
  32966. */
  32967. onAfterDrawPhaseObservable: Observable<Scene>;
  32968. /**
  32969. * An event triggered when the scene is ready
  32970. */
  32971. onReadyObservable: Observable<Scene>;
  32972. /**
  32973. * An event triggered before rendering a camera
  32974. */
  32975. onBeforeCameraRenderObservable: Observable<Camera>;
  32976. private _onBeforeCameraRenderObserver;
  32977. /** Sets a function to be executed before rendering a camera*/
  32978. beforeCameraRender: () => void;
  32979. /**
  32980. * An event triggered after rendering a camera
  32981. */
  32982. onAfterCameraRenderObservable: Observable<Camera>;
  32983. private _onAfterCameraRenderObserver;
  32984. /** Sets a function to be executed after rendering a camera*/
  32985. afterCameraRender: () => void;
  32986. /**
  32987. * An event triggered when active meshes evaluation is about to start
  32988. */
  32989. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32990. /**
  32991. * An event triggered when active meshes evaluation is done
  32992. */
  32993. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32994. /**
  32995. * An event triggered when particles rendering is about to start
  32996. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32997. */
  32998. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32999. /**
  33000. * An event triggered when particles rendering is done
  33001. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33002. */
  33003. onAfterParticlesRenderingObservable: Observable<Scene>;
  33004. /**
  33005. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33006. */
  33007. onDataLoadedObservable: Observable<Scene>;
  33008. /**
  33009. * An event triggered when a camera is created
  33010. */
  33011. onNewCameraAddedObservable: Observable<Camera>;
  33012. /**
  33013. * An event triggered when a camera is removed
  33014. */
  33015. onCameraRemovedObservable: Observable<Camera>;
  33016. /**
  33017. * An event triggered when a light is created
  33018. */
  33019. onNewLightAddedObservable: Observable<Light>;
  33020. /**
  33021. * An event triggered when a light is removed
  33022. */
  33023. onLightRemovedObservable: Observable<Light>;
  33024. /**
  33025. * An event triggered when a geometry is created
  33026. */
  33027. onNewGeometryAddedObservable: Observable<Geometry>;
  33028. /**
  33029. * An event triggered when a geometry is removed
  33030. */
  33031. onGeometryRemovedObservable: Observable<Geometry>;
  33032. /**
  33033. * An event triggered when a transform node is created
  33034. */
  33035. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33036. /**
  33037. * An event triggered when a transform node is removed
  33038. */
  33039. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33040. /**
  33041. * An event triggered when a mesh is created
  33042. */
  33043. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33044. /**
  33045. * An event triggered when a mesh is removed
  33046. */
  33047. onMeshRemovedObservable: Observable<AbstractMesh>;
  33048. /**
  33049. * An event triggered when a skeleton is created
  33050. */
  33051. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33052. /**
  33053. * An event triggered when a skeleton is removed
  33054. */
  33055. onSkeletonRemovedObservable: Observable<Skeleton>;
  33056. /**
  33057. * An event triggered when a material is created
  33058. */
  33059. onNewMaterialAddedObservable: Observable<Material>;
  33060. /**
  33061. * An event triggered when a material is removed
  33062. */
  33063. onMaterialRemovedObservable: Observable<Material>;
  33064. /**
  33065. * An event triggered when a texture is created
  33066. */
  33067. onNewTextureAddedObservable: Observable<BaseTexture>;
  33068. /**
  33069. * An event triggered when a texture is removed
  33070. */
  33071. onTextureRemovedObservable: Observable<BaseTexture>;
  33072. /**
  33073. * An event triggered when render targets are about to be rendered
  33074. * Can happen multiple times per frame.
  33075. */
  33076. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33077. /**
  33078. * An event triggered when render targets were rendered.
  33079. * Can happen multiple times per frame.
  33080. */
  33081. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33082. /**
  33083. * An event triggered before calculating deterministic simulation step
  33084. */
  33085. onBeforeStepObservable: Observable<Scene>;
  33086. /**
  33087. * An event triggered after calculating deterministic simulation step
  33088. */
  33089. onAfterStepObservable: Observable<Scene>;
  33090. /**
  33091. * An event triggered when the activeCamera property is updated
  33092. */
  33093. onActiveCameraChanged: Observable<Scene>;
  33094. /**
  33095. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33096. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33097. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  33098. */
  33099. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33100. /**
  33101. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33102. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33103. * 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)
  33104. */
  33105. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33106. /**
  33107. * This Observable will when a mesh has been imported into the scene.
  33108. */
  33109. onMeshImportedObservable: Observable<AbstractMesh>;
  33110. /**
  33111. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33112. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33113. */
  33114. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33115. /** @hidden */
  33116. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33117. /**
  33118. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33119. */
  33120. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33121. /**
  33122. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33123. */
  33124. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33125. /**
  33126. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33127. */
  33128. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33129. /** Callback called when a pointer move is detected */
  33130. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33131. /** Callback called when a pointer down is detected */
  33132. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33133. /** Callback called when a pointer up is detected */
  33134. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33135. /** Callback called when a pointer pick is detected */
  33136. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33137. /**
  33138. * 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).
  33139. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33140. */
  33141. onPrePointerObservable: Observable<PointerInfoPre>;
  33142. /**
  33143. * Observable event triggered each time an input event is received from the rendering canvas
  33144. */
  33145. onPointerObservable: Observable<PointerInfo>;
  33146. /**
  33147. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33148. */
  33149. readonly unTranslatedPointer: Vector2;
  33150. /**
  33151. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33152. */
  33153. static DragMovementThreshold: number;
  33154. /**
  33155. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33156. */
  33157. static LongPressDelay: number;
  33158. /**
  33159. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33160. */
  33161. static DoubleClickDelay: number;
  33162. /** If you need to check double click without raising a single click at first click, enable this flag */
  33163. static ExclusiveDoubleClickMode: boolean;
  33164. /** @hidden */
  33165. _mirroredCameraPosition: Nullable<Vector3>;
  33166. /**
  33167. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33168. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33169. */
  33170. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33171. /**
  33172. * Observable event triggered each time an keyboard event is received from the hosting window
  33173. */
  33174. onKeyboardObservable: Observable<KeyboardInfo>;
  33175. private _useRightHandedSystem;
  33176. /**
  33177. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33178. */
  33179. useRightHandedSystem: boolean;
  33180. private _timeAccumulator;
  33181. private _currentStepId;
  33182. private _currentInternalStep;
  33183. /**
  33184. * Sets the step Id used by deterministic lock step
  33185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33186. * @param newStepId defines the step Id
  33187. */
  33188. setStepId(newStepId: number): void;
  33189. /**
  33190. * Gets the step Id used by deterministic lock step
  33191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33192. * @returns the step Id
  33193. */
  33194. getStepId(): number;
  33195. /**
  33196. * Gets the internal step used by deterministic lock step
  33197. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33198. * @returns the internal step
  33199. */
  33200. getInternalStep(): number;
  33201. private _fogEnabled;
  33202. /**
  33203. * Gets or sets a boolean indicating if fog is enabled on this scene
  33204. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33205. * (Default is true)
  33206. */
  33207. fogEnabled: boolean;
  33208. private _fogMode;
  33209. /**
  33210. * Gets or sets the fog mode to use
  33211. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33212. * | mode | value |
  33213. * | --- | --- |
  33214. * | FOGMODE_NONE | 0 |
  33215. * | FOGMODE_EXP | 1 |
  33216. * | FOGMODE_EXP2 | 2 |
  33217. * | FOGMODE_LINEAR | 3 |
  33218. */
  33219. fogMode: number;
  33220. /**
  33221. * Gets or sets the fog color to use
  33222. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33223. * (Default is Color3(0.2, 0.2, 0.3))
  33224. */
  33225. fogColor: Color3;
  33226. /**
  33227. * Gets or sets the fog density to use
  33228. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33229. * (Default is 0.1)
  33230. */
  33231. fogDensity: number;
  33232. /**
  33233. * Gets or sets the fog start distance to use
  33234. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33235. * (Default is 0)
  33236. */
  33237. fogStart: number;
  33238. /**
  33239. * Gets or sets the fog end distance to use
  33240. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33241. * (Default is 1000)
  33242. */
  33243. fogEnd: number;
  33244. private _shadowsEnabled;
  33245. /**
  33246. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33247. */
  33248. shadowsEnabled: boolean;
  33249. private _lightsEnabled;
  33250. /**
  33251. * Gets or sets a boolean indicating if lights are enabled on this scene
  33252. */
  33253. lightsEnabled: boolean;
  33254. /** All of the active cameras added to this scene. */
  33255. activeCameras: Camera[];
  33256. /** @hidden */
  33257. _activeCamera: Nullable<Camera>;
  33258. /** Gets or sets the current active camera */
  33259. activeCamera: Nullable<Camera>;
  33260. private _defaultMaterial;
  33261. /** The default material used on meshes when no material is affected */
  33262. /** The default material used on meshes when no material is affected */
  33263. defaultMaterial: Material;
  33264. private _texturesEnabled;
  33265. /**
  33266. * Gets or sets a boolean indicating if textures are enabled on this scene
  33267. */
  33268. texturesEnabled: boolean;
  33269. /**
  33270. * Gets or sets a boolean indicating if particles are enabled on this scene
  33271. */
  33272. particlesEnabled: boolean;
  33273. /**
  33274. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33275. */
  33276. spritesEnabled: boolean;
  33277. private _skeletonsEnabled;
  33278. /**
  33279. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33280. */
  33281. skeletonsEnabled: boolean;
  33282. /**
  33283. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33284. */
  33285. lensFlaresEnabled: boolean;
  33286. /**
  33287. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33288. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33289. */
  33290. collisionsEnabled: boolean;
  33291. private _collisionCoordinator;
  33292. /** @hidden */
  33293. readonly collisionCoordinator: ICollisionCoordinator;
  33294. /**
  33295. * Defines the gravity applied to this scene (used only for collisions)
  33296. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33297. */
  33298. gravity: Vector3;
  33299. /**
  33300. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33301. */
  33302. postProcessesEnabled: boolean;
  33303. /**
  33304. * The list of postprocesses added to the scene
  33305. */
  33306. postProcesses: PostProcess[];
  33307. /**
  33308. * Gets the current postprocess manager
  33309. */
  33310. postProcessManager: PostProcessManager;
  33311. /**
  33312. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33313. */
  33314. renderTargetsEnabled: boolean;
  33315. /**
  33316. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33317. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33318. */
  33319. dumpNextRenderTargets: boolean;
  33320. /**
  33321. * The list of user defined render targets added to the scene
  33322. */
  33323. customRenderTargets: RenderTargetTexture[];
  33324. /**
  33325. * Defines if texture loading must be delayed
  33326. * If true, textures will only be loaded when they need to be rendered
  33327. */
  33328. useDelayedTextureLoading: boolean;
  33329. /**
  33330. * Gets the list of meshes imported to the scene through SceneLoader
  33331. */
  33332. importedMeshesFiles: String[];
  33333. /**
  33334. * Gets or sets a boolean indicating if probes are enabled on this scene
  33335. */
  33336. probesEnabled: boolean;
  33337. /**
  33338. * Gets or sets the current offline provider to use to store scene data
  33339. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33340. */
  33341. offlineProvider: IOfflineProvider;
  33342. /**
  33343. * Gets or sets the action manager associated with the scene
  33344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33345. */
  33346. actionManager: AbstractActionManager;
  33347. private _meshesForIntersections;
  33348. /**
  33349. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33350. */
  33351. proceduralTexturesEnabled: boolean;
  33352. private _engine;
  33353. private _totalVertices;
  33354. /** @hidden */
  33355. _activeIndices: PerfCounter;
  33356. /** @hidden */
  33357. _activeParticles: PerfCounter;
  33358. /** @hidden */
  33359. _activeBones: PerfCounter;
  33360. private _animationRatio;
  33361. /** @hidden */
  33362. _animationTimeLast: number;
  33363. /** @hidden */
  33364. _animationTime: number;
  33365. /**
  33366. * Gets or sets a general scale for animation speed
  33367. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33368. */
  33369. animationTimeScale: number;
  33370. /** @hidden */
  33371. _cachedMaterial: Nullable<Material>;
  33372. /** @hidden */
  33373. _cachedEffect: Nullable<Effect>;
  33374. /** @hidden */
  33375. _cachedVisibility: Nullable<number>;
  33376. private _renderId;
  33377. private _frameId;
  33378. private _executeWhenReadyTimeoutId;
  33379. private _intermediateRendering;
  33380. private _viewUpdateFlag;
  33381. private _projectionUpdateFlag;
  33382. /** @hidden */
  33383. _toBeDisposed: Nullable<IDisposable>[];
  33384. private _activeRequests;
  33385. /** @hidden */
  33386. _pendingData: any[];
  33387. private _isDisposed;
  33388. /**
  33389. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33390. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33391. */
  33392. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33393. private _activeMeshes;
  33394. private _processedMaterials;
  33395. private _renderTargets;
  33396. /** @hidden */
  33397. _activeParticleSystems: SmartArray<IParticleSystem>;
  33398. private _activeSkeletons;
  33399. private _softwareSkinnedMeshes;
  33400. private _renderingManager;
  33401. /** @hidden */
  33402. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33403. private _transformMatrix;
  33404. private _sceneUbo;
  33405. /** @hidden */
  33406. _viewMatrix: Matrix;
  33407. private _projectionMatrix;
  33408. /** @hidden */
  33409. _forcedViewPosition: Nullable<Vector3>;
  33410. /** @hidden */
  33411. _frustumPlanes: Plane[];
  33412. /**
  33413. * Gets the list of frustum planes (built from the active camera)
  33414. */
  33415. readonly frustumPlanes: Plane[];
  33416. /**
  33417. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33418. * This is useful if there are more lights that the maximum simulteanous authorized
  33419. */
  33420. requireLightSorting: boolean;
  33421. /** @hidden */
  33422. readonly useMaterialMeshMap: boolean;
  33423. /** @hidden */
  33424. readonly useClonedMeshhMap: boolean;
  33425. private _externalData;
  33426. private _uid;
  33427. /**
  33428. * @hidden
  33429. * Backing store of defined scene components.
  33430. */
  33431. _components: ISceneComponent[];
  33432. /**
  33433. * @hidden
  33434. * Backing store of defined scene components.
  33435. */
  33436. _serializableComponents: ISceneSerializableComponent[];
  33437. /**
  33438. * List of components to register on the next registration step.
  33439. */
  33440. private _transientComponents;
  33441. /**
  33442. * Registers the transient components if needed.
  33443. */
  33444. private _registerTransientComponents;
  33445. /**
  33446. * @hidden
  33447. * Add a component to the scene.
  33448. * Note that the ccomponent could be registered on th next frame if this is called after
  33449. * the register component stage.
  33450. * @param component Defines the component to add to the scene
  33451. */
  33452. _addComponent(component: ISceneComponent): void;
  33453. /**
  33454. * @hidden
  33455. * Gets a component from the scene.
  33456. * @param name defines the name of the component to retrieve
  33457. * @returns the component or null if not present
  33458. */
  33459. _getComponent(name: string): Nullable<ISceneComponent>;
  33460. /**
  33461. * @hidden
  33462. * Defines the actions happening before camera updates.
  33463. */
  33464. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33465. /**
  33466. * @hidden
  33467. * Defines the actions happening before clear the canvas.
  33468. */
  33469. _beforeClearStage: Stage<SimpleStageAction>;
  33470. /**
  33471. * @hidden
  33472. * Defines the actions when collecting render targets for the frame.
  33473. */
  33474. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33475. /**
  33476. * @hidden
  33477. * Defines the actions happening for one camera in the frame.
  33478. */
  33479. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33480. /**
  33481. * @hidden
  33482. * Defines the actions happening during the per mesh ready checks.
  33483. */
  33484. _isReadyForMeshStage: Stage<MeshStageAction>;
  33485. /**
  33486. * @hidden
  33487. * Defines the actions happening before evaluate active mesh checks.
  33488. */
  33489. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33490. /**
  33491. * @hidden
  33492. * Defines the actions happening during the evaluate sub mesh checks.
  33493. */
  33494. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33495. /**
  33496. * @hidden
  33497. * Defines the actions happening during the active mesh stage.
  33498. */
  33499. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33500. /**
  33501. * @hidden
  33502. * Defines the actions happening during the per camera render target step.
  33503. */
  33504. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33505. /**
  33506. * @hidden
  33507. * Defines the actions happening just before the active camera is drawing.
  33508. */
  33509. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33510. /**
  33511. * @hidden
  33512. * Defines the actions happening just before a render target is drawing.
  33513. */
  33514. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33515. /**
  33516. * @hidden
  33517. * Defines the actions happening just before a rendering group is drawing.
  33518. */
  33519. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33520. /**
  33521. * @hidden
  33522. * Defines the actions happening just before a mesh is drawing.
  33523. */
  33524. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33525. /**
  33526. * @hidden
  33527. * Defines the actions happening just after a mesh has been drawn.
  33528. */
  33529. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33530. /**
  33531. * @hidden
  33532. * Defines the actions happening just after a rendering group has been drawn.
  33533. */
  33534. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33535. /**
  33536. * @hidden
  33537. * Defines the actions happening just after the active camera has been drawn.
  33538. */
  33539. _afterCameraDrawStage: Stage<CameraStageAction>;
  33540. /**
  33541. * @hidden
  33542. * Defines the actions happening just after a render target has been drawn.
  33543. */
  33544. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33545. /**
  33546. * @hidden
  33547. * Defines the actions happening just after rendering all cameras and computing intersections.
  33548. */
  33549. _afterRenderStage: Stage<SimpleStageAction>;
  33550. /**
  33551. * @hidden
  33552. * Defines the actions happening when a pointer move event happens.
  33553. */
  33554. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33555. /**
  33556. * @hidden
  33557. * Defines the actions happening when a pointer down event happens.
  33558. */
  33559. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33560. /**
  33561. * @hidden
  33562. * Defines the actions happening when a pointer up event happens.
  33563. */
  33564. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33565. /**
  33566. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33567. */
  33568. private geometriesByUniqueId;
  33569. /**
  33570. * Creates a new Scene
  33571. * @param engine defines the engine to use to render this scene
  33572. * @param options defines the scene options
  33573. */
  33574. constructor(engine: Engine, options?: SceneOptions);
  33575. /**
  33576. * Gets a string idenfifying the name of the class
  33577. * @returns "Scene" string
  33578. */
  33579. getClassName(): string;
  33580. private _defaultMeshCandidates;
  33581. /**
  33582. * @hidden
  33583. */
  33584. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33585. private _defaultSubMeshCandidates;
  33586. /**
  33587. * @hidden
  33588. */
  33589. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33590. /**
  33591. * Sets the default candidate providers for the scene.
  33592. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33593. * and getCollidingSubMeshCandidates to their default function
  33594. */
  33595. setDefaultCandidateProviders(): void;
  33596. /**
  33597. * Gets the mesh that is currently under the pointer
  33598. */
  33599. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33600. /**
  33601. * Gets or sets the current on-screen X position of the pointer
  33602. */
  33603. pointerX: number;
  33604. /**
  33605. * Gets or sets the current on-screen Y position of the pointer
  33606. */
  33607. pointerY: number;
  33608. /**
  33609. * Gets the cached material (ie. the latest rendered one)
  33610. * @returns the cached material
  33611. */
  33612. getCachedMaterial(): Nullable<Material>;
  33613. /**
  33614. * Gets the cached effect (ie. the latest rendered one)
  33615. * @returns the cached effect
  33616. */
  33617. getCachedEffect(): Nullable<Effect>;
  33618. /**
  33619. * Gets the cached visibility state (ie. the latest rendered one)
  33620. * @returns the cached visibility state
  33621. */
  33622. getCachedVisibility(): Nullable<number>;
  33623. /**
  33624. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33625. * @param material defines the current material
  33626. * @param effect defines the current effect
  33627. * @param visibility defines the current visibility state
  33628. * @returns true if one parameter is not cached
  33629. */
  33630. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33631. /**
  33632. * Gets the engine associated with the scene
  33633. * @returns an Engine
  33634. */
  33635. getEngine(): Engine;
  33636. /**
  33637. * Gets the total number of vertices rendered per frame
  33638. * @returns the total number of vertices rendered per frame
  33639. */
  33640. getTotalVertices(): number;
  33641. /**
  33642. * Gets the performance counter for total vertices
  33643. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33644. */
  33645. readonly totalVerticesPerfCounter: PerfCounter;
  33646. /**
  33647. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33648. * @returns the total number of active indices rendered per frame
  33649. */
  33650. getActiveIndices(): number;
  33651. /**
  33652. * Gets the performance counter for active indices
  33653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33654. */
  33655. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33656. /**
  33657. * Gets the total number of active particles rendered per frame
  33658. * @returns the total number of active particles rendered per frame
  33659. */
  33660. getActiveParticles(): number;
  33661. /**
  33662. * Gets the performance counter for active particles
  33663. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33664. */
  33665. readonly activeParticlesPerfCounter: PerfCounter;
  33666. /**
  33667. * Gets the total number of active bones rendered per frame
  33668. * @returns the total number of active bones rendered per frame
  33669. */
  33670. getActiveBones(): number;
  33671. /**
  33672. * Gets the performance counter for active bones
  33673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33674. */
  33675. readonly activeBonesPerfCounter: PerfCounter;
  33676. /**
  33677. * Gets the array of active meshes
  33678. * @returns an array of AbstractMesh
  33679. */
  33680. getActiveMeshes(): SmartArray<AbstractMesh>;
  33681. /**
  33682. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33683. * @returns a number
  33684. */
  33685. getAnimationRatio(): number;
  33686. /**
  33687. * Gets an unique Id for the current render phase
  33688. * @returns a number
  33689. */
  33690. getRenderId(): number;
  33691. /**
  33692. * Gets an unique Id for the current frame
  33693. * @returns a number
  33694. */
  33695. getFrameId(): number;
  33696. /** Call this function if you want to manually increment the render Id*/
  33697. incrementRenderId(): void;
  33698. private _createUbo;
  33699. /**
  33700. * Use this method to simulate a pointer move on a mesh
  33701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33704. * @returns the current scene
  33705. */
  33706. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33707. /**
  33708. * Use this method to simulate a pointer down 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. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33715. /**
  33716. * Use this method to simulate a pointer up 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. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33721. * @returns the current scene
  33722. */
  33723. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33724. /**
  33725. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33726. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33727. * @returns true if the pointer was captured
  33728. */
  33729. isPointerCaptured(pointerId?: number): boolean;
  33730. /**
  33731. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33732. * @param attachUp defines if you want to attach events to pointerup
  33733. * @param attachDown defines if you want to attach events to pointerdown
  33734. * @param attachMove defines if you want to attach events to pointermove
  33735. */
  33736. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33737. /** Detaches all event handlers*/
  33738. detachControl(): void;
  33739. /**
  33740. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33741. * Delay loaded resources are not taking in account
  33742. * @return true if all required resources are ready
  33743. */
  33744. isReady(): boolean;
  33745. /** Resets all cached information relative to material (including effect and visibility) */
  33746. resetCachedMaterial(): void;
  33747. /**
  33748. * Registers a function to be called before every frame render
  33749. * @param func defines the function to register
  33750. */
  33751. registerBeforeRender(func: () => void): void;
  33752. /**
  33753. * Unregisters a function called before every frame render
  33754. * @param func defines the function to unregister
  33755. */
  33756. unregisterBeforeRender(func: () => void): void;
  33757. /**
  33758. * Registers a function to be called after every frame render
  33759. * @param func defines the function to register
  33760. */
  33761. registerAfterRender(func: () => void): void;
  33762. /**
  33763. * Unregisters a function called after every frame render
  33764. * @param func defines the function to unregister
  33765. */
  33766. unregisterAfterRender(func: () => void): void;
  33767. private _executeOnceBeforeRender;
  33768. /**
  33769. * The provided function will run before render once and will be disposed afterwards.
  33770. * A timeout delay can be provided so that the function will be executed in N ms.
  33771. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33772. * @param func The function to be executed.
  33773. * @param timeout optional delay in ms
  33774. */
  33775. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33776. /** @hidden */
  33777. _addPendingData(data: any): void;
  33778. /** @hidden */
  33779. _removePendingData(data: any): void;
  33780. /**
  33781. * Returns the number of items waiting to be loaded
  33782. * @returns the number of items waiting to be loaded
  33783. */
  33784. getWaitingItemsCount(): number;
  33785. /**
  33786. * Returns a boolean indicating if the scene is still loading data
  33787. */
  33788. readonly isLoading: boolean;
  33789. /**
  33790. * Registers a function to be executed when the scene is ready
  33791. * @param {Function} func - the function to be executed
  33792. */
  33793. executeWhenReady(func: () => void): void;
  33794. /**
  33795. * Returns a promise that resolves when the scene is ready
  33796. * @returns A promise that resolves when the scene is ready
  33797. */
  33798. whenReadyAsync(): Promise<void>;
  33799. /** @hidden */
  33800. _checkIsReady(): void;
  33801. /**
  33802. * Gets all animatable attached to the scene
  33803. */
  33804. readonly animatables: Animatable[];
  33805. /**
  33806. * Resets the last animation time frame.
  33807. * Useful to override when animations start running when loading a scene for the first time.
  33808. */
  33809. resetLastAnimationTimeFrame(): void;
  33810. /**
  33811. * Gets the current view matrix
  33812. * @returns a Matrix
  33813. */
  33814. getViewMatrix(): Matrix;
  33815. /**
  33816. * Gets the current projection matrix
  33817. * @returns a Matrix
  33818. */
  33819. getProjectionMatrix(): Matrix;
  33820. /**
  33821. * Gets the current transform matrix
  33822. * @returns a Matrix made of View * Projection
  33823. */
  33824. getTransformMatrix(): Matrix;
  33825. /**
  33826. * Sets the current transform matrix
  33827. * @param viewL defines the View matrix to use
  33828. * @param projectionL defines the Projection matrix to use
  33829. * @param viewR defines the right View matrix to use (if provided)
  33830. * @param projectionR defines the right Projection matrix to use (if provided)
  33831. */
  33832. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33833. /**
  33834. * Gets the uniform buffer used to store scene data
  33835. * @returns a UniformBuffer
  33836. */
  33837. getSceneUniformBuffer(): UniformBuffer;
  33838. /**
  33839. * Gets an unique (relatively to the current scene) Id
  33840. * @returns an unique number for the scene
  33841. */
  33842. getUniqueId(): number;
  33843. /**
  33844. * Add a mesh to the list of scene's meshes
  33845. * @param newMesh defines the mesh to add
  33846. * @param recursive if all child meshes should also be added to the scene
  33847. */
  33848. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33849. /**
  33850. * Remove a mesh for the list of scene's meshes
  33851. * @param toRemove defines the mesh to remove
  33852. * @param recursive if all child meshes should also be removed from the scene
  33853. * @returns the index where the mesh was in the mesh list
  33854. */
  33855. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33856. /**
  33857. * Add a transform node to the list of scene's transform nodes
  33858. * @param newTransformNode defines the transform node to add
  33859. */
  33860. addTransformNode(newTransformNode: TransformNode): void;
  33861. /**
  33862. * Remove a transform node for the list of scene's transform nodes
  33863. * @param toRemove defines the transform node to remove
  33864. * @returns the index where the transform node was in the transform node list
  33865. */
  33866. removeTransformNode(toRemove: TransformNode): number;
  33867. /**
  33868. * Remove a skeleton for the list of scene's skeletons
  33869. * @param toRemove defines the skeleton to remove
  33870. * @returns the index where the skeleton was in the skeleton list
  33871. */
  33872. removeSkeleton(toRemove: Skeleton): number;
  33873. /**
  33874. * Remove a morph target for the list of scene's morph targets
  33875. * @param toRemove defines the morph target to remove
  33876. * @returns the index where the morph target was in the morph target list
  33877. */
  33878. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33879. /**
  33880. * Remove a light for the list of scene's lights
  33881. * @param toRemove defines the light to remove
  33882. * @returns the index where the light was in the light list
  33883. */
  33884. removeLight(toRemove: Light): number;
  33885. /**
  33886. * Remove a camera for the list of scene's cameras
  33887. * @param toRemove defines the camera to remove
  33888. * @returns the index where the camera was in the camera list
  33889. */
  33890. removeCamera(toRemove: Camera): number;
  33891. /**
  33892. * Remove a particle system for the list of scene's particle systems
  33893. * @param toRemove defines the particle system to remove
  33894. * @returns the index where the particle system was in the particle system list
  33895. */
  33896. removeParticleSystem(toRemove: IParticleSystem): number;
  33897. /**
  33898. * Remove a animation for the list of scene's animations
  33899. * @param toRemove defines the animation to remove
  33900. * @returns the index where the animation was in the animation list
  33901. */
  33902. removeAnimation(toRemove: Animation): number;
  33903. /**
  33904. * Will stop the animation of the given target
  33905. * @param target - the target
  33906. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33907. * @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)
  33908. */
  33909. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33910. /**
  33911. * Removes the given animation group from this scene.
  33912. * @param toRemove The animation group to remove
  33913. * @returns The index of the removed animation group
  33914. */
  33915. removeAnimationGroup(toRemove: AnimationGroup): number;
  33916. /**
  33917. * Removes the given multi-material from this scene.
  33918. * @param toRemove The multi-material to remove
  33919. * @returns The index of the removed multi-material
  33920. */
  33921. removeMultiMaterial(toRemove: MultiMaterial): number;
  33922. /**
  33923. * Removes the given material from this scene.
  33924. * @param toRemove The material to remove
  33925. * @returns The index of the removed material
  33926. */
  33927. removeMaterial(toRemove: Material): number;
  33928. /**
  33929. * Removes the given action manager from this scene.
  33930. * @param toRemove The action manager to remove
  33931. * @returns The index of the removed action manager
  33932. */
  33933. removeActionManager(toRemove: AbstractActionManager): number;
  33934. /**
  33935. * Removes the given texture from this scene.
  33936. * @param toRemove The texture to remove
  33937. * @returns The index of the removed texture
  33938. */
  33939. removeTexture(toRemove: BaseTexture): number;
  33940. /**
  33941. * Adds the given light to this scene
  33942. * @param newLight The light to add
  33943. */
  33944. addLight(newLight: Light): void;
  33945. /**
  33946. * Sorts the list list based on light priorities
  33947. */
  33948. sortLightsByPriority(): void;
  33949. /**
  33950. * Adds the given camera to this scene
  33951. * @param newCamera The camera to add
  33952. */
  33953. addCamera(newCamera: Camera): void;
  33954. /**
  33955. * Adds the given skeleton to this scene
  33956. * @param newSkeleton The skeleton to add
  33957. */
  33958. addSkeleton(newSkeleton: Skeleton): void;
  33959. /**
  33960. * Adds the given particle system to this scene
  33961. * @param newParticleSystem The particle system to add
  33962. */
  33963. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33964. /**
  33965. * Adds the given animation to this scene
  33966. * @param newAnimation The animation to add
  33967. */
  33968. addAnimation(newAnimation: Animation): void;
  33969. /**
  33970. * Adds the given animation group to this scene.
  33971. * @param newAnimationGroup The animation group to add
  33972. */
  33973. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33974. /**
  33975. * Adds the given multi-material to this scene
  33976. * @param newMultiMaterial The multi-material to add
  33977. */
  33978. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33979. /**
  33980. * Adds the given material to this scene
  33981. * @param newMaterial The material to add
  33982. */
  33983. addMaterial(newMaterial: Material): void;
  33984. /**
  33985. * Adds the given morph target to this scene
  33986. * @param newMorphTargetManager The morph target to add
  33987. */
  33988. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33989. /**
  33990. * Adds the given geometry to this scene
  33991. * @param newGeometry The geometry to add
  33992. */
  33993. addGeometry(newGeometry: Geometry): void;
  33994. /**
  33995. * Adds the given action manager to this scene
  33996. * @param newActionManager The action manager to add
  33997. */
  33998. addActionManager(newActionManager: AbstractActionManager): void;
  33999. /**
  34000. * Adds the given texture to this scene.
  34001. * @param newTexture The texture to add
  34002. */
  34003. addTexture(newTexture: BaseTexture): void;
  34004. /**
  34005. * Switch active camera
  34006. * @param newCamera defines the new active camera
  34007. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34008. */
  34009. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34010. /**
  34011. * sets the active camera of the scene using its ID
  34012. * @param id defines the camera's ID
  34013. * @return the new active camera or null if none found.
  34014. */
  34015. setActiveCameraByID(id: string): Nullable<Camera>;
  34016. /**
  34017. * sets the active camera of the scene using its name
  34018. * @param name defines the camera's name
  34019. * @returns the new active camera or null if none found.
  34020. */
  34021. setActiveCameraByName(name: string): Nullable<Camera>;
  34022. /**
  34023. * get an animation group using its name
  34024. * @param name defines the material's name
  34025. * @return the animation group or null if none found.
  34026. */
  34027. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34028. /**
  34029. * Get a material using its unique id
  34030. * @param uniqueId defines the material's unique id
  34031. * @return the material or null if none found.
  34032. */
  34033. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34034. /**
  34035. * get a material using its id
  34036. * @param id defines the material's ID
  34037. * @return the material or null if none found.
  34038. */
  34039. getMaterialByID(id: string): Nullable<Material>;
  34040. /**
  34041. * Gets a material using its name
  34042. * @param name defines the material's name
  34043. * @return the material or null if none found.
  34044. */
  34045. getMaterialByName(name: string): Nullable<Material>;
  34046. /**
  34047. * Gets a camera using its id
  34048. * @param id defines the id to look for
  34049. * @returns the camera or null if not found
  34050. */
  34051. getCameraByID(id: string): Nullable<Camera>;
  34052. /**
  34053. * Gets a camera using its unique id
  34054. * @param uniqueId defines the unique id to look for
  34055. * @returns the camera or null if not found
  34056. */
  34057. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34058. /**
  34059. * Gets a camera using its name
  34060. * @param name defines the camera's name
  34061. * @return the camera or null if none found.
  34062. */
  34063. getCameraByName(name: string): Nullable<Camera>;
  34064. /**
  34065. * Gets a bone using its id
  34066. * @param id defines the bone's id
  34067. * @return the bone or null if not found
  34068. */
  34069. getBoneByID(id: string): Nullable<Bone>;
  34070. /**
  34071. * Gets a bone using its id
  34072. * @param name defines the bone's name
  34073. * @return the bone or null if not found
  34074. */
  34075. getBoneByName(name: string): Nullable<Bone>;
  34076. /**
  34077. * Gets a light node using its name
  34078. * @param name defines the the light's name
  34079. * @return the light or null if none found.
  34080. */
  34081. getLightByName(name: string): Nullable<Light>;
  34082. /**
  34083. * Gets a light node using its id
  34084. * @param id defines the light's id
  34085. * @return the light or null if none found.
  34086. */
  34087. getLightByID(id: string): Nullable<Light>;
  34088. /**
  34089. * Gets a light node using its scene-generated unique ID
  34090. * @param uniqueId defines the light's unique id
  34091. * @return the light or null if none found.
  34092. */
  34093. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34094. /**
  34095. * Gets a particle system by id
  34096. * @param id defines the particle system id
  34097. * @return the corresponding system or null if none found
  34098. */
  34099. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34100. /**
  34101. * Gets a geometry using its ID
  34102. * @param id defines the geometry's id
  34103. * @return the geometry or null if none found.
  34104. */
  34105. getGeometryByID(id: string): Nullable<Geometry>;
  34106. private _getGeometryByUniqueID;
  34107. /**
  34108. * Add a new geometry to this scene
  34109. * @param geometry defines the geometry to be added to the scene.
  34110. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34111. * @return a boolean defining if the geometry was added or not
  34112. */
  34113. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34114. /**
  34115. * Removes an existing geometry
  34116. * @param geometry defines the geometry to be removed from the scene
  34117. * @return a boolean defining if the geometry was removed or not
  34118. */
  34119. removeGeometry(geometry: Geometry): boolean;
  34120. /**
  34121. * Gets the list of geometries attached to the scene
  34122. * @returns an array of Geometry
  34123. */
  34124. getGeometries(): Geometry[];
  34125. /**
  34126. * Gets the first added mesh found of a given ID
  34127. * @param id defines the id to search for
  34128. * @return the mesh found or null if not found at all
  34129. */
  34130. getMeshByID(id: string): Nullable<AbstractMesh>;
  34131. /**
  34132. * Gets a list of meshes using their id
  34133. * @param id defines the id to search for
  34134. * @returns a list of meshes
  34135. */
  34136. getMeshesByID(id: string): Array<AbstractMesh>;
  34137. /**
  34138. * Gets the first added transform node found of a given ID
  34139. * @param id defines the id to search for
  34140. * @return the found transform node or null if not found at all.
  34141. */
  34142. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34143. /**
  34144. * Gets a transform node with its auto-generated unique id
  34145. * @param uniqueId efines the unique id to search for
  34146. * @return the found transform node or null if not found at all.
  34147. */
  34148. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34149. /**
  34150. * Gets a list of transform nodes using their id
  34151. * @param id defines the id to search for
  34152. * @returns a list of transform nodes
  34153. */
  34154. getTransformNodesByID(id: string): Array<TransformNode>;
  34155. /**
  34156. * Gets a mesh with its auto-generated unique id
  34157. * @param uniqueId defines the unique id to search for
  34158. * @return the found mesh or null if not found at all.
  34159. */
  34160. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34161. /**
  34162. * Gets a the last added mesh using a given id
  34163. * @param id defines the id to search for
  34164. * @return the found mesh or null if not found at all.
  34165. */
  34166. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34167. /**
  34168. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34169. * @param id defines the id to search for
  34170. * @return the found node or null if not found at all
  34171. */
  34172. getLastEntryByID(id: string): Nullable<Node>;
  34173. /**
  34174. * Gets a node (Mesh, Camera, Light) using a given id
  34175. * @param id defines the id to search for
  34176. * @return the found node or null if not found at all
  34177. */
  34178. getNodeByID(id: string): Nullable<Node>;
  34179. /**
  34180. * Gets a node (Mesh, Camera, Light) using a given name
  34181. * @param name defines the name to search for
  34182. * @return the found node or null if not found at all.
  34183. */
  34184. getNodeByName(name: string): Nullable<Node>;
  34185. /**
  34186. * Gets a mesh using a given name
  34187. * @param name defines the name to search for
  34188. * @return the found mesh or null if not found at all.
  34189. */
  34190. getMeshByName(name: string): Nullable<AbstractMesh>;
  34191. /**
  34192. * Gets a transform node using a given name
  34193. * @param name defines the name to search for
  34194. * @return the found transform node or null if not found at all.
  34195. */
  34196. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34197. /**
  34198. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34199. * @param id defines the id to search for
  34200. * @return the found skeleton or null if not found at all.
  34201. */
  34202. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34203. /**
  34204. * Gets a skeleton using a given auto generated unique id
  34205. * @param uniqueId defines the unique id to search for
  34206. * @return the found skeleton or null if not found at all.
  34207. */
  34208. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34209. /**
  34210. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34211. * @param id defines the id to search for
  34212. * @return the found skeleton or null if not found at all.
  34213. */
  34214. getSkeletonById(id: string): Nullable<Skeleton>;
  34215. /**
  34216. * Gets a skeleton using a given name
  34217. * @param name defines the name to search for
  34218. * @return the found skeleton or null if not found at all.
  34219. */
  34220. getSkeletonByName(name: string): Nullable<Skeleton>;
  34221. /**
  34222. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34223. * @param id defines the id to search for
  34224. * @return the found morph target manager or null if not found at all.
  34225. */
  34226. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34227. /**
  34228. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34229. * @param id defines the id to search for
  34230. * @return the found morph target or null if not found at all.
  34231. */
  34232. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34233. /**
  34234. * Gets a boolean indicating if the given mesh is active
  34235. * @param mesh defines the mesh to look for
  34236. * @returns true if the mesh is in the active list
  34237. */
  34238. isActiveMesh(mesh: AbstractMesh): boolean;
  34239. /**
  34240. * Return a unique id as a string which can serve as an identifier for the scene
  34241. */
  34242. readonly uid: string;
  34243. /**
  34244. * Add an externaly attached data from its key.
  34245. * This method call will fail and return false, if such key already exists.
  34246. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34247. * @param key the unique key that identifies the data
  34248. * @param data the data object to associate to the key for this Engine instance
  34249. * @return true if no such key were already present and the data was added successfully, false otherwise
  34250. */
  34251. addExternalData<T>(key: string, data: T): boolean;
  34252. /**
  34253. * Get an externaly attached data from its key
  34254. * @param key the unique key that identifies the data
  34255. * @return the associated data, if present (can be null), or undefined if not present
  34256. */
  34257. getExternalData<T>(key: string): Nullable<T>;
  34258. /**
  34259. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34260. * @param key the unique key that identifies the data
  34261. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34262. * @return the associated data, can be null if the factory returned null.
  34263. */
  34264. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34265. /**
  34266. * Remove an externaly attached data from the Engine instance
  34267. * @param key the unique key that identifies the data
  34268. * @return true if the data was successfully removed, false if it doesn't exist
  34269. */
  34270. removeExternalData(key: string): boolean;
  34271. private _evaluateSubMesh;
  34272. /**
  34273. * Clear the processed materials smart array preventing retention point in material dispose.
  34274. */
  34275. freeProcessedMaterials(): void;
  34276. private _preventFreeActiveMeshesAndRenderingGroups;
  34277. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34278. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34279. * when disposing several meshes in a row or a hierarchy of meshes.
  34280. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34281. */
  34282. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34283. /**
  34284. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34285. */
  34286. freeActiveMeshes(): void;
  34287. /**
  34288. * Clear the info related to rendering groups preventing retention points during dispose.
  34289. */
  34290. freeRenderingGroups(): void;
  34291. /** @hidden */
  34292. _isInIntermediateRendering(): boolean;
  34293. /**
  34294. * Lambda returning the list of potentially active meshes.
  34295. */
  34296. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34297. /**
  34298. * Lambda returning the list of potentially active sub meshes.
  34299. */
  34300. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34301. /**
  34302. * Lambda returning the list of potentially intersecting sub meshes.
  34303. */
  34304. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34305. /**
  34306. * Lambda returning the list of potentially colliding sub meshes.
  34307. */
  34308. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34309. private _activeMeshesFrozen;
  34310. /**
  34311. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34312. * @returns the current scene
  34313. */
  34314. freezeActiveMeshes(): Scene;
  34315. /**
  34316. * Use this function to restart evaluating active meshes on every frame
  34317. * @returns the current scene
  34318. */
  34319. unfreezeActiveMeshes(): Scene;
  34320. private _evaluateActiveMeshes;
  34321. private _activeMesh;
  34322. /**
  34323. * Update the transform matrix to update from the current active camera
  34324. * @param force defines a boolean used to force the update even if cache is up to date
  34325. */
  34326. updateTransformMatrix(force?: boolean): void;
  34327. private _bindFrameBuffer;
  34328. /** @hidden */
  34329. _allowPostProcessClearColor: boolean;
  34330. /** @hidden */
  34331. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34332. private _processSubCameras;
  34333. private _checkIntersections;
  34334. /** @hidden */
  34335. _advancePhysicsEngineStep(step: number): void;
  34336. /**
  34337. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34338. */
  34339. getDeterministicFrameTime: () => number;
  34340. /** @hidden */
  34341. _animate(): void;
  34342. /** Execute all animations (for a frame) */
  34343. animate(): void;
  34344. /**
  34345. * Render the scene
  34346. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34347. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34348. */
  34349. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34350. /**
  34351. * Freeze all materials
  34352. * A frozen material will not be updatable but should be faster to render
  34353. */
  34354. freezeMaterials(): void;
  34355. /**
  34356. * Unfreeze all materials
  34357. * A frozen material will not be updatable but should be faster to render
  34358. */
  34359. unfreezeMaterials(): void;
  34360. /**
  34361. * Releases all held ressources
  34362. */
  34363. dispose(): void;
  34364. /**
  34365. * Gets if the scene is already disposed
  34366. */
  34367. readonly isDisposed: boolean;
  34368. /**
  34369. * Call this function to reduce memory footprint of the scene.
  34370. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34371. */
  34372. clearCachedVertexData(): void;
  34373. /**
  34374. * This function will remove the local cached buffer data from texture.
  34375. * It will save memory but will prevent the texture from being rebuilt
  34376. */
  34377. cleanCachedTextureBuffer(): void;
  34378. /**
  34379. * Get the world extend vectors with an optional filter
  34380. *
  34381. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34382. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34383. */
  34384. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34385. min: Vector3;
  34386. max: Vector3;
  34387. };
  34388. /**
  34389. * Creates a ray that can be used to pick in the scene
  34390. * @param x defines the x coordinate of the origin (on-screen)
  34391. * @param y defines the y coordinate of the origin (on-screen)
  34392. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34393. * @param camera defines the camera to use for the picking
  34394. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34395. * @returns a Ray
  34396. */
  34397. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34398. /**
  34399. * Creates a ray that can be used to pick in the scene
  34400. * @param x defines the x coordinate of the origin (on-screen)
  34401. * @param y defines the y coordinate of the origin (on-screen)
  34402. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34403. * @param result defines the ray where to store the picking ray
  34404. * @param camera defines the camera to use for the picking
  34405. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34406. * @returns the current scene
  34407. */
  34408. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34409. /**
  34410. * Creates a ray that can be used to pick in the scene
  34411. * @param x defines the x coordinate of the origin (on-screen)
  34412. * @param y defines the y coordinate of the origin (on-screen)
  34413. * @param camera defines the camera to use for the picking
  34414. * @returns a Ray
  34415. */
  34416. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  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 result defines the ray where to store the picking ray
  34422. * @param camera defines the camera to use for the picking
  34423. * @returns the current scene
  34424. */
  34425. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34426. /** Launch a ray to try to pick a mesh in the scene
  34427. * @param x position on screen
  34428. * @param y position on screen
  34429. * @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
  34430. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34431. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34432. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34433. * @returns a PickingInfo
  34434. */
  34435. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34436. /** Use the given ray to pick a mesh in the scene
  34437. * @param ray The ray to use to pick meshes
  34438. * @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
  34439. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34440. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34441. * @returns a PickingInfo
  34442. */
  34443. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34444. /**
  34445. * Launch a ray to try to pick a mesh in the scene
  34446. * @param x X position on screen
  34447. * @param y Y position on screen
  34448. * @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
  34449. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34450. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34451. * @returns an array of PickingInfo
  34452. */
  34453. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34454. /**
  34455. * Launch a ray to try to pick a mesh in the scene
  34456. * @param ray Ray to use
  34457. * @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
  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. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34462. /**
  34463. * Force the value of meshUnderPointer
  34464. * @param mesh defines the mesh to use
  34465. */
  34466. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34467. /**
  34468. * Gets the mesh under the pointer
  34469. * @returns a Mesh or null if no mesh is under the pointer
  34470. */
  34471. getPointerOverMesh(): Nullable<AbstractMesh>;
  34472. /** @hidden */
  34473. _rebuildGeometries(): void;
  34474. /** @hidden */
  34475. _rebuildTextures(): void;
  34476. private _getByTags;
  34477. /**
  34478. * Get a list of meshes by tags
  34479. * @param tagsQuery defines the tags query to use
  34480. * @param forEach defines a predicate used to filter results
  34481. * @returns an array of Mesh
  34482. */
  34483. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34484. /**
  34485. * Get a list of cameras by tags
  34486. * @param tagsQuery defines the tags query to use
  34487. * @param forEach defines a predicate used to filter results
  34488. * @returns an array of Camera
  34489. */
  34490. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34491. /**
  34492. * Get a list of lights by tags
  34493. * @param tagsQuery defines the tags query to use
  34494. * @param forEach defines a predicate used to filter results
  34495. * @returns an array of Light
  34496. */
  34497. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34498. /**
  34499. * Get a list of materials by tags
  34500. * @param tagsQuery defines the tags query to use
  34501. * @param forEach defines a predicate used to filter results
  34502. * @returns an array of Material
  34503. */
  34504. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34505. /**
  34506. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34507. * This allowed control for front to back rendering or reversly depending of the special needs.
  34508. *
  34509. * @param renderingGroupId The rendering group id corresponding to its index
  34510. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34511. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34512. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34513. */
  34514. 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;
  34515. /**
  34516. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34517. *
  34518. * @param renderingGroupId The rendering group id corresponding to its index
  34519. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34520. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34521. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34522. */
  34523. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34524. /**
  34525. * Gets the current auto clear configuration for one rendering group of the rendering
  34526. * manager.
  34527. * @param index the rendering group index to get the information for
  34528. * @returns The auto clear setup for the requested rendering group
  34529. */
  34530. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34531. private _blockMaterialDirtyMechanism;
  34532. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34533. blockMaterialDirtyMechanism: boolean;
  34534. /**
  34535. * Will flag all materials as dirty to trigger new shader compilation
  34536. * @param flag defines the flag used to specify which material part must be marked as dirty
  34537. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34538. */
  34539. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34540. /** @hidden */
  34541. _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;
  34542. /** @hidden */
  34543. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34544. }
  34545. }
  34546. declare module "babylonjs/assetContainer" {
  34547. import { AbstractScene } from "babylonjs/abstractScene";
  34548. import { Scene } from "babylonjs/scene";
  34549. import { Mesh } from "babylonjs/Meshes/mesh";
  34550. /**
  34551. * Set of assets to keep when moving a scene into an asset container.
  34552. */
  34553. export class KeepAssets extends AbstractScene {
  34554. }
  34555. /**
  34556. * Container with a set of assets that can be added or removed from a scene.
  34557. */
  34558. export class AssetContainer extends AbstractScene {
  34559. /**
  34560. * The scene the AssetContainer belongs to.
  34561. */
  34562. scene: Scene;
  34563. /**
  34564. * Instantiates an AssetContainer.
  34565. * @param scene The scene the AssetContainer belongs to.
  34566. */
  34567. constructor(scene: Scene);
  34568. /**
  34569. * Adds all the assets from the container to the scene.
  34570. */
  34571. addAllToScene(): void;
  34572. /**
  34573. * Removes all the assets in the container from the scene
  34574. */
  34575. removeAllFromScene(): void;
  34576. /**
  34577. * Disposes all the assets in the container
  34578. */
  34579. dispose(): void;
  34580. private _moveAssets;
  34581. /**
  34582. * Removes all the assets contained in the scene and adds them to the container.
  34583. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34584. */
  34585. moveAllFromScene(keepAssets?: KeepAssets): void;
  34586. /**
  34587. * 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.
  34588. * @returns the root mesh
  34589. */
  34590. createRootMesh(): Mesh;
  34591. }
  34592. }
  34593. declare module "babylonjs/abstractScene" {
  34594. import { Scene } from "babylonjs/scene";
  34595. import { Nullable } from "babylonjs/types";
  34596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34597. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34598. import { Geometry } from "babylonjs/Meshes/geometry";
  34599. import { Skeleton } from "babylonjs/Bones/skeleton";
  34600. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34601. import { AssetContainer } from "babylonjs/assetContainer";
  34602. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34603. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34605. import { Material } from "babylonjs/Materials/material";
  34606. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34607. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34608. import { Camera } from "babylonjs/Cameras/camera";
  34609. import { Light } from "babylonjs/Lights/light";
  34610. import { Node } from "babylonjs/node";
  34611. import { Animation } from "babylonjs/Animations/animation";
  34612. /**
  34613. * Defines how the parser contract is defined.
  34614. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34615. */
  34616. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34617. /**
  34618. * Defines how the individual parser contract is defined.
  34619. * These parser can parse an individual asset
  34620. */
  34621. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34622. /**
  34623. * Base class of the scene acting as a container for the different elements composing a scene.
  34624. * This class is dynamically extended by the different components of the scene increasing
  34625. * flexibility and reducing coupling
  34626. */
  34627. export abstract class AbstractScene {
  34628. /**
  34629. * Stores the list of available parsers in the application.
  34630. */
  34631. private static _BabylonFileParsers;
  34632. /**
  34633. * Stores the list of available individual parsers in the application.
  34634. */
  34635. private static _IndividualBabylonFileParsers;
  34636. /**
  34637. * Adds a parser in the list of available ones
  34638. * @param name Defines the name of the parser
  34639. * @param parser Defines the parser to add
  34640. */
  34641. static AddParser(name: string, parser: BabylonFileParser): void;
  34642. /**
  34643. * Gets a general parser from the list of avaialble ones
  34644. * @param name Defines the name of the parser
  34645. * @returns the requested parser or null
  34646. */
  34647. static GetParser(name: string): Nullable<BabylonFileParser>;
  34648. /**
  34649. * Adds n individual parser in the list of available ones
  34650. * @param name Defines the name of the parser
  34651. * @param parser Defines the parser to add
  34652. */
  34653. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34654. /**
  34655. * Gets an individual parser from the list of avaialble ones
  34656. * @param name Defines the name of the parser
  34657. * @returns the requested parser or null
  34658. */
  34659. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34660. /**
  34661. * Parser json data and populate both a scene and its associated container object
  34662. * @param jsonData Defines the data to parse
  34663. * @param scene Defines the scene to parse the data for
  34664. * @param container Defines the container attached to the parsing sequence
  34665. * @param rootUrl Defines the root url of the data
  34666. */
  34667. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34668. /**
  34669. * Gets the list of root nodes (ie. nodes with no parent)
  34670. */
  34671. rootNodes: Node[];
  34672. /** All of the cameras added to this scene
  34673. * @see http://doc.babylonjs.com/babylon101/cameras
  34674. */
  34675. cameras: Camera[];
  34676. /**
  34677. * All of the lights added to this scene
  34678. * @see http://doc.babylonjs.com/babylon101/lights
  34679. */
  34680. lights: Light[];
  34681. /**
  34682. * All of the (abstract) meshes added to this scene
  34683. */
  34684. meshes: AbstractMesh[];
  34685. /**
  34686. * The list of skeletons added to the scene
  34687. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34688. */
  34689. skeletons: Skeleton[];
  34690. /**
  34691. * All of the particle systems added to this scene
  34692. * @see http://doc.babylonjs.com/babylon101/particles
  34693. */
  34694. particleSystems: IParticleSystem[];
  34695. /**
  34696. * Gets a list of Animations associated with the scene
  34697. */
  34698. animations: Animation[];
  34699. /**
  34700. * All of the animation groups added to this scene
  34701. * @see http://doc.babylonjs.com/how_to/group
  34702. */
  34703. animationGroups: AnimationGroup[];
  34704. /**
  34705. * All of the multi-materials added to this scene
  34706. * @see http://doc.babylonjs.com/how_to/multi_materials
  34707. */
  34708. multiMaterials: MultiMaterial[];
  34709. /**
  34710. * All of the materials added to this scene
  34711. * In the context of a Scene, it is not supposed to be modified manually.
  34712. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34713. * Note also that the order of the Material wihin the array is not significant and might change.
  34714. * @see http://doc.babylonjs.com/babylon101/materials
  34715. */
  34716. materials: Material[];
  34717. /**
  34718. * The list of morph target managers added to the scene
  34719. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34720. */
  34721. morphTargetManagers: MorphTargetManager[];
  34722. /**
  34723. * The list of geometries used in the scene.
  34724. */
  34725. geometries: Geometry[];
  34726. /**
  34727. * All of the tranform nodes added to this scene
  34728. * In the context of a Scene, it is not supposed to be modified manually.
  34729. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34730. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34731. * @see http://doc.babylonjs.com/how_to/transformnode
  34732. */
  34733. transformNodes: TransformNode[];
  34734. /**
  34735. * ActionManagers available on the scene.
  34736. */
  34737. actionManagers: AbstractActionManager[];
  34738. /**
  34739. * Textures to keep.
  34740. */
  34741. textures: BaseTexture[];
  34742. /**
  34743. * Environment texture for the scene
  34744. */
  34745. environmentTexture: Nullable<BaseTexture>;
  34746. }
  34747. }
  34748. declare module "babylonjs/Audio/sound" {
  34749. import { Observable } from "babylonjs/Misc/observable";
  34750. import { Vector3 } from "babylonjs/Maths/math";
  34751. import { Nullable } from "babylonjs/types";
  34752. import { Scene } from "babylonjs/scene";
  34753. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34754. /**
  34755. * Defines a sound that can be played in the application.
  34756. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34758. */
  34759. export class Sound {
  34760. /**
  34761. * The name of the sound in the scene.
  34762. */
  34763. name: string;
  34764. /**
  34765. * Does the sound autoplay once loaded.
  34766. */
  34767. autoplay: boolean;
  34768. /**
  34769. * Does the sound loop after it finishes playing once.
  34770. */
  34771. loop: boolean;
  34772. /**
  34773. * Does the sound use a custom attenuation curve to simulate the falloff
  34774. * happening when the source gets further away from the camera.
  34775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34776. */
  34777. useCustomAttenuation: boolean;
  34778. /**
  34779. * The sound track id this sound belongs to.
  34780. */
  34781. soundTrackId: number;
  34782. /**
  34783. * Is this sound currently played.
  34784. */
  34785. isPlaying: boolean;
  34786. /**
  34787. * Is this sound currently paused.
  34788. */
  34789. isPaused: boolean;
  34790. /**
  34791. * Does this sound enables spatial sound.
  34792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34793. */
  34794. spatialSound: boolean;
  34795. /**
  34796. * Define the reference distance the sound should be heard perfectly.
  34797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34798. */
  34799. refDistance: number;
  34800. /**
  34801. * Define the roll off factor of spatial sounds.
  34802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34803. */
  34804. rolloffFactor: number;
  34805. /**
  34806. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34808. */
  34809. maxDistance: number;
  34810. /**
  34811. * Define the distance attenuation model the sound will follow.
  34812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34813. */
  34814. distanceModel: string;
  34815. /**
  34816. * @hidden
  34817. * Back Compat
  34818. **/
  34819. onended: () => any;
  34820. /**
  34821. * Observable event when the current playing sound finishes.
  34822. */
  34823. onEndedObservable: Observable<Sound>;
  34824. private _panningModel;
  34825. private _playbackRate;
  34826. private _streaming;
  34827. private _startTime;
  34828. private _startOffset;
  34829. private _position;
  34830. /** @hidden */
  34831. _positionInEmitterSpace: boolean;
  34832. private _localDirection;
  34833. private _volume;
  34834. private _isReadyToPlay;
  34835. private _isDirectional;
  34836. private _readyToPlayCallback;
  34837. private _audioBuffer;
  34838. private _soundSource;
  34839. private _streamingSource;
  34840. private _soundPanner;
  34841. private _soundGain;
  34842. private _inputAudioNode;
  34843. private _outputAudioNode;
  34844. private _coneInnerAngle;
  34845. private _coneOuterAngle;
  34846. private _coneOuterGain;
  34847. private _scene;
  34848. private _connectedTransformNode;
  34849. private _customAttenuationFunction;
  34850. private _registerFunc;
  34851. private _isOutputConnected;
  34852. private _htmlAudioElement;
  34853. private _urlType;
  34854. /** @hidden */
  34855. static _SceneComponentInitialization: (scene: Scene) => void;
  34856. /**
  34857. * Create a sound and attach it to a scene
  34858. * @param name Name of your sound
  34859. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34860. * @param scene defines the scene the sound belongs to
  34861. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34862. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34863. */
  34864. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34865. /**
  34866. * Release the sound and its associated resources
  34867. */
  34868. dispose(): void;
  34869. /**
  34870. * Gets if the sounds is ready to be played or not.
  34871. * @returns true if ready, otherwise false
  34872. */
  34873. isReady(): boolean;
  34874. private _soundLoaded;
  34875. /**
  34876. * Sets the data of the sound from an audiobuffer
  34877. * @param audioBuffer The audioBuffer containing the data
  34878. */
  34879. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34880. /**
  34881. * Updates the current sounds options such as maxdistance, loop...
  34882. * @param options A JSON object containing values named as the object properties
  34883. */
  34884. updateOptions(options: any): void;
  34885. private _createSpatialParameters;
  34886. private _updateSpatialParameters;
  34887. /**
  34888. * Switch the panning model to HRTF:
  34889. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34891. */
  34892. switchPanningModelToHRTF(): void;
  34893. /**
  34894. * Switch the panning model to Equal Power:
  34895. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34897. */
  34898. switchPanningModelToEqualPower(): void;
  34899. private _switchPanningModel;
  34900. /**
  34901. * Connect this sound to a sound track audio node like gain...
  34902. * @param soundTrackAudioNode the sound track audio node to connect to
  34903. */
  34904. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34905. /**
  34906. * Transform this sound into a directional source
  34907. * @param coneInnerAngle Size of the inner cone in degree
  34908. * @param coneOuterAngle Size of the outer cone in degree
  34909. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34910. */
  34911. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34912. /**
  34913. * Gets or sets the inner angle for the directional cone.
  34914. */
  34915. /**
  34916. * Gets or sets the inner angle for the directional cone.
  34917. */
  34918. directionalConeInnerAngle: number;
  34919. /**
  34920. * Gets or sets the outer angle for the directional cone.
  34921. */
  34922. /**
  34923. * Gets or sets the outer angle for the directional cone.
  34924. */
  34925. directionalConeOuterAngle: number;
  34926. /**
  34927. * Sets the position of the emitter if spatial sound is enabled
  34928. * @param newPosition Defines the new posisiton
  34929. */
  34930. setPosition(newPosition: Vector3): void;
  34931. /**
  34932. * Sets the local direction of the emitter if spatial sound is enabled
  34933. * @param newLocalDirection Defines the new local direction
  34934. */
  34935. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34936. private _updateDirection;
  34937. /** @hidden */
  34938. updateDistanceFromListener(): void;
  34939. /**
  34940. * Sets a new custom attenuation function for the sound.
  34941. * @param callback Defines the function used for the attenuation
  34942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34943. */
  34944. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34945. /**
  34946. * Play the sound
  34947. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34948. * @param offset (optional) Start the sound setting it at a specific time
  34949. */
  34950. play(time?: number, offset?: number): void;
  34951. private _onended;
  34952. /**
  34953. * Stop the sound
  34954. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34955. */
  34956. stop(time?: number): void;
  34957. /**
  34958. * Put the sound in pause
  34959. */
  34960. pause(): void;
  34961. /**
  34962. * Sets a dedicated volume for this sounds
  34963. * @param newVolume Define the new volume of the sound
  34964. * @param time Define in how long the sound should be at this value
  34965. */
  34966. setVolume(newVolume: number, time?: number): void;
  34967. /**
  34968. * Set the sound play back rate
  34969. * @param newPlaybackRate Define the playback rate the sound should be played at
  34970. */
  34971. setPlaybackRate(newPlaybackRate: number): void;
  34972. /**
  34973. * Gets the volume of the sound.
  34974. * @returns the volume of the sound
  34975. */
  34976. getVolume(): number;
  34977. /**
  34978. * Attach the sound to a dedicated mesh
  34979. * @param transformNode The transform node to connect the sound with
  34980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34981. */
  34982. attachToMesh(transformNode: TransformNode): void;
  34983. /**
  34984. * Detach the sound from the previously attached mesh
  34985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34986. */
  34987. detachFromMesh(): void;
  34988. private _onRegisterAfterWorldMatrixUpdate;
  34989. /**
  34990. * Clone the current sound in the scene.
  34991. * @returns the new sound clone
  34992. */
  34993. clone(): Nullable<Sound>;
  34994. /**
  34995. * Gets the current underlying audio buffer containing the data
  34996. * @returns the audio buffer
  34997. */
  34998. getAudioBuffer(): Nullable<AudioBuffer>;
  34999. /**
  35000. * Serializes the Sound in a JSON representation
  35001. * @returns the JSON representation of the sound
  35002. */
  35003. serialize(): any;
  35004. /**
  35005. * Parse a JSON representation of a sound to innstantiate in a given scene
  35006. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35007. * @param scene Define the scene the new parsed sound should be created in
  35008. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35009. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35010. * @returns the newly parsed sound
  35011. */
  35012. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35013. }
  35014. }
  35015. declare module "babylonjs/Actions/directAudioActions" {
  35016. import { Action } from "babylonjs/Actions/action";
  35017. import { Condition } from "babylonjs/Actions/condition";
  35018. import { Sound } from "babylonjs/Audio/sound";
  35019. /**
  35020. * This defines an action helpful to play a defined sound on a triggered action.
  35021. */
  35022. export class PlaySoundAction extends Action {
  35023. private _sound;
  35024. /**
  35025. * Instantiate the action
  35026. * @param triggerOptions defines the trigger options
  35027. * @param sound defines the sound to play
  35028. * @param condition defines the trigger related conditions
  35029. */
  35030. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35031. /** @hidden */
  35032. _prepare(): void;
  35033. /**
  35034. * Execute the action and play the sound.
  35035. */
  35036. execute(): void;
  35037. /**
  35038. * Serializes the actions and its related information.
  35039. * @param parent defines the object to serialize in
  35040. * @returns the serialized object
  35041. */
  35042. serialize(parent: any): any;
  35043. }
  35044. /**
  35045. * This defines an action helpful to stop a defined sound on a triggered action.
  35046. */
  35047. export class StopSoundAction extends Action {
  35048. private _sound;
  35049. /**
  35050. * Instantiate the action
  35051. * @param triggerOptions defines the trigger options
  35052. * @param sound defines the sound to stop
  35053. * @param condition defines the trigger related conditions
  35054. */
  35055. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35056. /** @hidden */
  35057. _prepare(): void;
  35058. /**
  35059. * Execute the action and stop the sound.
  35060. */
  35061. execute(): void;
  35062. /**
  35063. * Serializes the actions and its related information.
  35064. * @param parent defines the object to serialize in
  35065. * @returns the serialized object
  35066. */
  35067. serialize(parent: any): any;
  35068. }
  35069. }
  35070. declare module "babylonjs/Actions/interpolateValueAction" {
  35071. import { Action } from "babylonjs/Actions/action";
  35072. import { Condition } from "babylonjs/Actions/condition";
  35073. import { Observable } from "babylonjs/Misc/observable";
  35074. /**
  35075. * This defines an action responsible to change the value of a property
  35076. * by interpolating between its current value and the newly set one once triggered.
  35077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35078. */
  35079. export class InterpolateValueAction extends Action {
  35080. /**
  35081. * Defines the path of the property where the value should be interpolated
  35082. */
  35083. propertyPath: string;
  35084. /**
  35085. * Defines the target value at the end of the interpolation.
  35086. */
  35087. value: any;
  35088. /**
  35089. * Defines the time it will take for the property to interpolate to the value.
  35090. */
  35091. duration: number;
  35092. /**
  35093. * Defines if the other scene animations should be stopped when the action has been triggered
  35094. */
  35095. stopOtherAnimations?: boolean;
  35096. /**
  35097. * Defines a callback raised once the interpolation animation has been done.
  35098. */
  35099. onInterpolationDone?: () => void;
  35100. /**
  35101. * Observable triggered once the interpolation animation has been done.
  35102. */
  35103. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35104. private _target;
  35105. private _effectiveTarget;
  35106. private _property;
  35107. /**
  35108. * Instantiate the action
  35109. * @param triggerOptions defines the trigger options
  35110. * @param target defines the object containing the value to interpolate
  35111. * @param propertyPath defines the path to the property in the target object
  35112. * @param value defines the target value at the end of the interpolation
  35113. * @param duration deines the time it will take for the property to interpolate to the value.
  35114. * @param condition defines the trigger related conditions
  35115. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35116. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35117. */
  35118. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35119. /** @hidden */
  35120. _prepare(): void;
  35121. /**
  35122. * Execute the action starts the value interpolation.
  35123. */
  35124. execute(): void;
  35125. /**
  35126. * Serializes the actions and its related information.
  35127. * @param parent defines the object to serialize in
  35128. * @returns the serialized object
  35129. */
  35130. serialize(parent: any): any;
  35131. }
  35132. }
  35133. declare module "babylonjs/Actions/index" {
  35134. export * from "babylonjs/Actions/action";
  35135. export * from "babylonjs/Actions/actionEvent";
  35136. export * from "babylonjs/Actions/actionManager";
  35137. export * from "babylonjs/Actions/condition";
  35138. export * from "babylonjs/Actions/directActions";
  35139. export * from "babylonjs/Actions/directAudioActions";
  35140. export * from "babylonjs/Actions/interpolateValueAction";
  35141. }
  35142. declare module "babylonjs/Animations/index" {
  35143. export * from "babylonjs/Animations/animatable";
  35144. export * from "babylonjs/Animations/animation";
  35145. export * from "babylonjs/Animations/animationGroup";
  35146. export * from "babylonjs/Animations/animationPropertiesOverride";
  35147. export * from "babylonjs/Animations/easing";
  35148. export * from "babylonjs/Animations/runtimeAnimation";
  35149. export * from "babylonjs/Animations/animationEvent";
  35150. export * from "babylonjs/Animations/animationGroup";
  35151. export * from "babylonjs/Animations/animationKey";
  35152. export * from "babylonjs/Animations/animationRange";
  35153. }
  35154. declare module "babylonjs/Audio/soundTrack" {
  35155. import { Sound } from "babylonjs/Audio/sound";
  35156. import { Analyser } from "babylonjs/Audio/analyser";
  35157. import { Scene } from "babylonjs/scene";
  35158. /**
  35159. * Options allowed during the creation of a sound track.
  35160. */
  35161. export interface ISoundTrackOptions {
  35162. /**
  35163. * The volume the sound track should take during creation
  35164. */
  35165. volume?: number;
  35166. /**
  35167. * Define if the sound track is the main sound track of the scene
  35168. */
  35169. mainTrack?: boolean;
  35170. }
  35171. /**
  35172. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35173. * It will be also used in a future release to apply effects on a specific track.
  35174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35175. */
  35176. export class SoundTrack {
  35177. /**
  35178. * The unique identifier of the sound track in the scene.
  35179. */
  35180. id: number;
  35181. /**
  35182. * The list of sounds included in the sound track.
  35183. */
  35184. soundCollection: Array<Sound>;
  35185. private _outputAudioNode;
  35186. private _scene;
  35187. private _isMainTrack;
  35188. private _connectedAnalyser;
  35189. private _options;
  35190. private _isInitialized;
  35191. /**
  35192. * Creates a new sound track.
  35193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35194. * @param scene Define the scene the sound track belongs to
  35195. * @param options
  35196. */
  35197. constructor(scene: Scene, options?: ISoundTrackOptions);
  35198. private _initializeSoundTrackAudioGraph;
  35199. /**
  35200. * Release the sound track and its associated resources
  35201. */
  35202. dispose(): void;
  35203. /**
  35204. * Adds a sound to this sound track
  35205. * @param sound define the cound to add
  35206. * @ignoreNaming
  35207. */
  35208. AddSound(sound: Sound): void;
  35209. /**
  35210. * Removes a sound to this sound track
  35211. * @param sound define the cound to remove
  35212. * @ignoreNaming
  35213. */
  35214. RemoveSound(sound: Sound): void;
  35215. /**
  35216. * Set a global volume for the full sound track.
  35217. * @param newVolume Define the new volume of the sound track
  35218. */
  35219. setVolume(newVolume: number): void;
  35220. /**
  35221. * Switch the panning model to HRTF:
  35222. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35224. */
  35225. switchPanningModelToHRTF(): void;
  35226. /**
  35227. * Switch the panning model to Equal Power:
  35228. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35230. */
  35231. switchPanningModelToEqualPower(): void;
  35232. /**
  35233. * Connect the sound track to an audio analyser allowing some amazing
  35234. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35236. * @param analyser The analyser to connect to the engine
  35237. */
  35238. connectToAnalyser(analyser: Analyser): void;
  35239. }
  35240. }
  35241. declare module "babylonjs/Audio/audioSceneComponent" {
  35242. import { Sound } from "babylonjs/Audio/sound";
  35243. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35244. import { Nullable } from "babylonjs/types";
  35245. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35246. import { Scene } from "babylonjs/scene";
  35247. import { AbstractScene } from "babylonjs/abstractScene";
  35248. module "babylonjs/abstractScene" {
  35249. interface AbstractScene {
  35250. /**
  35251. * The list of sounds used in the scene.
  35252. */
  35253. sounds: Nullable<Array<Sound>>;
  35254. }
  35255. }
  35256. module "babylonjs/scene" {
  35257. interface Scene {
  35258. /**
  35259. * @hidden
  35260. * Backing field
  35261. */
  35262. _mainSoundTrack: SoundTrack;
  35263. /**
  35264. * The main sound track played by the scene.
  35265. * It cotains your primary collection of sounds.
  35266. */
  35267. mainSoundTrack: SoundTrack;
  35268. /**
  35269. * The list of sound tracks added to the scene
  35270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35271. */
  35272. soundTracks: Nullable<Array<SoundTrack>>;
  35273. /**
  35274. * Gets a sound using a given name
  35275. * @param name defines the name to search for
  35276. * @return the found sound or null if not found at all.
  35277. */
  35278. getSoundByName(name: string): Nullable<Sound>;
  35279. /**
  35280. * Gets or sets if audio support is enabled
  35281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35282. */
  35283. audioEnabled: boolean;
  35284. /**
  35285. * Gets or sets if audio will be output to headphones
  35286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35287. */
  35288. headphone: boolean;
  35289. }
  35290. }
  35291. /**
  35292. * Defines the sound scene component responsible to manage any sounds
  35293. * in a given scene.
  35294. */
  35295. export class AudioSceneComponent implements ISceneSerializableComponent {
  35296. /**
  35297. * The component name helpfull to identify the component in the list of scene components.
  35298. */
  35299. readonly name: string;
  35300. /**
  35301. * The scene the component belongs to.
  35302. */
  35303. scene: Scene;
  35304. private _audioEnabled;
  35305. /**
  35306. * Gets whether audio is enabled or not.
  35307. * Please use related enable/disable method to switch state.
  35308. */
  35309. readonly audioEnabled: boolean;
  35310. private _headphone;
  35311. /**
  35312. * Gets whether audio is outputing to headphone or not.
  35313. * Please use the according Switch methods to change output.
  35314. */
  35315. readonly headphone: boolean;
  35316. /**
  35317. * Creates a new instance of the component for the given scene
  35318. * @param scene Defines the scene to register the component in
  35319. */
  35320. constructor(scene: Scene);
  35321. /**
  35322. * Registers the component in a given scene
  35323. */
  35324. register(): void;
  35325. /**
  35326. * Rebuilds the elements related to this component in case of
  35327. * context lost for instance.
  35328. */
  35329. rebuild(): void;
  35330. /**
  35331. * Serializes the component data to the specified json object
  35332. * @param serializationObject The object to serialize to
  35333. */
  35334. serialize(serializationObject: any): void;
  35335. /**
  35336. * Adds all the element from the container to the scene
  35337. * @param container the container holding the elements
  35338. */
  35339. addFromContainer(container: AbstractScene): void;
  35340. /**
  35341. * Removes all the elements in the container from the scene
  35342. * @param container contains the elements to remove
  35343. * @param dispose if the removed element should be disposed (default: false)
  35344. */
  35345. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35346. /**
  35347. * Disposes the component and the associated ressources.
  35348. */
  35349. dispose(): void;
  35350. /**
  35351. * Disables audio in the associated scene.
  35352. */
  35353. disableAudio(): void;
  35354. /**
  35355. * Enables audio in the associated scene.
  35356. */
  35357. enableAudio(): void;
  35358. /**
  35359. * Switch audio to headphone output.
  35360. */
  35361. switchAudioModeForHeadphones(): void;
  35362. /**
  35363. * Switch audio to normal speakers.
  35364. */
  35365. switchAudioModeForNormalSpeakers(): void;
  35366. private _afterRender;
  35367. }
  35368. }
  35369. declare module "babylonjs/Audio/weightedsound" {
  35370. import { Sound } from "babylonjs/Audio/sound";
  35371. /**
  35372. * Wraps one or more Sound objects and selects one with random weight for playback.
  35373. */
  35374. export class WeightedSound {
  35375. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35376. loop: boolean;
  35377. private _coneInnerAngle;
  35378. private _coneOuterAngle;
  35379. private _volume;
  35380. /** A Sound is currently playing. */
  35381. isPlaying: boolean;
  35382. /** A Sound is currently paused. */
  35383. isPaused: boolean;
  35384. private _sounds;
  35385. private _weights;
  35386. private _currentIndex?;
  35387. /**
  35388. * Creates a new WeightedSound from the list of sounds given.
  35389. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35390. * @param sounds Array of Sounds that will be selected from.
  35391. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35392. */
  35393. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35394. /**
  35395. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35396. */
  35397. /**
  35398. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35399. */
  35400. directionalConeInnerAngle: number;
  35401. /**
  35402. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35403. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35404. */
  35405. /**
  35406. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35407. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35408. */
  35409. directionalConeOuterAngle: number;
  35410. /**
  35411. * Playback volume.
  35412. */
  35413. /**
  35414. * Playback volume.
  35415. */
  35416. volume: number;
  35417. private _onended;
  35418. /**
  35419. * Suspend playback
  35420. */
  35421. pause(): void;
  35422. /**
  35423. * Stop playback
  35424. */
  35425. stop(): void;
  35426. /**
  35427. * Start playback.
  35428. * @param startOffset Position the clip head at a specific time in seconds.
  35429. */
  35430. play(startOffset?: number): void;
  35431. }
  35432. }
  35433. declare module "babylonjs/Audio/index" {
  35434. export * from "babylonjs/Audio/analyser";
  35435. export * from "babylonjs/Audio/audioEngine";
  35436. export * from "babylonjs/Audio/audioSceneComponent";
  35437. export * from "babylonjs/Audio/sound";
  35438. export * from "babylonjs/Audio/soundTrack";
  35439. export * from "babylonjs/Audio/weightedsound";
  35440. }
  35441. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35442. import { Behavior } from "babylonjs/Behaviors/behavior";
  35443. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35444. import { BackEase } from "babylonjs/Animations/easing";
  35445. /**
  35446. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35447. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35448. */
  35449. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35450. /**
  35451. * Gets the name of the behavior.
  35452. */
  35453. readonly name: string;
  35454. /**
  35455. * The easing function used by animations
  35456. */
  35457. static EasingFunction: BackEase;
  35458. /**
  35459. * The easing mode used by animations
  35460. */
  35461. static EasingMode: number;
  35462. /**
  35463. * The duration of the animation, in milliseconds
  35464. */
  35465. transitionDuration: number;
  35466. /**
  35467. * Length of the distance animated by the transition when lower radius is reached
  35468. */
  35469. lowerRadiusTransitionRange: number;
  35470. /**
  35471. * Length of the distance animated by the transition when upper radius is reached
  35472. */
  35473. upperRadiusTransitionRange: number;
  35474. private _autoTransitionRange;
  35475. /**
  35476. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35477. */
  35478. /**
  35479. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35480. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35481. */
  35482. autoTransitionRange: boolean;
  35483. private _attachedCamera;
  35484. private _onAfterCheckInputsObserver;
  35485. private _onMeshTargetChangedObserver;
  35486. /**
  35487. * Initializes the behavior.
  35488. */
  35489. init(): void;
  35490. /**
  35491. * Attaches the behavior to its arc rotate camera.
  35492. * @param camera Defines the camera to attach the behavior to
  35493. */
  35494. attach(camera: ArcRotateCamera): void;
  35495. /**
  35496. * Detaches the behavior from its current arc rotate camera.
  35497. */
  35498. detach(): void;
  35499. private _radiusIsAnimating;
  35500. private _radiusBounceTransition;
  35501. private _animatables;
  35502. private _cachedWheelPrecision;
  35503. /**
  35504. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35505. * @param radiusLimit The limit to check against.
  35506. * @return Bool to indicate if at limit.
  35507. */
  35508. private _isRadiusAtLimit;
  35509. /**
  35510. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35511. * @param radiusDelta The delta by which to animate to. Can be negative.
  35512. */
  35513. private _applyBoundRadiusAnimation;
  35514. /**
  35515. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35516. */
  35517. protected _clearAnimationLocks(): void;
  35518. /**
  35519. * Stops and removes all animations that have been applied to the camera
  35520. */
  35521. stopAllAnimations(): void;
  35522. }
  35523. }
  35524. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35525. import { Behavior } from "babylonjs/Behaviors/behavior";
  35526. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35527. import { ExponentialEase } from "babylonjs/Animations/easing";
  35528. import { Nullable } from "babylonjs/types";
  35529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35530. import { Vector3 } from "babylonjs/Maths/math";
  35531. /**
  35532. * 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.
  35533. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35534. */
  35535. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35536. /**
  35537. * Gets the name of the behavior.
  35538. */
  35539. readonly name: string;
  35540. private _mode;
  35541. private _radiusScale;
  35542. private _positionScale;
  35543. private _defaultElevation;
  35544. private _elevationReturnTime;
  35545. private _elevationReturnWaitTime;
  35546. private _zoomStopsAnimation;
  35547. private _framingTime;
  35548. /**
  35549. * The easing function used by animations
  35550. */
  35551. static EasingFunction: ExponentialEase;
  35552. /**
  35553. * The easing mode used by animations
  35554. */
  35555. static EasingMode: number;
  35556. /**
  35557. * Sets the current mode used by the behavior
  35558. */
  35559. /**
  35560. * Gets current mode used by the behavior.
  35561. */
  35562. mode: number;
  35563. /**
  35564. * Sets the scale applied to the radius (1 by default)
  35565. */
  35566. /**
  35567. * Gets the scale applied to the radius
  35568. */
  35569. radiusScale: number;
  35570. /**
  35571. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35572. */
  35573. /**
  35574. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35575. */
  35576. positionScale: number;
  35577. /**
  35578. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35579. * behaviour is triggered, in radians.
  35580. */
  35581. /**
  35582. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35583. * behaviour is triggered, in radians.
  35584. */
  35585. defaultElevation: number;
  35586. /**
  35587. * Sets the time (in milliseconds) taken to return to the default beta position.
  35588. * Negative value indicates camera should not return to default.
  35589. */
  35590. /**
  35591. * Gets the time (in milliseconds) taken to return to the default beta position.
  35592. * Negative value indicates camera should not return to default.
  35593. */
  35594. elevationReturnTime: number;
  35595. /**
  35596. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35597. */
  35598. /**
  35599. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35600. */
  35601. elevationReturnWaitTime: number;
  35602. /**
  35603. * Sets the flag that indicates if user zooming should stop animation.
  35604. */
  35605. /**
  35606. * Gets the flag that indicates if user zooming should stop animation.
  35607. */
  35608. zoomStopsAnimation: boolean;
  35609. /**
  35610. * Sets the transition time when framing the mesh, in milliseconds
  35611. */
  35612. /**
  35613. * Gets the transition time when framing the mesh, in milliseconds
  35614. */
  35615. framingTime: number;
  35616. /**
  35617. * Define if the behavior should automatically change the configured
  35618. * camera limits and sensibilities.
  35619. */
  35620. autoCorrectCameraLimitsAndSensibility: boolean;
  35621. private _onPrePointerObservableObserver;
  35622. private _onAfterCheckInputsObserver;
  35623. private _onMeshTargetChangedObserver;
  35624. private _attachedCamera;
  35625. private _isPointerDown;
  35626. private _lastInteractionTime;
  35627. /**
  35628. * Initializes the behavior.
  35629. */
  35630. init(): void;
  35631. /**
  35632. * Attaches the behavior to its arc rotate camera.
  35633. * @param camera Defines the camera to attach the behavior to
  35634. */
  35635. attach(camera: ArcRotateCamera): void;
  35636. /**
  35637. * Detaches the behavior from its current arc rotate camera.
  35638. */
  35639. detach(): void;
  35640. private _animatables;
  35641. private _betaIsAnimating;
  35642. private _betaTransition;
  35643. private _radiusTransition;
  35644. private _vectorTransition;
  35645. /**
  35646. * Targets the given mesh and updates zoom level accordingly.
  35647. * @param mesh The mesh to target.
  35648. * @param radius Optional. If a cached radius position already exists, overrides default.
  35649. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35650. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35651. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35652. */
  35653. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35654. /**
  35655. * Targets the given mesh with its children and updates zoom level accordingly.
  35656. * @param mesh The mesh to target.
  35657. * @param radius Optional. If a cached radius position already exists, overrides default.
  35658. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35659. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35660. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35661. */
  35662. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35663. /**
  35664. * Targets the given meshes with their children and updates zoom level accordingly.
  35665. * @param meshes The mesh to target.
  35666. * @param radius Optional. If a cached radius position already exists, overrides default.
  35667. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35668. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35669. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35670. */
  35671. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35672. /**
  35673. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35674. * @param minimumWorld Determines the smaller position of the bounding box extend
  35675. * @param maximumWorld Determines the bigger position of the bounding box extend
  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. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35680. /**
  35681. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35682. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35683. * frustum width.
  35684. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35685. * to fully enclose the mesh in the viewing frustum.
  35686. */
  35687. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35688. /**
  35689. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35690. * is automatically returned to its default position (expected to be above ground plane).
  35691. */
  35692. private _maintainCameraAboveGround;
  35693. /**
  35694. * Returns the frustum slope based on the canvas ratio and camera FOV
  35695. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35696. */
  35697. private _getFrustumSlope;
  35698. /**
  35699. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35700. */
  35701. private _clearAnimationLocks;
  35702. /**
  35703. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35704. */
  35705. private _applyUserInteraction;
  35706. /**
  35707. * Stops and removes all animations that have been applied to the camera
  35708. */
  35709. stopAllAnimations(): void;
  35710. /**
  35711. * Gets a value indicating if the user is moving the camera
  35712. */
  35713. readonly isUserIsMoving: boolean;
  35714. /**
  35715. * The camera can move all the way towards the mesh.
  35716. */
  35717. static IgnoreBoundsSizeMode: number;
  35718. /**
  35719. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35720. */
  35721. static FitFrustumSidesMode: number;
  35722. }
  35723. }
  35724. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35725. import { Nullable } from "babylonjs/types";
  35726. import { Camera } from "babylonjs/Cameras/camera";
  35727. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35728. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35729. /**
  35730. * Base class for Camera Pointer Inputs.
  35731. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35732. * for example usage.
  35733. */
  35734. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35735. /**
  35736. * Defines the camera the input is attached to.
  35737. */
  35738. abstract camera: Camera;
  35739. /**
  35740. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35741. */
  35742. protected _altKey: boolean;
  35743. protected _ctrlKey: boolean;
  35744. protected _metaKey: boolean;
  35745. protected _shiftKey: boolean;
  35746. /**
  35747. * Which mouse buttons were pressed at time of last mouse event.
  35748. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35749. */
  35750. protected _buttonsPressed: number;
  35751. /**
  35752. * Defines the buttons associated with the input to handle camera move.
  35753. */
  35754. buttons: number[];
  35755. /**
  35756. * Attach the input controls to a specific dom element to get the input from.
  35757. * @param element Defines the element the controls should be listened from
  35758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35759. */
  35760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35761. /**
  35762. * Detach the current controls from the specified dom element.
  35763. * @param element Defines the element to stop listening the inputs from
  35764. */
  35765. detachControl(element: Nullable<HTMLElement>): void;
  35766. /**
  35767. * Gets the class name of the current input.
  35768. * @returns the class name
  35769. */
  35770. getClassName(): string;
  35771. /**
  35772. * Get the friendly name associated with the input class.
  35773. * @returns the input friendly name
  35774. */
  35775. getSimpleName(): string;
  35776. /**
  35777. * Called on pointer POINTERDOUBLETAP event.
  35778. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35779. */
  35780. protected onDoubleTap(type: string): void;
  35781. /**
  35782. * Called on pointer POINTERMOVE event if only a single touch is active.
  35783. * Override this method to provide functionality.
  35784. */
  35785. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35786. /**
  35787. * Called on pointer POINTERMOVE event if multiple touches are active.
  35788. * Override this method to provide functionality.
  35789. */
  35790. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35791. /**
  35792. * Called on JS contextmenu event.
  35793. * Override this method to provide functionality.
  35794. */
  35795. protected onContextMenu(evt: PointerEvent): void;
  35796. /**
  35797. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35798. * press.
  35799. * Override this method to provide functionality.
  35800. */
  35801. protected onButtonDown(evt: PointerEvent): void;
  35802. /**
  35803. * Called each time a new POINTERUP event occurs. Ie, for each button
  35804. * release.
  35805. * Override this method to provide functionality.
  35806. */
  35807. protected onButtonUp(evt: PointerEvent): void;
  35808. /**
  35809. * Called when window becomes inactive.
  35810. * Override this method to provide functionality.
  35811. */
  35812. protected onLostFocus(): void;
  35813. private _pointerInput;
  35814. private _observer;
  35815. private _onLostFocus;
  35816. private pointA;
  35817. private pointB;
  35818. }
  35819. }
  35820. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35821. import { Nullable } from "babylonjs/types";
  35822. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35823. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35824. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35825. /**
  35826. * Manage the pointers inputs to control an arc rotate camera.
  35827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35828. */
  35829. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35830. /**
  35831. * Defines the camera the input is attached to.
  35832. */
  35833. camera: ArcRotateCamera;
  35834. /**
  35835. * Gets the class name of the current input.
  35836. * @returns the class name
  35837. */
  35838. getClassName(): string;
  35839. /**
  35840. * Defines the buttons associated with the input to handle camera move.
  35841. */
  35842. buttons: number[];
  35843. /**
  35844. * Defines the pointer angular sensibility along the X axis or how fast is
  35845. * the camera rotating.
  35846. */
  35847. angularSensibilityX: number;
  35848. /**
  35849. * Defines the pointer angular sensibility along the Y axis or how fast is
  35850. * the camera rotating.
  35851. */
  35852. angularSensibilityY: number;
  35853. /**
  35854. * Defines the pointer pinch precision or how fast is the camera zooming.
  35855. */
  35856. pinchPrecision: number;
  35857. /**
  35858. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35859. * from 0.
  35860. * It defines the percentage of current camera.radius to use as delta when
  35861. * pinch zoom is used.
  35862. */
  35863. pinchDeltaPercentage: number;
  35864. /**
  35865. * Defines the pointer panning sensibility or how fast is the camera moving.
  35866. */
  35867. panningSensibility: number;
  35868. /**
  35869. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35870. */
  35871. multiTouchPanning: boolean;
  35872. /**
  35873. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35874. * zoom (pinch) through multitouch.
  35875. */
  35876. multiTouchPanAndZoom: boolean;
  35877. /**
  35878. * Revers pinch action direction.
  35879. */
  35880. pinchInwards: boolean;
  35881. private _isPanClick;
  35882. private _twoFingerActivityCount;
  35883. private _isPinching;
  35884. /**
  35885. * Called on pointer POINTERMOVE event if only a single touch is active.
  35886. */
  35887. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35888. /**
  35889. * Called on pointer POINTERDOUBLETAP event.
  35890. */
  35891. protected onDoubleTap(type: string): void;
  35892. /**
  35893. * Called on pointer POINTERMOVE event if multiple touches are active.
  35894. */
  35895. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35896. /**
  35897. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35898. * press.
  35899. */
  35900. protected onButtonDown(evt: PointerEvent): void;
  35901. /**
  35902. * Called each time a new POINTERUP event occurs. Ie, for each button
  35903. * release.
  35904. */
  35905. protected onButtonUp(evt: PointerEvent): void;
  35906. /**
  35907. * Called when window becomes inactive.
  35908. */
  35909. protected onLostFocus(): void;
  35910. }
  35911. }
  35912. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35913. import { Nullable } from "babylonjs/types";
  35914. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35915. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35916. /**
  35917. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35918. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35919. */
  35920. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35921. /**
  35922. * Defines the camera the input is attached to.
  35923. */
  35924. camera: ArcRotateCamera;
  35925. /**
  35926. * Defines the list of key codes associated with the up action (increase alpha)
  35927. */
  35928. keysUp: number[];
  35929. /**
  35930. * Defines the list of key codes associated with the down action (decrease alpha)
  35931. */
  35932. keysDown: number[];
  35933. /**
  35934. * Defines the list of key codes associated with the left action (increase beta)
  35935. */
  35936. keysLeft: number[];
  35937. /**
  35938. * Defines the list of key codes associated with the right action (decrease beta)
  35939. */
  35940. keysRight: number[];
  35941. /**
  35942. * Defines the list of key codes associated with the reset action.
  35943. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35944. */
  35945. keysReset: number[];
  35946. /**
  35947. * Defines the panning sensibility of the inputs.
  35948. * (How fast is the camera paning)
  35949. */
  35950. panningSensibility: number;
  35951. /**
  35952. * Defines the zooming sensibility of the inputs.
  35953. * (How fast is the camera zooming)
  35954. */
  35955. zoomingSensibility: number;
  35956. /**
  35957. * Defines wether maintaining the alt key down switch the movement mode from
  35958. * orientation to zoom.
  35959. */
  35960. useAltToZoom: boolean;
  35961. /**
  35962. * Rotation speed of the camera
  35963. */
  35964. angularSpeed: number;
  35965. private _keys;
  35966. private _ctrlPressed;
  35967. private _altPressed;
  35968. private _onCanvasBlurObserver;
  35969. private _onKeyboardObserver;
  35970. private _engine;
  35971. private _scene;
  35972. /**
  35973. * Attach the input controls to a specific dom element to get the input from.
  35974. * @param element Defines the element the controls should be listened from
  35975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35976. */
  35977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35978. /**
  35979. * Detach the current controls from the specified dom element.
  35980. * @param element Defines the element to stop listening the inputs from
  35981. */
  35982. detachControl(element: Nullable<HTMLElement>): void;
  35983. /**
  35984. * Update the current camera state depending on the inputs that have been used this frame.
  35985. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35986. */
  35987. checkInputs(): void;
  35988. /**
  35989. * Gets the class name of the current intput.
  35990. * @returns the class name
  35991. */
  35992. getClassName(): string;
  35993. /**
  35994. * Get the friendly name associated with the input class.
  35995. * @returns the input friendly name
  35996. */
  35997. getSimpleName(): string;
  35998. }
  35999. }
  36000. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36001. import { Nullable } from "babylonjs/types";
  36002. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36003. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36004. /**
  36005. * Manage the mouse wheel inputs to control an arc rotate camera.
  36006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36007. */
  36008. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36009. /**
  36010. * Defines the camera the input is attached to.
  36011. */
  36012. camera: ArcRotateCamera;
  36013. /**
  36014. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36015. */
  36016. wheelPrecision: number;
  36017. /**
  36018. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36019. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36020. */
  36021. wheelDeltaPercentage: number;
  36022. private _wheel;
  36023. private _observer;
  36024. private computeDeltaFromMouseWheelLegacyEvent;
  36025. /**
  36026. * Attach the input controls to a specific dom element to get the input from.
  36027. * @param element Defines the element the controls should be listened from
  36028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36029. */
  36030. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36031. /**
  36032. * Detach the current controls from the specified dom element.
  36033. * @param element Defines the element to stop listening the inputs from
  36034. */
  36035. detachControl(element: Nullable<HTMLElement>): void;
  36036. /**
  36037. * Gets the class name of the current intput.
  36038. * @returns the class name
  36039. */
  36040. getClassName(): string;
  36041. /**
  36042. * Get the friendly name associated with the input class.
  36043. * @returns the input friendly name
  36044. */
  36045. getSimpleName(): string;
  36046. }
  36047. }
  36048. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36049. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36050. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36051. /**
  36052. * Default Inputs manager for the ArcRotateCamera.
  36053. * It groups all the default supported inputs for ease of use.
  36054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36055. */
  36056. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36057. /**
  36058. * Instantiates a new ArcRotateCameraInputsManager.
  36059. * @param camera Defines the camera the inputs belong to
  36060. */
  36061. constructor(camera: ArcRotateCamera);
  36062. /**
  36063. * Add mouse wheel input support to the input manager.
  36064. * @returns the current input manager
  36065. */
  36066. addMouseWheel(): ArcRotateCameraInputsManager;
  36067. /**
  36068. * Add pointers input support to the input manager.
  36069. * @returns the current input manager
  36070. */
  36071. addPointers(): ArcRotateCameraInputsManager;
  36072. /**
  36073. * Add keyboard input support to the input manager.
  36074. * @returns the current input manager
  36075. */
  36076. addKeyboard(): ArcRotateCameraInputsManager;
  36077. }
  36078. }
  36079. declare module "babylonjs/Cameras/arcRotateCamera" {
  36080. import { Observable } from "babylonjs/Misc/observable";
  36081. import { Nullable } from "babylonjs/types";
  36082. import { Scene } from "babylonjs/scene";
  36083. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36085. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36086. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36087. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36088. import { Camera } from "babylonjs/Cameras/camera";
  36089. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36090. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36091. import { Collider } from "babylonjs/Collisions/collider";
  36092. /**
  36093. * This represents an orbital type of camera.
  36094. *
  36095. * 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.
  36096. * 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.
  36097. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36098. */
  36099. export class ArcRotateCamera extends TargetCamera {
  36100. /**
  36101. * Defines the rotation angle of the camera along the longitudinal axis.
  36102. */
  36103. alpha: number;
  36104. /**
  36105. * Defines the rotation angle of the camera along the latitudinal axis.
  36106. */
  36107. beta: number;
  36108. /**
  36109. * Defines the radius of the camera from it s target point.
  36110. */
  36111. radius: number;
  36112. protected _target: Vector3;
  36113. protected _targetHost: Nullable<AbstractMesh>;
  36114. /**
  36115. * Defines the target point of the camera.
  36116. * The camera looks towards it form the radius distance.
  36117. */
  36118. target: Vector3;
  36119. /**
  36120. * Define the current local position of the camera in the scene
  36121. */
  36122. position: Vector3;
  36123. protected _upVector: Vector3;
  36124. protected _upToYMatrix: Matrix;
  36125. protected _YToUpMatrix: Matrix;
  36126. /**
  36127. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36128. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36129. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36130. */
  36131. upVector: Vector3;
  36132. /**
  36133. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36134. */
  36135. setMatUp(): void;
  36136. /**
  36137. * Current inertia value on the longitudinal axis.
  36138. * The bigger this number the longer it will take for the camera to stop.
  36139. */
  36140. inertialAlphaOffset: number;
  36141. /**
  36142. * Current inertia value on the latitudinal axis.
  36143. * The bigger this number the longer it will take for the camera to stop.
  36144. */
  36145. inertialBetaOffset: number;
  36146. /**
  36147. * Current inertia value on the radius axis.
  36148. * The bigger this number the longer it will take for the camera to stop.
  36149. */
  36150. inertialRadiusOffset: number;
  36151. /**
  36152. * Minimum allowed angle on the longitudinal axis.
  36153. * This can help limiting how the Camera is able to move in the scene.
  36154. */
  36155. lowerAlphaLimit: Nullable<number>;
  36156. /**
  36157. * Maximum allowed angle on the longitudinal axis.
  36158. * This can help limiting how the Camera is able to move in the scene.
  36159. */
  36160. upperAlphaLimit: Nullable<number>;
  36161. /**
  36162. * Minimum allowed angle on the latitudinal axis.
  36163. * This can help limiting how the Camera is able to move in the scene.
  36164. */
  36165. lowerBetaLimit: number;
  36166. /**
  36167. * Maximum allowed angle on the latitudinal axis.
  36168. * This can help limiting how the Camera is able to move in the scene.
  36169. */
  36170. upperBetaLimit: number;
  36171. /**
  36172. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36173. * This can help limiting how the Camera is able to move in the scene.
  36174. */
  36175. lowerRadiusLimit: Nullable<number>;
  36176. /**
  36177. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36178. * This can help limiting how the Camera is able to move in the scene.
  36179. */
  36180. upperRadiusLimit: Nullable<number>;
  36181. /**
  36182. * Defines the current inertia value used during panning of the camera along the X axis.
  36183. */
  36184. inertialPanningX: number;
  36185. /**
  36186. * Defines the current inertia value used during panning of the camera along the Y axis.
  36187. */
  36188. inertialPanningY: number;
  36189. /**
  36190. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36191. * Basically if your fingers moves away from more than this distance you will be considered
  36192. * in pinch mode.
  36193. */
  36194. pinchToPanMaxDistance: number;
  36195. /**
  36196. * Defines the maximum distance the camera can pan.
  36197. * This could help keeping the cammera always in your scene.
  36198. */
  36199. panningDistanceLimit: Nullable<number>;
  36200. /**
  36201. * Defines the target of the camera before paning.
  36202. */
  36203. panningOriginTarget: Vector3;
  36204. /**
  36205. * Defines the value of the inertia used during panning.
  36206. * 0 would mean stop inertia and one would mean no decelleration at all.
  36207. */
  36208. panningInertia: number;
  36209. /**
  36210. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36211. */
  36212. angularSensibilityX: number;
  36213. /**
  36214. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36215. */
  36216. angularSensibilityY: number;
  36217. /**
  36218. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36219. */
  36220. pinchPrecision: number;
  36221. /**
  36222. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36223. * It will be used instead of pinchDeltaPrecision if different from 0.
  36224. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36225. */
  36226. pinchDeltaPercentage: number;
  36227. /**
  36228. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36229. */
  36230. panningSensibility: number;
  36231. /**
  36232. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36233. */
  36234. keysUp: number[];
  36235. /**
  36236. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36237. */
  36238. keysDown: number[];
  36239. /**
  36240. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36241. */
  36242. keysLeft: number[];
  36243. /**
  36244. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36245. */
  36246. keysRight: number[];
  36247. /**
  36248. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36249. */
  36250. wheelPrecision: number;
  36251. /**
  36252. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36253. * It will be used instead of pinchDeltaPrecision if different from 0.
  36254. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36255. */
  36256. wheelDeltaPercentage: number;
  36257. /**
  36258. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36259. */
  36260. zoomOnFactor: number;
  36261. /**
  36262. * Defines a screen offset for the camera position.
  36263. */
  36264. targetScreenOffset: Vector2;
  36265. /**
  36266. * Allows the camera to be completely reversed.
  36267. * If false the camera can not arrive upside down.
  36268. */
  36269. allowUpsideDown: boolean;
  36270. /**
  36271. * Define if double tap/click is used to restore the previously saved state of the camera.
  36272. */
  36273. useInputToRestoreState: boolean;
  36274. /** @hidden */
  36275. _viewMatrix: Matrix;
  36276. /** @hidden */
  36277. _useCtrlForPanning: boolean;
  36278. /** @hidden */
  36279. _panningMouseButton: number;
  36280. /**
  36281. * Defines the input associated to the camera.
  36282. */
  36283. inputs: ArcRotateCameraInputsManager;
  36284. /** @hidden */
  36285. _reset: () => void;
  36286. /**
  36287. * Defines the allowed panning axis.
  36288. */
  36289. panningAxis: Vector3;
  36290. protected _localDirection: Vector3;
  36291. protected _transformedDirection: Vector3;
  36292. private _bouncingBehavior;
  36293. /**
  36294. * Gets the bouncing behavior of the camera if it has been enabled.
  36295. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36296. */
  36297. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36298. /**
  36299. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36300. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36301. */
  36302. useBouncingBehavior: boolean;
  36303. private _framingBehavior;
  36304. /**
  36305. * Gets the framing behavior of the camera if it has been enabled.
  36306. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36307. */
  36308. readonly framingBehavior: Nullable<FramingBehavior>;
  36309. /**
  36310. * Defines if the framing behavior of the camera is enabled on the camera.
  36311. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36312. */
  36313. useFramingBehavior: boolean;
  36314. private _autoRotationBehavior;
  36315. /**
  36316. * Gets the auto rotation behavior of the camera if it has been enabled.
  36317. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36318. */
  36319. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36320. /**
  36321. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36322. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36323. */
  36324. useAutoRotationBehavior: boolean;
  36325. /**
  36326. * Observable triggered when the mesh target has been changed on the camera.
  36327. */
  36328. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36329. /**
  36330. * Event raised when the camera is colliding with a mesh.
  36331. */
  36332. onCollide: (collidedMesh: AbstractMesh) => void;
  36333. /**
  36334. * Defines whether the camera should check collision with the objects oh the scene.
  36335. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36336. */
  36337. checkCollisions: boolean;
  36338. /**
  36339. * Defines the collision radius of the camera.
  36340. * This simulates a sphere around the camera.
  36341. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36342. */
  36343. collisionRadius: Vector3;
  36344. protected _collider: Collider;
  36345. protected _previousPosition: Vector3;
  36346. protected _collisionVelocity: Vector3;
  36347. protected _newPosition: Vector3;
  36348. protected _previousAlpha: number;
  36349. protected _previousBeta: number;
  36350. protected _previousRadius: number;
  36351. protected _collisionTriggered: boolean;
  36352. protected _targetBoundingCenter: Nullable<Vector3>;
  36353. private _computationVector;
  36354. /**
  36355. * Instantiates a new ArcRotateCamera in a given scene
  36356. * @param name Defines the name of the camera
  36357. * @param alpha Defines the camera rotation along the logitudinal axis
  36358. * @param beta Defines the camera rotation along the latitudinal axis
  36359. * @param radius Defines the camera distance from its target
  36360. * @param target Defines the camera target
  36361. * @param scene Defines the scene the camera belongs to
  36362. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36363. */
  36364. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36365. /** @hidden */
  36366. _initCache(): void;
  36367. /** @hidden */
  36368. _updateCache(ignoreParentClass?: boolean): void;
  36369. protected _getTargetPosition(): Vector3;
  36370. private _storedAlpha;
  36371. private _storedBeta;
  36372. private _storedRadius;
  36373. private _storedTarget;
  36374. /**
  36375. * Stores the current state of the camera (alpha, beta, radius and target)
  36376. * @returns the camera itself
  36377. */
  36378. storeState(): Camera;
  36379. /**
  36380. * @hidden
  36381. * Restored camera state. You must call storeState() first
  36382. */
  36383. _restoreStateValues(): boolean;
  36384. /** @hidden */
  36385. _isSynchronizedViewMatrix(): boolean;
  36386. /**
  36387. * Attached controls to the current camera.
  36388. * @param element Defines the element the controls should be listened from
  36389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36390. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36391. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36392. */
  36393. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36394. /**
  36395. * Detach the current controls from the camera.
  36396. * The camera will stop reacting to inputs.
  36397. * @param element Defines the element to stop listening the inputs from
  36398. */
  36399. detachControl(element: HTMLElement): void;
  36400. /** @hidden */
  36401. _checkInputs(): void;
  36402. protected _checkLimits(): void;
  36403. /**
  36404. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36405. */
  36406. rebuildAnglesAndRadius(): void;
  36407. /**
  36408. * Use a position to define the current camera related information like aplha, beta and radius
  36409. * @param position Defines the position to set the camera at
  36410. */
  36411. setPosition(position: Vector3): void;
  36412. /**
  36413. * Defines the target the camera should look at.
  36414. * This will automatically adapt alpha beta and radius to fit within the new target.
  36415. * @param target Defines the new target as a Vector or a mesh
  36416. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36417. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36418. */
  36419. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36420. /** @hidden */
  36421. _getViewMatrix(): Matrix;
  36422. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36423. /**
  36424. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36425. * @param meshes Defines the mesh to zoom on
  36426. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  36427. */
  36428. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36429. /**
  36430. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36431. * The target will be changed but the radius
  36432. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36433. * @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)
  36434. */
  36435. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36436. min: Vector3;
  36437. max: Vector3;
  36438. distance: number;
  36439. }, doNotUpdateMaxZ?: boolean): void;
  36440. /**
  36441. * @override
  36442. * Override Camera.createRigCamera
  36443. */
  36444. createRigCamera(name: string, cameraIndex: number): Camera;
  36445. /**
  36446. * @hidden
  36447. * @override
  36448. * Override Camera._updateRigCameras
  36449. */
  36450. _updateRigCameras(): void;
  36451. /**
  36452. * Destroy the camera and release the current resources hold by it.
  36453. */
  36454. dispose(): void;
  36455. /**
  36456. * Gets the current object class name.
  36457. * @return the class name
  36458. */
  36459. getClassName(): string;
  36460. }
  36461. }
  36462. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36463. import { Behavior } from "babylonjs/Behaviors/behavior";
  36464. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36465. /**
  36466. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36467. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36468. */
  36469. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36470. /**
  36471. * Gets the name of the behavior.
  36472. */
  36473. readonly name: string;
  36474. private _zoomStopsAnimation;
  36475. private _idleRotationSpeed;
  36476. private _idleRotationWaitTime;
  36477. private _idleRotationSpinupTime;
  36478. /**
  36479. * Sets the flag that indicates if user zooming should stop animation.
  36480. */
  36481. /**
  36482. * Gets the flag that indicates if user zooming should stop animation.
  36483. */
  36484. zoomStopsAnimation: boolean;
  36485. /**
  36486. * Sets the default speed at which the camera rotates around the model.
  36487. */
  36488. /**
  36489. * Gets the default speed at which the camera rotates around the model.
  36490. */
  36491. idleRotationSpeed: number;
  36492. /**
  36493. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36494. */
  36495. /**
  36496. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36497. */
  36498. idleRotationWaitTime: number;
  36499. /**
  36500. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36501. */
  36502. /**
  36503. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36504. */
  36505. idleRotationSpinupTime: number;
  36506. /**
  36507. * Gets a value indicating if the camera is currently rotating because of this behavior
  36508. */
  36509. readonly rotationInProgress: boolean;
  36510. private _onPrePointerObservableObserver;
  36511. private _onAfterCheckInputsObserver;
  36512. private _attachedCamera;
  36513. private _isPointerDown;
  36514. private _lastFrameTime;
  36515. private _lastInteractionTime;
  36516. private _cameraRotationSpeed;
  36517. /**
  36518. * Initializes the behavior.
  36519. */
  36520. init(): void;
  36521. /**
  36522. * Attaches the behavior to its arc rotate camera.
  36523. * @param camera Defines the camera to attach the behavior to
  36524. */
  36525. attach(camera: ArcRotateCamera): void;
  36526. /**
  36527. * Detaches the behavior from its current arc rotate camera.
  36528. */
  36529. detach(): void;
  36530. /**
  36531. * Returns true if user is scrolling.
  36532. * @return true if user is scrolling.
  36533. */
  36534. private _userIsZooming;
  36535. private _lastFrameRadius;
  36536. private _shouldAnimationStopForInteraction;
  36537. /**
  36538. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36539. */
  36540. private _applyUserInteraction;
  36541. private _userIsMoving;
  36542. }
  36543. }
  36544. declare module "babylonjs/Behaviors/Cameras/index" {
  36545. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36546. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36547. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36548. }
  36549. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36550. import { Mesh } from "babylonjs/Meshes/mesh";
  36551. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36552. import { Behavior } from "babylonjs/Behaviors/behavior";
  36553. /**
  36554. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36555. */
  36556. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36557. private ui;
  36558. /**
  36559. * The name of the behavior
  36560. */
  36561. name: string;
  36562. /**
  36563. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36564. */
  36565. distanceAwayFromFace: number;
  36566. /**
  36567. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36568. */
  36569. distanceAwayFromBottomOfFace: number;
  36570. private _faceVectors;
  36571. private _target;
  36572. private _scene;
  36573. private _onRenderObserver;
  36574. private _tmpMatrix;
  36575. private _tmpVector;
  36576. /**
  36577. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36578. * @param ui The transform node that should be attched to the mesh
  36579. */
  36580. constructor(ui: TransformNode);
  36581. /**
  36582. * Initializes the behavior
  36583. */
  36584. init(): void;
  36585. private _closestFace;
  36586. private _zeroVector;
  36587. private _lookAtTmpMatrix;
  36588. private _lookAtToRef;
  36589. /**
  36590. * Attaches the AttachToBoxBehavior to the passed in mesh
  36591. * @param target The mesh that the specified node will be attached to
  36592. */
  36593. attach(target: Mesh): void;
  36594. /**
  36595. * Detaches the behavior from the mesh
  36596. */
  36597. detach(): void;
  36598. }
  36599. }
  36600. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36601. import { Behavior } from "babylonjs/Behaviors/behavior";
  36602. import { Mesh } from "babylonjs/Meshes/mesh";
  36603. /**
  36604. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36605. */
  36606. export class FadeInOutBehavior implements Behavior<Mesh> {
  36607. /**
  36608. * Time in milliseconds to delay before fading in (Default: 0)
  36609. */
  36610. delay: number;
  36611. /**
  36612. * Time in milliseconds for the mesh to fade in (Default: 300)
  36613. */
  36614. fadeInTime: number;
  36615. private _millisecondsPerFrame;
  36616. private _hovered;
  36617. private _hoverValue;
  36618. private _ownerNode;
  36619. /**
  36620. * Instatiates the FadeInOutBehavior
  36621. */
  36622. constructor();
  36623. /**
  36624. * The name of the behavior
  36625. */
  36626. readonly name: string;
  36627. /**
  36628. * Initializes the behavior
  36629. */
  36630. init(): void;
  36631. /**
  36632. * Attaches the fade behavior on the passed in mesh
  36633. * @param ownerNode The mesh that will be faded in/out once attached
  36634. */
  36635. attach(ownerNode: Mesh): void;
  36636. /**
  36637. * Detaches the behavior from the mesh
  36638. */
  36639. detach(): void;
  36640. /**
  36641. * Triggers the mesh to begin fading in or out
  36642. * @param value if the object should fade in or out (true to fade in)
  36643. */
  36644. fadeIn(value: boolean): void;
  36645. private _update;
  36646. private _setAllVisibility;
  36647. }
  36648. }
  36649. declare module "babylonjs/Misc/pivotTools" {
  36650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36651. /**
  36652. * Class containing a set of static utilities functions for managing Pivots
  36653. * @hidden
  36654. */
  36655. export class PivotTools {
  36656. private static _PivotCached;
  36657. private static _OldPivotPoint;
  36658. private static _PivotTranslation;
  36659. private static _PivotTmpVector;
  36660. /** @hidden */
  36661. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36662. /** @hidden */
  36663. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36664. }
  36665. }
  36666. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36667. import { Scene } from "babylonjs/scene";
  36668. import { Vector4, Plane } from "babylonjs/Maths/math";
  36669. import { Mesh } from "babylonjs/Meshes/mesh";
  36670. import { Nullable } from "babylonjs/types";
  36671. /**
  36672. * Class containing static functions to help procedurally build meshes
  36673. */
  36674. export class PlaneBuilder {
  36675. /**
  36676. * Creates a plane mesh
  36677. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36678. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36679. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36683. * @param name defines the name of the mesh
  36684. * @param options defines the options used to create the mesh
  36685. * @param scene defines the hosting scene
  36686. * @returns the plane mesh
  36687. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36688. */
  36689. static CreatePlane(name: string, options: {
  36690. size?: number;
  36691. width?: number;
  36692. height?: number;
  36693. sideOrientation?: number;
  36694. frontUVs?: Vector4;
  36695. backUVs?: Vector4;
  36696. updatable?: boolean;
  36697. sourcePlane?: Plane;
  36698. }, scene?: Nullable<Scene>): Mesh;
  36699. }
  36700. }
  36701. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36702. import { Behavior } from "babylonjs/Behaviors/behavior";
  36703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36704. import { Observable } from "babylonjs/Misc/observable";
  36705. import { Vector3 } from "babylonjs/Maths/math";
  36706. import { Ray } from "babylonjs/Culling/ray";
  36707. import "babylonjs/Meshes/Builders/planeBuilder";
  36708. /**
  36709. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36710. */
  36711. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36712. private static _AnyMouseID;
  36713. private _attachedNode;
  36714. private _dragPlane;
  36715. private _scene;
  36716. private _pointerObserver;
  36717. private _beforeRenderObserver;
  36718. private static _planeScene;
  36719. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36720. /**
  36721. * 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)
  36722. */
  36723. maxDragAngle: number;
  36724. /**
  36725. * @hidden
  36726. */
  36727. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36728. /**
  36729. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36730. */
  36731. currentDraggingPointerID: number;
  36732. /**
  36733. * The last position where the pointer hit the drag plane in world space
  36734. */
  36735. lastDragPosition: Vector3;
  36736. /**
  36737. * If the behavior is currently in a dragging state
  36738. */
  36739. dragging: boolean;
  36740. /**
  36741. * 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)
  36742. */
  36743. dragDeltaRatio: number;
  36744. /**
  36745. * If the drag plane orientation should be updated during the dragging (Default: true)
  36746. */
  36747. updateDragPlane: boolean;
  36748. private _debugMode;
  36749. private _moving;
  36750. /**
  36751. * Fires each time the attached mesh is dragged with the pointer
  36752. * * delta between last drag position and current drag position in world space
  36753. * * dragDistance along the drag axis
  36754. * * dragPlaneNormal normal of the current drag plane used during the drag
  36755. * * dragPlanePoint in world space where the drag intersects the drag plane
  36756. */
  36757. onDragObservable: Observable<{
  36758. delta: Vector3;
  36759. dragPlanePoint: Vector3;
  36760. dragPlaneNormal: Vector3;
  36761. dragDistance: number;
  36762. pointerId: number;
  36763. }>;
  36764. /**
  36765. * Fires each time a drag begins (eg. mouse down on mesh)
  36766. */
  36767. onDragStartObservable: Observable<{
  36768. dragPlanePoint: Vector3;
  36769. pointerId: number;
  36770. }>;
  36771. /**
  36772. * Fires each time a drag ends (eg. mouse release after drag)
  36773. */
  36774. onDragEndObservable: Observable<{
  36775. dragPlanePoint: Vector3;
  36776. pointerId: number;
  36777. }>;
  36778. /**
  36779. * If the attached mesh should be moved when dragged
  36780. */
  36781. moveAttached: boolean;
  36782. /**
  36783. * If the drag behavior will react to drag events (Default: true)
  36784. */
  36785. enabled: boolean;
  36786. /**
  36787. * If camera controls should be detached during the drag
  36788. */
  36789. detachCameraControls: boolean;
  36790. /**
  36791. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36792. */
  36793. useObjectOrienationForDragging: boolean;
  36794. private _options;
  36795. /**
  36796. * Creates a pointer drag behavior that can be attached to a mesh
  36797. * @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)
  36798. */
  36799. constructor(options?: {
  36800. dragAxis?: Vector3;
  36801. dragPlaneNormal?: Vector3;
  36802. });
  36803. /**
  36804. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36805. */
  36806. validateDrag: (targetPosition: Vector3) => boolean;
  36807. /**
  36808. * The name of the behavior
  36809. */
  36810. readonly name: string;
  36811. /**
  36812. * Initializes the behavior
  36813. */
  36814. init(): void;
  36815. private _tmpVector;
  36816. private _alternatePickedPoint;
  36817. private _worldDragAxis;
  36818. private _targetPosition;
  36819. private _attachedElement;
  36820. /**
  36821. * Attaches the drag behavior the passed in mesh
  36822. * @param ownerNode The mesh that will be dragged around once attached
  36823. */
  36824. attach(ownerNode: AbstractMesh): void;
  36825. /**
  36826. * Force relase the drag action by code.
  36827. */
  36828. releaseDrag(): void;
  36829. private _startDragRay;
  36830. private _lastPointerRay;
  36831. /**
  36832. * Simulates the start of a pointer drag event on the behavior
  36833. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36834. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36835. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36836. */
  36837. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36838. private _startDrag;
  36839. private _dragDelta;
  36840. private _moveDrag;
  36841. private _pickWithRayOnDragPlane;
  36842. private _pointA;
  36843. private _pointB;
  36844. private _pointC;
  36845. private _lineA;
  36846. private _lineB;
  36847. private _localAxis;
  36848. private _lookAt;
  36849. private _updateDragPlanePosition;
  36850. /**
  36851. * Detaches the behavior from the mesh
  36852. */
  36853. detach(): void;
  36854. }
  36855. }
  36856. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36857. import { Mesh } from "babylonjs/Meshes/mesh";
  36858. import { Behavior } from "babylonjs/Behaviors/behavior";
  36859. /**
  36860. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36861. */
  36862. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36863. private _dragBehaviorA;
  36864. private _dragBehaviorB;
  36865. private _startDistance;
  36866. private _initialScale;
  36867. private _targetScale;
  36868. private _ownerNode;
  36869. private _sceneRenderObserver;
  36870. /**
  36871. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36872. */
  36873. constructor();
  36874. /**
  36875. * The name of the behavior
  36876. */
  36877. readonly name: string;
  36878. /**
  36879. * Initializes the behavior
  36880. */
  36881. init(): void;
  36882. private _getCurrentDistance;
  36883. /**
  36884. * Attaches the scale behavior the passed in mesh
  36885. * @param ownerNode The mesh that will be scaled around once attached
  36886. */
  36887. attach(ownerNode: Mesh): void;
  36888. /**
  36889. * Detaches the behavior from the mesh
  36890. */
  36891. detach(): void;
  36892. }
  36893. }
  36894. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36895. import { Behavior } from "babylonjs/Behaviors/behavior";
  36896. import { Mesh } from "babylonjs/Meshes/mesh";
  36897. import { Observable } from "babylonjs/Misc/observable";
  36898. /**
  36899. * 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
  36900. */
  36901. export class SixDofDragBehavior implements Behavior<Mesh> {
  36902. private static _virtualScene;
  36903. private _ownerNode;
  36904. private _sceneRenderObserver;
  36905. private _scene;
  36906. private _targetPosition;
  36907. private _virtualOriginMesh;
  36908. private _virtualDragMesh;
  36909. private _pointerObserver;
  36910. private _moving;
  36911. private _startingOrientation;
  36912. /**
  36913. * 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)
  36914. */
  36915. private zDragFactor;
  36916. /**
  36917. * If the object should rotate to face the drag origin
  36918. */
  36919. rotateDraggedObject: boolean;
  36920. /**
  36921. * If the behavior is currently in a dragging state
  36922. */
  36923. dragging: boolean;
  36924. /**
  36925. * 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)
  36926. */
  36927. dragDeltaRatio: number;
  36928. /**
  36929. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36930. */
  36931. currentDraggingPointerID: number;
  36932. /**
  36933. * If camera controls should be detached during the drag
  36934. */
  36935. detachCameraControls: boolean;
  36936. /**
  36937. * Fires each time a drag starts
  36938. */
  36939. onDragStartObservable: Observable<{}>;
  36940. /**
  36941. * Fires each time a drag ends (eg. mouse release after drag)
  36942. */
  36943. onDragEndObservable: Observable<{}>;
  36944. /**
  36945. * 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
  36946. */
  36947. constructor();
  36948. /**
  36949. * The name of the behavior
  36950. */
  36951. readonly name: string;
  36952. /**
  36953. * Initializes the behavior
  36954. */
  36955. init(): void;
  36956. /**
  36957. * Attaches the scale behavior the passed in mesh
  36958. * @param ownerNode The mesh that will be scaled around once attached
  36959. */
  36960. attach(ownerNode: Mesh): void;
  36961. /**
  36962. * Detaches the behavior from the mesh
  36963. */
  36964. detach(): void;
  36965. }
  36966. }
  36967. declare module "babylonjs/Behaviors/Meshes/index" {
  36968. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36969. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36970. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36971. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36972. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36973. }
  36974. declare module "babylonjs/Behaviors/index" {
  36975. export * from "babylonjs/Behaviors/behavior";
  36976. export * from "babylonjs/Behaviors/Cameras/index";
  36977. export * from "babylonjs/Behaviors/Meshes/index";
  36978. }
  36979. declare module "babylonjs/Bones/boneIKController" {
  36980. import { Bone } from "babylonjs/Bones/bone";
  36981. import { Vector3 } from "babylonjs/Maths/math";
  36982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36983. import { Nullable } from "babylonjs/types";
  36984. /**
  36985. * Class used to apply inverse kinematics to bones
  36986. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36987. */
  36988. export class BoneIKController {
  36989. private static _tmpVecs;
  36990. private static _tmpQuat;
  36991. private static _tmpMats;
  36992. /**
  36993. * Gets or sets the target mesh
  36994. */
  36995. targetMesh: AbstractMesh;
  36996. /** Gets or sets the mesh used as pole */
  36997. poleTargetMesh: AbstractMesh;
  36998. /**
  36999. * Gets or sets the bone used as pole
  37000. */
  37001. poleTargetBone: Nullable<Bone>;
  37002. /**
  37003. * Gets or sets the target position
  37004. */
  37005. targetPosition: Vector3;
  37006. /**
  37007. * Gets or sets the pole target position
  37008. */
  37009. poleTargetPosition: Vector3;
  37010. /**
  37011. * Gets or sets the pole target local offset
  37012. */
  37013. poleTargetLocalOffset: Vector3;
  37014. /**
  37015. * Gets or sets the pole angle
  37016. */
  37017. poleAngle: number;
  37018. /**
  37019. * Gets or sets the mesh associated with the controller
  37020. */
  37021. mesh: AbstractMesh;
  37022. /**
  37023. * 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)
  37024. */
  37025. slerpAmount: number;
  37026. private _bone1Quat;
  37027. private _bone1Mat;
  37028. private _bone2Ang;
  37029. private _bone1;
  37030. private _bone2;
  37031. private _bone1Length;
  37032. private _bone2Length;
  37033. private _maxAngle;
  37034. private _maxReach;
  37035. private _rightHandedSystem;
  37036. private _bendAxis;
  37037. private _slerping;
  37038. private _adjustRoll;
  37039. /**
  37040. * Gets or sets maximum allowed angle
  37041. */
  37042. maxAngle: number;
  37043. /**
  37044. * Creates a new BoneIKController
  37045. * @param mesh defines the mesh to control
  37046. * @param bone defines the bone to control
  37047. * @param options defines options to set up the controller
  37048. */
  37049. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37050. targetMesh?: AbstractMesh;
  37051. poleTargetMesh?: AbstractMesh;
  37052. poleTargetBone?: Bone;
  37053. poleTargetLocalOffset?: Vector3;
  37054. poleAngle?: number;
  37055. bendAxis?: Vector3;
  37056. maxAngle?: number;
  37057. slerpAmount?: number;
  37058. });
  37059. private _setMaxAngle;
  37060. /**
  37061. * Force the controller to update the bones
  37062. */
  37063. update(): void;
  37064. }
  37065. }
  37066. declare module "babylonjs/Bones/boneLookController" {
  37067. import { Vector3, Space } from "babylonjs/Maths/math";
  37068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37069. import { Bone } from "babylonjs/Bones/bone";
  37070. /**
  37071. * Class used to make a bone look toward a point in space
  37072. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37073. */
  37074. export class BoneLookController {
  37075. private static _tmpVecs;
  37076. private static _tmpQuat;
  37077. private static _tmpMats;
  37078. /**
  37079. * The target Vector3 that the bone will look at
  37080. */
  37081. target: Vector3;
  37082. /**
  37083. * The mesh that the bone is attached to
  37084. */
  37085. mesh: AbstractMesh;
  37086. /**
  37087. * The bone that will be looking to the target
  37088. */
  37089. bone: Bone;
  37090. /**
  37091. * The up axis of the coordinate system that is used when the bone is rotated
  37092. */
  37093. upAxis: Vector3;
  37094. /**
  37095. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37096. */
  37097. upAxisSpace: Space;
  37098. /**
  37099. * Used to make an adjustment to the yaw of the bone
  37100. */
  37101. adjustYaw: number;
  37102. /**
  37103. * Used to make an adjustment to the pitch of the bone
  37104. */
  37105. adjustPitch: number;
  37106. /**
  37107. * Used to make an adjustment to the roll of the bone
  37108. */
  37109. adjustRoll: number;
  37110. /**
  37111. * 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)
  37112. */
  37113. slerpAmount: number;
  37114. private _minYaw;
  37115. private _maxYaw;
  37116. private _minPitch;
  37117. private _maxPitch;
  37118. private _minYawSin;
  37119. private _minYawCos;
  37120. private _maxYawSin;
  37121. private _maxYawCos;
  37122. private _midYawConstraint;
  37123. private _minPitchTan;
  37124. private _maxPitchTan;
  37125. private _boneQuat;
  37126. private _slerping;
  37127. private _transformYawPitch;
  37128. private _transformYawPitchInv;
  37129. private _firstFrameSkipped;
  37130. private _yawRange;
  37131. private _fowardAxis;
  37132. /**
  37133. * Gets or sets the minimum yaw angle that the bone can look to
  37134. */
  37135. minYaw: number;
  37136. /**
  37137. * Gets or sets the maximum yaw angle that the bone can look to
  37138. */
  37139. maxYaw: number;
  37140. /**
  37141. * Gets or sets the minimum pitch angle that the bone can look to
  37142. */
  37143. minPitch: number;
  37144. /**
  37145. * Gets or sets the maximum pitch angle that the bone can look to
  37146. */
  37147. maxPitch: number;
  37148. /**
  37149. * Create a BoneLookController
  37150. * @param mesh the mesh that the bone belongs to
  37151. * @param bone the bone that will be looking to the target
  37152. * @param target the target Vector3 to look at
  37153. * @param options optional settings:
  37154. * * maxYaw: the maximum angle the bone will yaw to
  37155. * * minYaw: the minimum angle the bone will yaw to
  37156. * * maxPitch: the maximum angle the bone will pitch to
  37157. * * minPitch: the minimum angle the bone will yaw to
  37158. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37159. * * upAxis: the up axis of the coordinate system
  37160. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37161. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37162. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37163. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37164. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37165. * * adjustRoll: used to make an adjustment to the roll of the bone
  37166. **/
  37167. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37168. maxYaw?: number;
  37169. minYaw?: number;
  37170. maxPitch?: number;
  37171. minPitch?: number;
  37172. slerpAmount?: number;
  37173. upAxis?: Vector3;
  37174. upAxisSpace?: Space;
  37175. yawAxis?: Vector3;
  37176. pitchAxis?: Vector3;
  37177. adjustYaw?: number;
  37178. adjustPitch?: number;
  37179. adjustRoll?: number;
  37180. });
  37181. /**
  37182. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37183. */
  37184. update(): void;
  37185. private _getAngleDiff;
  37186. private _getAngleBetween;
  37187. private _isAngleBetween;
  37188. }
  37189. }
  37190. declare module "babylonjs/Bones/index" {
  37191. export * from "babylonjs/Bones/bone";
  37192. export * from "babylonjs/Bones/boneIKController";
  37193. export * from "babylonjs/Bones/boneLookController";
  37194. export * from "babylonjs/Bones/skeleton";
  37195. }
  37196. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37197. import { Nullable } from "babylonjs/types";
  37198. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37199. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37200. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37201. /**
  37202. * Manage the gamepad inputs to control an arc rotate camera.
  37203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37204. */
  37205. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37206. /**
  37207. * Defines the camera the input is attached to.
  37208. */
  37209. camera: ArcRotateCamera;
  37210. /**
  37211. * Defines the gamepad the input is gathering event from.
  37212. */
  37213. gamepad: Nullable<Gamepad>;
  37214. /**
  37215. * Defines the gamepad rotation sensiblity.
  37216. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37217. */
  37218. gamepadRotationSensibility: number;
  37219. /**
  37220. * Defines the gamepad move sensiblity.
  37221. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37222. */
  37223. gamepadMoveSensibility: number;
  37224. private _onGamepadConnectedObserver;
  37225. private _onGamepadDisconnectedObserver;
  37226. /**
  37227. * Attach the input controls to a specific dom element to get the input from.
  37228. * @param element Defines the element the controls should be listened from
  37229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37230. */
  37231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37232. /**
  37233. * Detach the current controls from the specified dom element.
  37234. * @param element Defines the element to stop listening the inputs from
  37235. */
  37236. detachControl(element: Nullable<HTMLElement>): void;
  37237. /**
  37238. * Update the current camera state depending on the inputs that have been used this frame.
  37239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37240. */
  37241. checkInputs(): void;
  37242. /**
  37243. * Gets the class name of the current intput.
  37244. * @returns the class name
  37245. */
  37246. getClassName(): string;
  37247. /**
  37248. * Get the friendly name associated with the input class.
  37249. * @returns the input friendly name
  37250. */
  37251. getSimpleName(): string;
  37252. }
  37253. }
  37254. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37255. import { Nullable } from "babylonjs/types";
  37256. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37257. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37258. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37259. interface ArcRotateCameraInputsManager {
  37260. /**
  37261. * Add orientation input support to the input manager.
  37262. * @returns the current input manager
  37263. */
  37264. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37265. }
  37266. }
  37267. /**
  37268. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37270. */
  37271. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37272. /**
  37273. * Defines the camera the input is attached to.
  37274. */
  37275. camera: ArcRotateCamera;
  37276. /**
  37277. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37278. */
  37279. alphaCorrection: number;
  37280. /**
  37281. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37282. */
  37283. gammaCorrection: number;
  37284. private _alpha;
  37285. private _gamma;
  37286. private _dirty;
  37287. private _deviceOrientationHandler;
  37288. /**
  37289. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37290. */
  37291. constructor();
  37292. /**
  37293. * Attach the input controls to a specific dom element to get the input from.
  37294. * @param element Defines the element the controls should be listened from
  37295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37296. */
  37297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37298. /** @hidden */
  37299. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37300. /**
  37301. * Update the current camera state depending on the inputs that have been used this frame.
  37302. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37303. */
  37304. checkInputs(): void;
  37305. /**
  37306. * Detach the current controls from the specified dom element.
  37307. * @param element Defines the element to stop listening the inputs from
  37308. */
  37309. detachControl(element: Nullable<HTMLElement>): void;
  37310. /**
  37311. * Gets the class name of the current intput.
  37312. * @returns the class name
  37313. */
  37314. getClassName(): string;
  37315. /**
  37316. * Get the friendly name associated with the input class.
  37317. * @returns the input friendly name
  37318. */
  37319. getSimpleName(): string;
  37320. }
  37321. }
  37322. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37323. import { Nullable } from "babylonjs/types";
  37324. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37325. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37326. /**
  37327. * Listen to mouse events to control the camera.
  37328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37329. */
  37330. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37331. /**
  37332. * Defines the camera the input is attached to.
  37333. */
  37334. camera: FlyCamera;
  37335. /**
  37336. * Defines if touch is enabled. (Default is true.)
  37337. */
  37338. touchEnabled: boolean;
  37339. /**
  37340. * Defines the buttons associated with the input to handle camera rotation.
  37341. */
  37342. buttons: number[];
  37343. /**
  37344. * Assign buttons for Yaw control.
  37345. */
  37346. buttonsYaw: number[];
  37347. /**
  37348. * Assign buttons for Pitch control.
  37349. */
  37350. buttonsPitch: number[];
  37351. /**
  37352. * Assign buttons for Roll control.
  37353. */
  37354. buttonsRoll: number[];
  37355. /**
  37356. * Detect if any button is being pressed while mouse is moved.
  37357. * -1 = Mouse locked.
  37358. * 0 = Left button.
  37359. * 1 = Middle Button.
  37360. * 2 = Right Button.
  37361. */
  37362. activeButton: number;
  37363. /**
  37364. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37365. * Higher values reduce its sensitivity.
  37366. */
  37367. angularSensibility: number;
  37368. private _mousemoveCallback;
  37369. private _observer;
  37370. private _rollObserver;
  37371. private previousPosition;
  37372. private noPreventDefault;
  37373. private element;
  37374. /**
  37375. * Listen to mouse events to control the camera.
  37376. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37378. */
  37379. constructor(touchEnabled?: boolean);
  37380. /**
  37381. * Attach the mouse control to the HTML DOM element.
  37382. * @param element Defines the element that listens to the input events.
  37383. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37384. */
  37385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37386. /**
  37387. * Detach the current controls from the specified dom element.
  37388. * @param element Defines the element to stop listening the inputs from
  37389. */
  37390. detachControl(element: Nullable<HTMLElement>): void;
  37391. /**
  37392. * Gets the class name of the current input.
  37393. * @returns the class name.
  37394. */
  37395. getClassName(): string;
  37396. /**
  37397. * Get the friendly name associated with the input class.
  37398. * @returns the input's friendly name.
  37399. */
  37400. getSimpleName(): string;
  37401. private _pointerInput;
  37402. private _onMouseMove;
  37403. /**
  37404. * Rotate camera by mouse offset.
  37405. */
  37406. private rotateCamera;
  37407. }
  37408. }
  37409. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37410. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37411. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37412. /**
  37413. * Default Inputs manager for the FlyCamera.
  37414. * It groups all the default supported inputs for ease of use.
  37415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37416. */
  37417. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37418. /**
  37419. * Instantiates a new FlyCameraInputsManager.
  37420. * @param camera Defines the camera the inputs belong to.
  37421. */
  37422. constructor(camera: FlyCamera);
  37423. /**
  37424. * Add keyboard input support to the input manager.
  37425. * @returns the new FlyCameraKeyboardMoveInput().
  37426. */
  37427. addKeyboard(): FlyCameraInputsManager;
  37428. /**
  37429. * Add mouse input support to the input manager.
  37430. * @param touchEnabled Enable touch screen support.
  37431. * @returns the new FlyCameraMouseInput().
  37432. */
  37433. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37434. }
  37435. }
  37436. declare module "babylonjs/Cameras/flyCamera" {
  37437. import { Scene } from "babylonjs/scene";
  37438. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37440. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37441. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37442. /**
  37443. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37444. * such as in a 3D Space Shooter or a Flight Simulator.
  37445. */
  37446. export class FlyCamera extends TargetCamera {
  37447. /**
  37448. * Define the collision ellipsoid of the camera.
  37449. * This is helpful for simulating a camera body, like a player's body.
  37450. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37451. */
  37452. ellipsoid: Vector3;
  37453. /**
  37454. * Define an offset for the position of the ellipsoid around the camera.
  37455. * This can be helpful if the camera is attached away from the player's body center,
  37456. * such as at its head.
  37457. */
  37458. ellipsoidOffset: Vector3;
  37459. /**
  37460. * Enable or disable collisions of the camera with the rest of the scene objects.
  37461. */
  37462. checkCollisions: boolean;
  37463. /**
  37464. * Enable or disable gravity on the camera.
  37465. */
  37466. applyGravity: boolean;
  37467. /**
  37468. * Define the current direction the camera is moving to.
  37469. */
  37470. cameraDirection: Vector3;
  37471. /**
  37472. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37473. * This overrides and empties cameraRotation.
  37474. */
  37475. rotationQuaternion: Quaternion;
  37476. /**
  37477. * Track Roll to maintain the wanted Rolling when looking around.
  37478. */
  37479. _trackRoll: number;
  37480. /**
  37481. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37482. */
  37483. rollCorrect: number;
  37484. /**
  37485. * Mimic a banked turn, Rolling the camera when Yawing.
  37486. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37487. */
  37488. bankedTurn: boolean;
  37489. /**
  37490. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37491. */
  37492. bankedTurnLimit: number;
  37493. /**
  37494. * Value of 0 disables the banked Roll.
  37495. * Value of 1 is equal to the Yaw angle in radians.
  37496. */
  37497. bankedTurnMultiplier: number;
  37498. /**
  37499. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37500. */
  37501. inputs: FlyCameraInputsManager;
  37502. /**
  37503. * Gets the input sensibility for mouse input.
  37504. * Higher values reduce sensitivity.
  37505. */
  37506. /**
  37507. * Sets the input sensibility for a mouse input.
  37508. * Higher values reduce sensitivity.
  37509. */
  37510. angularSensibility: number;
  37511. /**
  37512. * Get the keys for camera movement forward.
  37513. */
  37514. /**
  37515. * Set the keys for camera movement forward.
  37516. */
  37517. keysForward: number[];
  37518. /**
  37519. * Get the keys for camera movement backward.
  37520. */
  37521. keysBackward: number[];
  37522. /**
  37523. * Get the keys for camera movement up.
  37524. */
  37525. /**
  37526. * Set the keys for camera movement up.
  37527. */
  37528. keysUp: number[];
  37529. /**
  37530. * Get the keys for camera movement down.
  37531. */
  37532. /**
  37533. * Set the keys for camera movement down.
  37534. */
  37535. keysDown: number[];
  37536. /**
  37537. * Get the keys for camera movement left.
  37538. */
  37539. /**
  37540. * Set the keys for camera movement left.
  37541. */
  37542. keysLeft: number[];
  37543. /**
  37544. * Set the keys for camera movement right.
  37545. */
  37546. /**
  37547. * Set the keys for camera movement right.
  37548. */
  37549. keysRight: number[];
  37550. /**
  37551. * Event raised when the camera collides with a mesh in the scene.
  37552. */
  37553. onCollide: (collidedMesh: AbstractMesh) => void;
  37554. private _collider;
  37555. private _needMoveForGravity;
  37556. private _oldPosition;
  37557. private _diffPosition;
  37558. private _newPosition;
  37559. /** @hidden */
  37560. _localDirection: Vector3;
  37561. /** @hidden */
  37562. _transformedDirection: Vector3;
  37563. /**
  37564. * Instantiates a FlyCamera.
  37565. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37566. * such as in a 3D Space Shooter or a Flight Simulator.
  37567. * @param name Define the name of the camera in the scene.
  37568. * @param position Define the starting position of the camera in the scene.
  37569. * @param scene Define the scene the camera belongs to.
  37570. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37571. */
  37572. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37573. /**
  37574. * Attach a control to the HTML DOM element.
  37575. * @param element Defines the element that listens to the input events.
  37576. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37577. */
  37578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37579. /**
  37580. * Detach a control from the HTML DOM element.
  37581. * The camera will stop reacting to that input.
  37582. * @param element Defines the element that listens to the input events.
  37583. */
  37584. detachControl(element: HTMLElement): void;
  37585. private _collisionMask;
  37586. /**
  37587. * Get the mask that the camera ignores in collision events.
  37588. */
  37589. /**
  37590. * Set the mask that the camera ignores in collision events.
  37591. */
  37592. collisionMask: number;
  37593. /** @hidden */
  37594. _collideWithWorld(displacement: Vector3): void;
  37595. /** @hidden */
  37596. private _onCollisionPositionChange;
  37597. /** @hidden */
  37598. _checkInputs(): void;
  37599. /** @hidden */
  37600. _decideIfNeedsToMove(): boolean;
  37601. /** @hidden */
  37602. _updatePosition(): void;
  37603. /**
  37604. * Restore the Roll to its target value at the rate specified.
  37605. * @param rate - Higher means slower restoring.
  37606. * @hidden
  37607. */
  37608. restoreRoll(rate: number): void;
  37609. /**
  37610. * Destroy the camera and release the current resources held by it.
  37611. */
  37612. dispose(): void;
  37613. /**
  37614. * Get the current object class name.
  37615. * @returns the class name.
  37616. */
  37617. getClassName(): string;
  37618. }
  37619. }
  37620. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37621. import { Nullable } from "babylonjs/types";
  37622. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37623. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37624. /**
  37625. * Listen to keyboard events to control the camera.
  37626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37627. */
  37628. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37629. /**
  37630. * Defines the camera the input is attached to.
  37631. */
  37632. camera: FlyCamera;
  37633. /**
  37634. * The list of keyboard keys used to control the forward move of the camera.
  37635. */
  37636. keysForward: number[];
  37637. /**
  37638. * The list of keyboard keys used to control the backward move of the camera.
  37639. */
  37640. keysBackward: number[];
  37641. /**
  37642. * The list of keyboard keys used to control the forward move of the camera.
  37643. */
  37644. keysUp: number[];
  37645. /**
  37646. * The list of keyboard keys used to control the backward move of the camera.
  37647. */
  37648. keysDown: number[];
  37649. /**
  37650. * The list of keyboard keys used to control the right strafe move of the camera.
  37651. */
  37652. keysRight: number[];
  37653. /**
  37654. * The list of keyboard keys used to control the left strafe move of the camera.
  37655. */
  37656. keysLeft: number[];
  37657. private _keys;
  37658. private _onCanvasBlurObserver;
  37659. private _onKeyboardObserver;
  37660. private _engine;
  37661. private _scene;
  37662. /**
  37663. * Attach the input controls to a specific dom element to get the input from.
  37664. * @param element Defines the element the controls should be listened from
  37665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37666. */
  37667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37668. /**
  37669. * Detach the current controls from the specified dom element.
  37670. * @param element Defines the element to stop listening the inputs from
  37671. */
  37672. detachControl(element: Nullable<HTMLElement>): void;
  37673. /**
  37674. * Gets the class name of the current intput.
  37675. * @returns the class name
  37676. */
  37677. getClassName(): string;
  37678. /** @hidden */
  37679. _onLostFocus(e: FocusEvent): void;
  37680. /**
  37681. * Get the friendly name associated with the input class.
  37682. * @returns the input friendly name
  37683. */
  37684. getSimpleName(): string;
  37685. /**
  37686. * Update the current camera state depending on the inputs that have been used this frame.
  37687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37688. */
  37689. checkInputs(): void;
  37690. }
  37691. }
  37692. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37693. import { Nullable } from "babylonjs/types";
  37694. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37695. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37696. /**
  37697. * Manage the mouse wheel inputs to control a follow camera.
  37698. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37699. */
  37700. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37701. /**
  37702. * Defines the camera the input is attached to.
  37703. */
  37704. camera: FollowCamera;
  37705. /**
  37706. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37707. */
  37708. axisControlRadius: boolean;
  37709. /**
  37710. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37711. */
  37712. axisControlHeight: boolean;
  37713. /**
  37714. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37715. */
  37716. axisControlRotation: boolean;
  37717. /**
  37718. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37719. * relation to mouseWheel events.
  37720. */
  37721. wheelPrecision: number;
  37722. /**
  37723. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37724. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37725. */
  37726. wheelDeltaPercentage: number;
  37727. private _wheel;
  37728. private _observer;
  37729. /**
  37730. * Attach the input controls to a specific dom element to get the input from.
  37731. * @param element Defines the element the controls should be listened from
  37732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37733. */
  37734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37735. /**
  37736. * Detach the current controls from the specified dom element.
  37737. * @param element Defines the element to stop listening the inputs from
  37738. */
  37739. detachControl(element: Nullable<HTMLElement>): void;
  37740. /**
  37741. * Gets the class name of the current intput.
  37742. * @returns the class name
  37743. */
  37744. getClassName(): string;
  37745. /**
  37746. * Get the friendly name associated with the input class.
  37747. * @returns the input friendly name
  37748. */
  37749. getSimpleName(): string;
  37750. }
  37751. }
  37752. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37753. import { Nullable } from "babylonjs/types";
  37754. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37755. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37756. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37757. /**
  37758. * Manage the pointers inputs to control an follow camera.
  37759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37760. */
  37761. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37762. /**
  37763. * Defines the camera the input is attached to.
  37764. */
  37765. camera: FollowCamera;
  37766. /**
  37767. * Gets the class name of the current input.
  37768. * @returns the class name
  37769. */
  37770. getClassName(): string;
  37771. /**
  37772. * Defines the pointer angular sensibility along the X axis or how fast is
  37773. * the camera rotating.
  37774. * A negative number will reverse the axis direction.
  37775. */
  37776. angularSensibilityX: number;
  37777. /**
  37778. * Defines the pointer angular sensibility along the Y axis or how fast is
  37779. * the camera rotating.
  37780. * A negative number will reverse the axis direction.
  37781. */
  37782. angularSensibilityY: number;
  37783. /**
  37784. * Defines the pointer pinch precision or how fast is the camera zooming.
  37785. * A negative number will reverse the axis direction.
  37786. */
  37787. pinchPrecision: number;
  37788. /**
  37789. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37790. * from 0.
  37791. * It defines the percentage of current camera.radius to use as delta when
  37792. * pinch zoom is used.
  37793. */
  37794. pinchDeltaPercentage: number;
  37795. /**
  37796. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37797. */
  37798. axisXControlRadius: boolean;
  37799. /**
  37800. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37801. */
  37802. axisXControlHeight: boolean;
  37803. /**
  37804. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37805. */
  37806. axisXControlRotation: boolean;
  37807. /**
  37808. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37809. */
  37810. axisYControlRadius: boolean;
  37811. /**
  37812. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37813. */
  37814. axisYControlHeight: boolean;
  37815. /**
  37816. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37817. */
  37818. axisYControlRotation: boolean;
  37819. /**
  37820. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37821. */
  37822. axisPinchControlRadius: boolean;
  37823. /**
  37824. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37825. */
  37826. axisPinchControlHeight: boolean;
  37827. /**
  37828. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37829. */
  37830. axisPinchControlRotation: boolean;
  37831. /**
  37832. * Log error messages if basic misconfiguration has occurred.
  37833. */
  37834. warningEnable: boolean;
  37835. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37836. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37837. private _warningCounter;
  37838. private _warning;
  37839. }
  37840. }
  37841. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37842. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37843. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37844. /**
  37845. * Default Inputs manager for the FollowCamera.
  37846. * It groups all the default supported inputs for ease of use.
  37847. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37848. */
  37849. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37850. /**
  37851. * Instantiates a new FollowCameraInputsManager.
  37852. * @param camera Defines the camera the inputs belong to
  37853. */
  37854. constructor(camera: FollowCamera);
  37855. /**
  37856. * Add keyboard input support to the input manager.
  37857. * @returns the current input manager
  37858. */
  37859. addKeyboard(): FollowCameraInputsManager;
  37860. /**
  37861. * Add mouse wheel input support to the input manager.
  37862. * @returns the current input manager
  37863. */
  37864. addMouseWheel(): FollowCameraInputsManager;
  37865. /**
  37866. * Add pointers input support to the input manager.
  37867. * @returns the current input manager
  37868. */
  37869. addPointers(): FollowCameraInputsManager;
  37870. /**
  37871. * Add orientation input support to the input manager.
  37872. * @returns the current input manager
  37873. */
  37874. addVRDeviceOrientation(): FollowCameraInputsManager;
  37875. }
  37876. }
  37877. declare module "babylonjs/Cameras/followCamera" {
  37878. import { Nullable } from "babylonjs/types";
  37879. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37880. import { Scene } from "babylonjs/scene";
  37881. import { Vector3 } from "babylonjs/Maths/math";
  37882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37883. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37884. /**
  37885. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37886. * an arc rotate version arcFollowCamera are available.
  37887. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37888. */
  37889. export class FollowCamera extends TargetCamera {
  37890. /**
  37891. * Distance the follow camera should follow an object at
  37892. */
  37893. radius: number;
  37894. /**
  37895. * Minimum allowed distance of the camera to the axis of rotation
  37896. * (The camera can not get closer).
  37897. * This can help limiting how the Camera is able to move in the scene.
  37898. */
  37899. lowerRadiusLimit: Nullable<number>;
  37900. /**
  37901. * Maximum allowed distance of the camera to the axis of rotation
  37902. * (The camera can not get further).
  37903. * This can help limiting how the Camera is able to move in the scene.
  37904. */
  37905. upperRadiusLimit: Nullable<number>;
  37906. /**
  37907. * Define a rotation offset between the camera and the object it follows
  37908. */
  37909. rotationOffset: number;
  37910. /**
  37911. * Minimum allowed angle to camera position relative to target object.
  37912. * This can help limiting how the Camera is able to move in the scene.
  37913. */
  37914. lowerRotationOffsetLimit: Nullable<number>;
  37915. /**
  37916. * Maximum allowed angle to camera position relative to target object.
  37917. * This can help limiting how the Camera is able to move in the scene.
  37918. */
  37919. upperRotationOffsetLimit: Nullable<number>;
  37920. /**
  37921. * Define a height offset between the camera and the object it follows.
  37922. * It can help following an object from the top (like a car chaing a plane)
  37923. */
  37924. heightOffset: number;
  37925. /**
  37926. * Minimum allowed height of camera position relative to target object.
  37927. * This can help limiting how the Camera is able to move in the scene.
  37928. */
  37929. lowerHeightOffsetLimit: Nullable<number>;
  37930. /**
  37931. * Maximum allowed height of camera position relative to target object.
  37932. * This can help limiting how the Camera is able to move in the scene.
  37933. */
  37934. upperHeightOffsetLimit: Nullable<number>;
  37935. /**
  37936. * Define how fast the camera can accelerate to follow it s target.
  37937. */
  37938. cameraAcceleration: number;
  37939. /**
  37940. * Define the speed limit of the camera following an object.
  37941. */
  37942. maxCameraSpeed: number;
  37943. /**
  37944. * Define the target of the camera.
  37945. */
  37946. lockedTarget: Nullable<AbstractMesh>;
  37947. /**
  37948. * Defines the input associated with the camera.
  37949. */
  37950. inputs: FollowCameraInputsManager;
  37951. /**
  37952. * Instantiates the follow camera.
  37953. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37954. * @param name Define the name of the camera in the scene
  37955. * @param position Define the position of the camera
  37956. * @param scene Define the scene the camera belong to
  37957. * @param lockedTarget Define the target of the camera
  37958. */
  37959. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37960. private _follow;
  37961. /**
  37962. * Attached controls to the current camera.
  37963. * @param element Defines the element the controls should be listened from
  37964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37965. */
  37966. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37967. /**
  37968. * Detach the current controls from the camera.
  37969. * The camera will stop reacting to inputs.
  37970. * @param element Defines the element to stop listening the inputs from
  37971. */
  37972. detachControl(element: HTMLElement): void;
  37973. /** @hidden */
  37974. _checkInputs(): void;
  37975. private _checkLimits;
  37976. /**
  37977. * Gets the camera class name.
  37978. * @returns the class name
  37979. */
  37980. getClassName(): string;
  37981. }
  37982. /**
  37983. * Arc Rotate version of the follow camera.
  37984. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37985. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37986. */
  37987. export class ArcFollowCamera extends TargetCamera {
  37988. /** The longitudinal angle of the camera */
  37989. alpha: number;
  37990. /** The latitudinal angle of the camera */
  37991. beta: number;
  37992. /** The radius of the camera from its target */
  37993. radius: number;
  37994. /** Define the camera target (the messh it should follow) */
  37995. target: Nullable<AbstractMesh>;
  37996. private _cartesianCoordinates;
  37997. /**
  37998. * Instantiates a new ArcFollowCamera
  37999. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38000. * @param name Define the name of the camera
  38001. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38002. * @param beta Define the rotation angle of the camera around the elevation axis
  38003. * @param radius Define the radius of the camera from its target point
  38004. * @param target Define the target of the camera
  38005. * @param scene Define the scene the camera belongs to
  38006. */
  38007. constructor(name: string,
  38008. /** The longitudinal angle of the camera */
  38009. alpha: number,
  38010. /** The latitudinal angle of the camera */
  38011. beta: number,
  38012. /** The radius of the camera from its target */
  38013. radius: number,
  38014. /** Define the camera target (the messh it should follow) */
  38015. target: Nullable<AbstractMesh>, scene: Scene);
  38016. private _follow;
  38017. /** @hidden */
  38018. _checkInputs(): void;
  38019. /**
  38020. * Returns the class name of the object.
  38021. * It is mostly used internally for serialization purposes.
  38022. */
  38023. getClassName(): string;
  38024. }
  38025. }
  38026. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38027. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38028. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38029. import { Nullable } from "babylonjs/types";
  38030. /**
  38031. * Manage the keyboard inputs to control the movement of a follow camera.
  38032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38033. */
  38034. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38035. /**
  38036. * Defines the camera the input is attached to.
  38037. */
  38038. camera: FollowCamera;
  38039. /**
  38040. * Defines the list of key codes associated with the up action (increase heightOffset)
  38041. */
  38042. keysHeightOffsetIncr: number[];
  38043. /**
  38044. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38045. */
  38046. keysHeightOffsetDecr: number[];
  38047. /**
  38048. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38049. */
  38050. keysHeightOffsetModifierAlt: boolean;
  38051. /**
  38052. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38053. */
  38054. keysHeightOffsetModifierCtrl: boolean;
  38055. /**
  38056. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38057. */
  38058. keysHeightOffsetModifierShift: boolean;
  38059. /**
  38060. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38061. */
  38062. keysRotationOffsetIncr: number[];
  38063. /**
  38064. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38065. */
  38066. keysRotationOffsetDecr: number[];
  38067. /**
  38068. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38069. */
  38070. keysRotationOffsetModifierAlt: boolean;
  38071. /**
  38072. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38073. */
  38074. keysRotationOffsetModifierCtrl: boolean;
  38075. /**
  38076. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38077. */
  38078. keysRotationOffsetModifierShift: boolean;
  38079. /**
  38080. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38081. */
  38082. keysRadiusIncr: number[];
  38083. /**
  38084. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38085. */
  38086. keysRadiusDecr: number[];
  38087. /**
  38088. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38089. */
  38090. keysRadiusModifierAlt: boolean;
  38091. /**
  38092. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38093. */
  38094. keysRadiusModifierCtrl: boolean;
  38095. /**
  38096. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38097. */
  38098. keysRadiusModifierShift: boolean;
  38099. /**
  38100. * Defines the rate of change of heightOffset.
  38101. */
  38102. heightSensibility: number;
  38103. /**
  38104. * Defines the rate of change of rotationOffset.
  38105. */
  38106. rotationSensibility: number;
  38107. /**
  38108. * Defines the rate of change of radius.
  38109. */
  38110. radiusSensibility: number;
  38111. private _keys;
  38112. private _ctrlPressed;
  38113. private _altPressed;
  38114. private _shiftPressed;
  38115. private _onCanvasBlurObserver;
  38116. private _onKeyboardObserver;
  38117. private _engine;
  38118. private _scene;
  38119. /**
  38120. * Attach the input controls to a specific dom element to get the input from.
  38121. * @param element Defines the element the controls should be listened from
  38122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38123. */
  38124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38125. /**
  38126. * Detach the current controls from the specified dom element.
  38127. * @param element Defines the element to stop listening the inputs from
  38128. */
  38129. detachControl(element: Nullable<HTMLElement>): void;
  38130. /**
  38131. * Update the current camera state depending on the inputs that have been used this frame.
  38132. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38133. */
  38134. checkInputs(): void;
  38135. /**
  38136. * Gets the class name of the current input.
  38137. * @returns the class name
  38138. */
  38139. getClassName(): string;
  38140. /**
  38141. * Get the friendly name associated with the input class.
  38142. * @returns the input friendly name
  38143. */
  38144. getSimpleName(): string;
  38145. /**
  38146. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38147. * allow modification of the heightOffset value.
  38148. */
  38149. private _modifierHeightOffset;
  38150. /**
  38151. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38152. * allow modification of the rotationOffset value.
  38153. */
  38154. private _modifierRotationOffset;
  38155. /**
  38156. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38157. * allow modification of the radius value.
  38158. */
  38159. private _modifierRadius;
  38160. }
  38161. }
  38162. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38163. import { Nullable } from "babylonjs/types";
  38164. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38165. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38166. import { Observable } from "babylonjs/Misc/observable";
  38167. module "babylonjs/Cameras/freeCameraInputsManager" {
  38168. interface FreeCameraInputsManager {
  38169. /**
  38170. * @hidden
  38171. */
  38172. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38173. /**
  38174. * Add orientation input support to the input manager.
  38175. * @returns the current input manager
  38176. */
  38177. addDeviceOrientation(): FreeCameraInputsManager;
  38178. }
  38179. }
  38180. /**
  38181. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38182. * Screen rotation is taken into account.
  38183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38184. */
  38185. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38186. private _camera;
  38187. private _screenOrientationAngle;
  38188. private _constantTranform;
  38189. private _screenQuaternion;
  38190. private _alpha;
  38191. private _beta;
  38192. private _gamma;
  38193. /**
  38194. * @hidden
  38195. */
  38196. _onDeviceOrientationChangedObservable: Observable<void>;
  38197. /**
  38198. * Instantiates a new input
  38199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38200. */
  38201. constructor();
  38202. /**
  38203. * Define the camera controlled by the input.
  38204. */
  38205. camera: FreeCamera;
  38206. /**
  38207. * Attach the input controls to a specific dom element to get the input from.
  38208. * @param element Defines the element the controls should be listened from
  38209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38210. */
  38211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38212. private _orientationChanged;
  38213. private _deviceOrientation;
  38214. /**
  38215. * Detach the current controls from the specified dom element.
  38216. * @param element Defines the element to stop listening the inputs from
  38217. */
  38218. detachControl(element: Nullable<HTMLElement>): void;
  38219. /**
  38220. * Update the current camera state depending on the inputs that have been used this frame.
  38221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38222. */
  38223. checkInputs(): void;
  38224. /**
  38225. * Gets the class name of the current intput.
  38226. * @returns the class name
  38227. */
  38228. getClassName(): string;
  38229. /**
  38230. * Get the friendly name associated with the input class.
  38231. * @returns the input friendly name
  38232. */
  38233. getSimpleName(): string;
  38234. }
  38235. }
  38236. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38237. import { Nullable } from "babylonjs/types";
  38238. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38239. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38240. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38241. /**
  38242. * Manage the gamepad inputs to control a free camera.
  38243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38244. */
  38245. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38246. /**
  38247. * Define the camera the input is attached to.
  38248. */
  38249. camera: FreeCamera;
  38250. /**
  38251. * Define the Gamepad controlling the input
  38252. */
  38253. gamepad: Nullable<Gamepad>;
  38254. /**
  38255. * Defines the gamepad rotation sensiblity.
  38256. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38257. */
  38258. gamepadAngularSensibility: number;
  38259. /**
  38260. * Defines the gamepad move sensiblity.
  38261. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38262. */
  38263. gamepadMoveSensibility: number;
  38264. private _onGamepadConnectedObserver;
  38265. private _onGamepadDisconnectedObserver;
  38266. private _cameraTransform;
  38267. private _deltaTransform;
  38268. private _vector3;
  38269. private _vector2;
  38270. /**
  38271. * Attach the input controls to a specific dom element to get the input from.
  38272. * @param element Defines the element the controls should be listened from
  38273. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38274. */
  38275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38276. /**
  38277. * Detach the current controls from the specified dom element.
  38278. * @param element Defines the element to stop listening the inputs from
  38279. */
  38280. detachControl(element: Nullable<HTMLElement>): void;
  38281. /**
  38282. * Update the current camera state depending on the inputs that have been used this frame.
  38283. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38284. */
  38285. checkInputs(): void;
  38286. /**
  38287. * Gets the class name of the current intput.
  38288. * @returns the class name
  38289. */
  38290. getClassName(): string;
  38291. /**
  38292. * Get the friendly name associated with the input class.
  38293. * @returns the input friendly name
  38294. */
  38295. getSimpleName(): string;
  38296. }
  38297. }
  38298. declare module "babylonjs/Misc/virtualJoystick" {
  38299. import { Nullable } from "babylonjs/types";
  38300. import { Vector3 } from "babylonjs/Maths/math";
  38301. /**
  38302. * Defines the potential axis of a Joystick
  38303. */
  38304. export enum JoystickAxis {
  38305. /** X axis */
  38306. X = 0,
  38307. /** Y axis */
  38308. Y = 1,
  38309. /** Z axis */
  38310. Z = 2
  38311. }
  38312. /**
  38313. * Class used to define virtual joystick (used in touch mode)
  38314. */
  38315. export class VirtualJoystick {
  38316. /**
  38317. * Gets or sets a boolean indicating that left and right values must be inverted
  38318. */
  38319. reverseLeftRight: boolean;
  38320. /**
  38321. * Gets or sets a boolean indicating that up and down values must be inverted
  38322. */
  38323. reverseUpDown: boolean;
  38324. /**
  38325. * Gets the offset value for the position (ie. the change of the position value)
  38326. */
  38327. deltaPosition: Vector3;
  38328. /**
  38329. * Gets a boolean indicating if the virtual joystick was pressed
  38330. */
  38331. pressed: boolean;
  38332. /**
  38333. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38334. */
  38335. static Canvas: Nullable<HTMLCanvasElement>;
  38336. private static _globalJoystickIndex;
  38337. private static vjCanvasContext;
  38338. private static vjCanvasWidth;
  38339. private static vjCanvasHeight;
  38340. private static halfWidth;
  38341. private _action;
  38342. private _axisTargetedByLeftAndRight;
  38343. private _axisTargetedByUpAndDown;
  38344. private _joystickSensibility;
  38345. private _inversedSensibility;
  38346. private _joystickPointerID;
  38347. private _joystickColor;
  38348. private _joystickPointerPos;
  38349. private _joystickPreviousPointerPos;
  38350. private _joystickPointerStartPos;
  38351. private _deltaJoystickVector;
  38352. private _leftJoystick;
  38353. private _touches;
  38354. private _onPointerDownHandlerRef;
  38355. private _onPointerMoveHandlerRef;
  38356. private _onPointerUpHandlerRef;
  38357. private _onResize;
  38358. /**
  38359. * Creates a new virtual joystick
  38360. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38361. */
  38362. constructor(leftJoystick?: boolean);
  38363. /**
  38364. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38365. * @param newJoystickSensibility defines the new sensibility
  38366. */
  38367. setJoystickSensibility(newJoystickSensibility: number): void;
  38368. private _onPointerDown;
  38369. private _onPointerMove;
  38370. private _onPointerUp;
  38371. /**
  38372. * Change the color of the virtual joystick
  38373. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38374. */
  38375. setJoystickColor(newColor: string): void;
  38376. /**
  38377. * Defines a callback to call when the joystick is touched
  38378. * @param action defines the callback
  38379. */
  38380. setActionOnTouch(action: () => any): void;
  38381. /**
  38382. * Defines which axis you'd like to control for left & right
  38383. * @param axis defines the axis to use
  38384. */
  38385. setAxisForLeftRight(axis: JoystickAxis): void;
  38386. /**
  38387. * Defines which axis you'd like to control for up & down
  38388. * @param axis defines the axis to use
  38389. */
  38390. setAxisForUpDown(axis: JoystickAxis): void;
  38391. private _drawVirtualJoystick;
  38392. /**
  38393. * Release internal HTML canvas
  38394. */
  38395. releaseCanvas(): void;
  38396. }
  38397. }
  38398. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38399. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38400. import { Nullable } from "babylonjs/types";
  38401. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38402. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38403. module "babylonjs/Cameras/freeCameraInputsManager" {
  38404. interface FreeCameraInputsManager {
  38405. /**
  38406. * Add virtual joystick input support to the input manager.
  38407. * @returns the current input manager
  38408. */
  38409. addVirtualJoystick(): FreeCameraInputsManager;
  38410. }
  38411. }
  38412. /**
  38413. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38415. */
  38416. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38417. /**
  38418. * Defines the camera the input is attached to.
  38419. */
  38420. camera: FreeCamera;
  38421. private _leftjoystick;
  38422. private _rightjoystick;
  38423. /**
  38424. * Gets the left stick of the virtual joystick.
  38425. * @returns The virtual Joystick
  38426. */
  38427. getLeftJoystick(): VirtualJoystick;
  38428. /**
  38429. * Gets the right stick of the virtual joystick.
  38430. * @returns The virtual Joystick
  38431. */
  38432. getRightJoystick(): VirtualJoystick;
  38433. /**
  38434. * Update the current camera state depending on the inputs that have been used this frame.
  38435. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38436. */
  38437. checkInputs(): void;
  38438. /**
  38439. * Attach the input controls to a specific dom element to get the input from.
  38440. * @param element Defines the element the controls should be listened from
  38441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38442. */
  38443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38444. /**
  38445. * Detach the current controls from the specified dom element.
  38446. * @param element Defines the element to stop listening the inputs from
  38447. */
  38448. detachControl(element: Nullable<HTMLElement>): void;
  38449. /**
  38450. * Gets the class name of the current intput.
  38451. * @returns the class name
  38452. */
  38453. getClassName(): string;
  38454. /**
  38455. * Get the friendly name associated with the input class.
  38456. * @returns the input friendly name
  38457. */
  38458. getSimpleName(): string;
  38459. }
  38460. }
  38461. declare module "babylonjs/Cameras/Inputs/index" {
  38462. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38463. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38464. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38465. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38466. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38467. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38468. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38469. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38470. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38471. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38472. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38473. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38474. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38475. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38476. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38477. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38478. }
  38479. declare module "babylonjs/Cameras/touchCamera" {
  38480. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38481. import { Scene } from "babylonjs/scene";
  38482. import { Vector3 } from "babylonjs/Maths/math";
  38483. /**
  38484. * This represents a FPS type of camera controlled by touch.
  38485. * This is like a universal camera minus the Gamepad controls.
  38486. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38487. */
  38488. export class TouchCamera extends FreeCamera {
  38489. /**
  38490. * Defines the touch sensibility for rotation.
  38491. * The higher the faster.
  38492. */
  38493. touchAngularSensibility: number;
  38494. /**
  38495. * Defines the touch sensibility for move.
  38496. * The higher the faster.
  38497. */
  38498. touchMoveSensibility: number;
  38499. /**
  38500. * Instantiates a new touch camera.
  38501. * This represents a FPS type of camera controlled by touch.
  38502. * This is like a universal camera minus the Gamepad controls.
  38503. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38504. * @param name Define the name of the camera in the scene
  38505. * @param position Define the start position of the camera in the scene
  38506. * @param scene Define the scene the camera belongs to
  38507. */
  38508. constructor(name: string, position: Vector3, scene: Scene);
  38509. /**
  38510. * Gets the current object class name.
  38511. * @return the class name
  38512. */
  38513. getClassName(): string;
  38514. /** @hidden */
  38515. _setupInputs(): void;
  38516. }
  38517. }
  38518. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38519. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38520. import { Scene } from "babylonjs/scene";
  38521. import { Vector3, Axis } from "babylonjs/Maths/math";
  38522. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38523. /**
  38524. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38525. * being tilted forward or back and left or right.
  38526. */
  38527. export class DeviceOrientationCamera extends FreeCamera {
  38528. private _initialQuaternion;
  38529. private _quaternionCache;
  38530. private _tmpDragQuaternion;
  38531. /**
  38532. * Creates a new device orientation camera
  38533. * @param name The name of the camera
  38534. * @param position The start position camera
  38535. * @param scene The scene the camera belongs to
  38536. */
  38537. constructor(name: string, position: Vector3, scene: Scene);
  38538. /**
  38539. * @hidden
  38540. * Disabled pointer input on first orientation sensor update (Default: true)
  38541. */
  38542. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38543. private _dragFactor;
  38544. /**
  38545. * Enabled turning on the y axis when the orientation sensor is active
  38546. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38547. */
  38548. enableHorizontalDragging(dragFactor?: number): void;
  38549. /**
  38550. * Gets the current instance class name ("DeviceOrientationCamera").
  38551. * This helps avoiding instanceof at run time.
  38552. * @returns the class name
  38553. */
  38554. getClassName(): string;
  38555. /**
  38556. * @hidden
  38557. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38558. */
  38559. _checkInputs(): void;
  38560. /**
  38561. * Reset the camera to its default orientation on the specified axis only.
  38562. * @param axis The axis to reset
  38563. */
  38564. resetToCurrentRotation(axis?: Axis): void;
  38565. }
  38566. }
  38567. declare module "babylonjs/Cameras/universalCamera" {
  38568. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38569. import { Scene } from "babylonjs/scene";
  38570. import { Vector3 } from "babylonjs/Maths/math";
  38571. /**
  38572. * 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,
  38573. * which still works and will still be found in many Playgrounds.
  38574. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38575. */
  38576. export class UniversalCamera extends TouchCamera {
  38577. /**
  38578. * Defines the gamepad rotation sensiblity.
  38579. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38580. */
  38581. gamepadAngularSensibility: number;
  38582. /**
  38583. * Defines the gamepad move sensiblity.
  38584. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38585. */
  38586. gamepadMoveSensibility: number;
  38587. /**
  38588. * 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,
  38589. * which still works and will still be found in many Playgrounds.
  38590. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38591. * @param name Define the name of the camera in the scene
  38592. * @param position Define the start position of the camera in the scene
  38593. * @param scene Define the scene the camera belongs to
  38594. */
  38595. constructor(name: string, position: Vector3, scene: Scene);
  38596. /**
  38597. * Gets the current object class name.
  38598. * @return the class name
  38599. */
  38600. getClassName(): string;
  38601. }
  38602. }
  38603. declare module "babylonjs/Cameras/gamepadCamera" {
  38604. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38605. import { Scene } from "babylonjs/scene";
  38606. import { Vector3 } from "babylonjs/Maths/math";
  38607. /**
  38608. * This represents a FPS type of camera. This is only here for back compat purpose.
  38609. * Please use the UniversalCamera instead as both are identical.
  38610. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38611. */
  38612. export class GamepadCamera extends UniversalCamera {
  38613. /**
  38614. * Instantiates a new Gamepad Camera
  38615. * This represents a FPS type of camera. This is only here for back compat purpose.
  38616. * Please use the UniversalCamera instead as both are identical.
  38617. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38618. * @param name Define the name of the camera in the scene
  38619. * @param position Define the start position of the camera in the scene
  38620. * @param scene Define the scene the camera belongs to
  38621. */
  38622. constructor(name: string, position: Vector3, scene: Scene);
  38623. /**
  38624. * Gets the current object class name.
  38625. * @return the class name
  38626. */
  38627. getClassName(): string;
  38628. }
  38629. }
  38630. declare module "babylonjs/Shaders/pass.fragment" {
  38631. /** @hidden */
  38632. export var passPixelShader: {
  38633. name: string;
  38634. shader: string;
  38635. };
  38636. }
  38637. declare module "babylonjs/Shaders/passCube.fragment" {
  38638. /** @hidden */
  38639. export var passCubePixelShader: {
  38640. name: string;
  38641. shader: string;
  38642. };
  38643. }
  38644. declare module "babylonjs/PostProcesses/passPostProcess" {
  38645. import { Nullable } from "babylonjs/types";
  38646. import { Camera } from "babylonjs/Cameras/camera";
  38647. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38648. import { Engine } from "babylonjs/Engines/engine";
  38649. import "babylonjs/Shaders/pass.fragment";
  38650. import "babylonjs/Shaders/passCube.fragment";
  38651. /**
  38652. * PassPostProcess which produces an output the same as it's input
  38653. */
  38654. export class PassPostProcess extends PostProcess {
  38655. /**
  38656. * Creates the PassPostProcess
  38657. * @param name The name of the effect.
  38658. * @param options The required width/height ratio to downsize to before computing the render pass.
  38659. * @param camera The camera to apply the render pass to.
  38660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38661. * @param engine The engine which the post process will be applied. (default: current engine)
  38662. * @param reusable If the post process can be reused on the same frame. (default: false)
  38663. * @param textureType The type of texture to be used when performing the post processing.
  38664. * @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)
  38665. */
  38666. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38667. }
  38668. /**
  38669. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38670. */
  38671. export class PassCubePostProcess extends PostProcess {
  38672. private _face;
  38673. /**
  38674. * Gets or sets the cube face to display.
  38675. * * 0 is +X
  38676. * * 1 is -X
  38677. * * 2 is +Y
  38678. * * 3 is -Y
  38679. * * 4 is +Z
  38680. * * 5 is -Z
  38681. */
  38682. face: number;
  38683. /**
  38684. * Creates the PassCubePostProcess
  38685. * @param name The name of the effect.
  38686. * @param options The required width/height ratio to downsize to before computing the render pass.
  38687. * @param camera The camera to apply the render pass to.
  38688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38689. * @param engine The engine which the post process will be applied. (default: current engine)
  38690. * @param reusable If the post process can be reused on the same frame. (default: false)
  38691. * @param textureType The type of texture to be used when performing the post processing.
  38692. * @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)
  38693. */
  38694. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38695. }
  38696. }
  38697. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38698. /** @hidden */
  38699. export var anaglyphPixelShader: {
  38700. name: string;
  38701. shader: string;
  38702. };
  38703. }
  38704. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38705. import { Engine } from "babylonjs/Engines/engine";
  38706. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38707. import { Camera } from "babylonjs/Cameras/camera";
  38708. import "babylonjs/Shaders/anaglyph.fragment";
  38709. /**
  38710. * Postprocess used to generate anaglyphic rendering
  38711. */
  38712. export class AnaglyphPostProcess extends PostProcess {
  38713. private _passedProcess;
  38714. /**
  38715. * Creates a new AnaglyphPostProcess
  38716. * @param name defines postprocess name
  38717. * @param options defines creation options or target ratio scale
  38718. * @param rigCameras defines cameras using this postprocess
  38719. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38720. * @param engine defines hosting engine
  38721. * @param reusable defines if the postprocess will be reused multiple times per frame
  38722. */
  38723. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38724. }
  38725. }
  38726. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38727. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38728. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38729. import { Scene } from "babylonjs/scene";
  38730. import { Vector3 } from "babylonjs/Maths/math";
  38731. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38732. /**
  38733. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38734. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38735. */
  38736. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38737. /**
  38738. * Creates a new AnaglyphArcRotateCamera
  38739. * @param name defines camera name
  38740. * @param alpha defines alpha angle (in radians)
  38741. * @param beta defines beta angle (in radians)
  38742. * @param radius defines radius
  38743. * @param target defines camera target
  38744. * @param interaxialDistance defines distance between each color axis
  38745. * @param scene defines the hosting scene
  38746. */
  38747. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38748. /**
  38749. * Gets camera class name
  38750. * @returns AnaglyphArcRotateCamera
  38751. */
  38752. getClassName(): string;
  38753. }
  38754. }
  38755. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38756. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38757. import { Scene } from "babylonjs/scene";
  38758. import { Vector3 } from "babylonjs/Maths/math";
  38759. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38760. /**
  38761. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38762. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38763. */
  38764. export class AnaglyphFreeCamera extends FreeCamera {
  38765. /**
  38766. * Creates a new AnaglyphFreeCamera
  38767. * @param name defines camera name
  38768. * @param position defines initial position
  38769. * @param interaxialDistance defines distance between each color axis
  38770. * @param scene defines the hosting scene
  38771. */
  38772. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38773. /**
  38774. * Gets camera class name
  38775. * @returns AnaglyphFreeCamera
  38776. */
  38777. getClassName(): string;
  38778. }
  38779. }
  38780. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38781. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38782. import { Scene } from "babylonjs/scene";
  38783. import { Vector3 } from "babylonjs/Maths/math";
  38784. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38785. /**
  38786. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38787. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38788. */
  38789. export class AnaglyphGamepadCamera extends GamepadCamera {
  38790. /**
  38791. * Creates a new AnaglyphGamepadCamera
  38792. * @param name defines camera name
  38793. * @param position defines initial position
  38794. * @param interaxialDistance defines distance between each color axis
  38795. * @param scene defines the hosting scene
  38796. */
  38797. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38798. /**
  38799. * Gets camera class name
  38800. * @returns AnaglyphGamepadCamera
  38801. */
  38802. getClassName(): string;
  38803. }
  38804. }
  38805. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38806. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38807. import { Scene } from "babylonjs/scene";
  38808. import { Vector3 } from "babylonjs/Maths/math";
  38809. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38810. /**
  38811. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38812. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38813. */
  38814. export class AnaglyphUniversalCamera extends UniversalCamera {
  38815. /**
  38816. * Creates a new AnaglyphUniversalCamera
  38817. * @param name defines camera name
  38818. * @param position defines initial position
  38819. * @param interaxialDistance defines distance between each color axis
  38820. * @param scene defines the hosting scene
  38821. */
  38822. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38823. /**
  38824. * Gets camera class name
  38825. * @returns AnaglyphUniversalCamera
  38826. */
  38827. getClassName(): string;
  38828. }
  38829. }
  38830. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38831. /** @hidden */
  38832. export var stereoscopicInterlacePixelShader: {
  38833. name: string;
  38834. shader: string;
  38835. };
  38836. }
  38837. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38838. import { Camera } from "babylonjs/Cameras/camera";
  38839. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38840. import { Engine } from "babylonjs/Engines/engine";
  38841. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38842. /**
  38843. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38844. */
  38845. export class StereoscopicInterlacePostProcess extends PostProcess {
  38846. private _stepSize;
  38847. private _passedProcess;
  38848. /**
  38849. * Initializes a StereoscopicInterlacePostProcess
  38850. * @param name The name of the effect.
  38851. * @param rigCameras The rig cameras to be appled to the post process
  38852. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38854. * @param engine The engine which the post process will be applied. (default: current engine)
  38855. * @param reusable If the post process can be reused on the same frame. (default: false)
  38856. */
  38857. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38858. }
  38859. }
  38860. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38861. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38862. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38863. import { Scene } from "babylonjs/scene";
  38864. import { Vector3 } from "babylonjs/Maths/math";
  38865. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38866. /**
  38867. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38868. * @see http://doc.babylonjs.com/features/cameras
  38869. */
  38870. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38871. /**
  38872. * Creates a new StereoscopicArcRotateCamera
  38873. * @param name defines camera name
  38874. * @param alpha defines alpha angle (in radians)
  38875. * @param beta defines beta angle (in radians)
  38876. * @param radius defines radius
  38877. * @param target defines camera target
  38878. * @param interaxialDistance defines distance between each color axis
  38879. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38880. * @param scene defines the hosting scene
  38881. */
  38882. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38883. /**
  38884. * Gets camera class name
  38885. * @returns StereoscopicArcRotateCamera
  38886. */
  38887. getClassName(): string;
  38888. }
  38889. }
  38890. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38891. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38892. import { Scene } from "babylonjs/scene";
  38893. import { Vector3 } from "babylonjs/Maths/math";
  38894. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38895. /**
  38896. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38897. * @see http://doc.babylonjs.com/features/cameras
  38898. */
  38899. export class StereoscopicFreeCamera extends FreeCamera {
  38900. /**
  38901. * Creates a new StereoscopicFreeCamera
  38902. * @param name defines camera name
  38903. * @param position defines initial position
  38904. * @param interaxialDistance defines distance between each color axis
  38905. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38906. * @param scene defines the hosting scene
  38907. */
  38908. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38909. /**
  38910. * Gets camera class name
  38911. * @returns StereoscopicFreeCamera
  38912. */
  38913. getClassName(): string;
  38914. }
  38915. }
  38916. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38917. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38918. import { Scene } from "babylonjs/scene";
  38919. import { Vector3 } from "babylonjs/Maths/math";
  38920. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38921. /**
  38922. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38923. * @see http://doc.babylonjs.com/features/cameras
  38924. */
  38925. export class StereoscopicGamepadCamera extends GamepadCamera {
  38926. /**
  38927. * Creates a new StereoscopicGamepadCamera
  38928. * @param name defines camera name
  38929. * @param position defines initial position
  38930. * @param interaxialDistance defines distance between each color axis
  38931. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38932. * @param scene defines the hosting scene
  38933. */
  38934. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38935. /**
  38936. * Gets camera class name
  38937. * @returns StereoscopicGamepadCamera
  38938. */
  38939. getClassName(): string;
  38940. }
  38941. }
  38942. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38943. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38944. import { Scene } from "babylonjs/scene";
  38945. import { Vector3 } from "babylonjs/Maths/math";
  38946. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38947. /**
  38948. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38949. * @see http://doc.babylonjs.com/features/cameras
  38950. */
  38951. export class StereoscopicUniversalCamera extends UniversalCamera {
  38952. /**
  38953. * Creates a new StereoscopicUniversalCamera
  38954. * @param name defines camera name
  38955. * @param position defines initial position
  38956. * @param interaxialDistance defines distance between each color axis
  38957. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38958. * @param scene defines the hosting scene
  38959. */
  38960. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38961. /**
  38962. * Gets camera class name
  38963. * @returns StereoscopicUniversalCamera
  38964. */
  38965. getClassName(): string;
  38966. }
  38967. }
  38968. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38969. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38970. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38971. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38972. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38973. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38974. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38975. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38976. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38977. }
  38978. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38979. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38980. import { Scene } from "babylonjs/scene";
  38981. import { Vector3 } from "babylonjs/Maths/math";
  38982. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38983. /**
  38984. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38985. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38986. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38987. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38988. */
  38989. export class VirtualJoysticksCamera extends FreeCamera {
  38990. /**
  38991. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38992. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38993. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38994. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38995. * @param name Define the name of the camera in the scene
  38996. * @param position Define the start position of the camera in the scene
  38997. * @param scene Define the scene the camera belongs to
  38998. */
  38999. constructor(name: string, position: Vector3, scene: Scene);
  39000. /**
  39001. * Gets the current object class name.
  39002. * @return the class name
  39003. */
  39004. getClassName(): string;
  39005. }
  39006. }
  39007. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39008. import { Matrix } from "babylonjs/Maths/math";
  39009. /**
  39010. * This represents all the required metrics to create a VR camera.
  39011. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39012. */
  39013. export class VRCameraMetrics {
  39014. /**
  39015. * Define the horizontal resolution off the screen.
  39016. */
  39017. hResolution: number;
  39018. /**
  39019. * Define the vertical resolution off the screen.
  39020. */
  39021. vResolution: number;
  39022. /**
  39023. * Define the horizontal screen size.
  39024. */
  39025. hScreenSize: number;
  39026. /**
  39027. * Define the vertical screen size.
  39028. */
  39029. vScreenSize: number;
  39030. /**
  39031. * Define the vertical screen center position.
  39032. */
  39033. vScreenCenter: number;
  39034. /**
  39035. * Define the distance of the eyes to the screen.
  39036. */
  39037. eyeToScreenDistance: number;
  39038. /**
  39039. * Define the distance between both lenses
  39040. */
  39041. lensSeparationDistance: number;
  39042. /**
  39043. * Define the distance between both viewer's eyes.
  39044. */
  39045. interpupillaryDistance: number;
  39046. /**
  39047. * Define the distortion factor of the VR postprocess.
  39048. * Please, touch with care.
  39049. */
  39050. distortionK: number[];
  39051. /**
  39052. * Define the chromatic aberration correction factors for the VR post process.
  39053. */
  39054. chromaAbCorrection: number[];
  39055. /**
  39056. * Define the scale factor of the post process.
  39057. * The smaller the better but the slower.
  39058. */
  39059. postProcessScaleFactor: number;
  39060. /**
  39061. * Define an offset for the lens center.
  39062. */
  39063. lensCenterOffset: number;
  39064. /**
  39065. * Define if the current vr camera should compensate the distortion of the lense or not.
  39066. */
  39067. compensateDistortion: boolean;
  39068. /**
  39069. * Defines if multiview should be enabled when rendering (Default: false)
  39070. */
  39071. multiviewEnabled: boolean;
  39072. /**
  39073. * Gets the rendering aspect ratio based on the provided resolutions.
  39074. */
  39075. readonly aspectRatio: number;
  39076. /**
  39077. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39078. */
  39079. readonly aspectRatioFov: number;
  39080. /**
  39081. * @hidden
  39082. */
  39083. readonly leftHMatrix: Matrix;
  39084. /**
  39085. * @hidden
  39086. */
  39087. readonly rightHMatrix: Matrix;
  39088. /**
  39089. * @hidden
  39090. */
  39091. readonly leftPreViewMatrix: Matrix;
  39092. /**
  39093. * @hidden
  39094. */
  39095. readonly rightPreViewMatrix: Matrix;
  39096. /**
  39097. * Get the default VRMetrics based on the most generic setup.
  39098. * @returns the default vr metrics
  39099. */
  39100. static GetDefault(): VRCameraMetrics;
  39101. }
  39102. }
  39103. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39104. /** @hidden */
  39105. export var vrDistortionCorrectionPixelShader: {
  39106. name: string;
  39107. shader: string;
  39108. };
  39109. }
  39110. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39111. import { Camera } from "babylonjs/Cameras/camera";
  39112. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39113. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39114. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39115. /**
  39116. * VRDistortionCorrectionPostProcess used for mobile VR
  39117. */
  39118. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39119. private _isRightEye;
  39120. private _distortionFactors;
  39121. private _postProcessScaleFactor;
  39122. private _lensCenterOffset;
  39123. private _scaleIn;
  39124. private _scaleFactor;
  39125. private _lensCenter;
  39126. /**
  39127. * Initializes the VRDistortionCorrectionPostProcess
  39128. * @param name The name of the effect.
  39129. * @param camera The camera to apply the render pass to.
  39130. * @param isRightEye If this is for the right eye distortion
  39131. * @param vrMetrics All the required metrics for the VR camera
  39132. */
  39133. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39134. }
  39135. }
  39136. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39137. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39138. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39139. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39140. import { Scene } from "babylonjs/scene";
  39141. import { Vector3 } from "babylonjs/Maths/math";
  39142. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39143. import "babylonjs/Cameras/RigModes/vrRigMode";
  39144. /**
  39145. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39146. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39147. */
  39148. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39149. /**
  39150. * Creates a new VRDeviceOrientationArcRotateCamera
  39151. * @param name defines camera name
  39152. * @param alpha defines the camera rotation along the logitudinal axis
  39153. * @param beta defines the camera rotation along the latitudinal axis
  39154. * @param radius defines the camera distance from its target
  39155. * @param target defines the camera target
  39156. * @param scene defines the scene the camera belongs to
  39157. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39158. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39159. */
  39160. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39161. /**
  39162. * Gets camera class name
  39163. * @returns VRDeviceOrientationArcRotateCamera
  39164. */
  39165. getClassName(): string;
  39166. }
  39167. }
  39168. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39169. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39170. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39171. import { Scene } from "babylonjs/scene";
  39172. import { Vector3 } from "babylonjs/Maths/math";
  39173. import "babylonjs/Cameras/RigModes/vrRigMode";
  39174. /**
  39175. * Camera used to simulate VR rendering (based on FreeCamera)
  39176. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39177. */
  39178. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39179. /**
  39180. * Creates a new VRDeviceOrientationFreeCamera
  39181. * @param name defines camera name
  39182. * @param position defines the start position of the camera
  39183. * @param scene defines the scene the camera belongs to
  39184. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39185. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39186. */
  39187. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39188. /**
  39189. * Gets camera class name
  39190. * @returns VRDeviceOrientationFreeCamera
  39191. */
  39192. getClassName(): string;
  39193. }
  39194. }
  39195. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39196. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39197. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39198. import { Scene } from "babylonjs/scene";
  39199. import { Vector3 } from "babylonjs/Maths/math";
  39200. /**
  39201. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39202. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39203. */
  39204. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39205. /**
  39206. * Creates a new VRDeviceOrientationGamepadCamera
  39207. * @param name defines camera name
  39208. * @param position defines the start position of the camera
  39209. * @param scene defines the scene the camera belongs to
  39210. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39211. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39212. */
  39213. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39214. /**
  39215. * Gets camera class name
  39216. * @returns VRDeviceOrientationGamepadCamera
  39217. */
  39218. getClassName(): string;
  39219. }
  39220. }
  39221. declare module "babylonjs/Gamepads/xboxGamepad" {
  39222. import { Observable } from "babylonjs/Misc/observable";
  39223. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39224. /**
  39225. * Defines supported buttons for XBox360 compatible gamepads
  39226. */
  39227. export enum Xbox360Button {
  39228. /** A */
  39229. A = 0,
  39230. /** B */
  39231. B = 1,
  39232. /** X */
  39233. X = 2,
  39234. /** Y */
  39235. Y = 3,
  39236. /** Start */
  39237. Start = 4,
  39238. /** Back */
  39239. Back = 5,
  39240. /** Left button */
  39241. LB = 6,
  39242. /** Right button */
  39243. RB = 7,
  39244. /** Left stick */
  39245. LeftStick = 8,
  39246. /** Right stick */
  39247. RightStick = 9
  39248. }
  39249. /** Defines values for XBox360 DPad */
  39250. export enum Xbox360Dpad {
  39251. /** Up */
  39252. Up = 0,
  39253. /** Down */
  39254. Down = 1,
  39255. /** Left */
  39256. Left = 2,
  39257. /** Right */
  39258. Right = 3
  39259. }
  39260. /**
  39261. * Defines a XBox360 gamepad
  39262. */
  39263. export class Xbox360Pad extends Gamepad {
  39264. private _leftTrigger;
  39265. private _rightTrigger;
  39266. private _onlefttriggerchanged;
  39267. private _onrighttriggerchanged;
  39268. private _onbuttondown;
  39269. private _onbuttonup;
  39270. private _ondpaddown;
  39271. private _ondpadup;
  39272. /** Observable raised when a button is pressed */
  39273. onButtonDownObservable: Observable<Xbox360Button>;
  39274. /** Observable raised when a button is released */
  39275. onButtonUpObservable: Observable<Xbox360Button>;
  39276. /** Observable raised when a pad is pressed */
  39277. onPadDownObservable: Observable<Xbox360Dpad>;
  39278. /** Observable raised when a pad is released */
  39279. onPadUpObservable: Observable<Xbox360Dpad>;
  39280. private _buttonA;
  39281. private _buttonB;
  39282. private _buttonX;
  39283. private _buttonY;
  39284. private _buttonBack;
  39285. private _buttonStart;
  39286. private _buttonLB;
  39287. private _buttonRB;
  39288. private _buttonLeftStick;
  39289. private _buttonRightStick;
  39290. private _dPadUp;
  39291. private _dPadDown;
  39292. private _dPadLeft;
  39293. private _dPadRight;
  39294. private _isXboxOnePad;
  39295. /**
  39296. * Creates a new XBox360 gamepad object
  39297. * @param id defines the id of this gamepad
  39298. * @param index defines its index
  39299. * @param gamepad defines the internal HTML gamepad object
  39300. * @param xboxOne defines if it is a XBox One gamepad
  39301. */
  39302. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39303. /**
  39304. * Defines the callback to call when left trigger is pressed
  39305. * @param callback defines the callback to use
  39306. */
  39307. onlefttriggerchanged(callback: (value: number) => void): void;
  39308. /**
  39309. * Defines the callback to call when right trigger is pressed
  39310. * @param callback defines the callback to use
  39311. */
  39312. onrighttriggerchanged(callback: (value: number) => void): void;
  39313. /**
  39314. * Gets the left trigger value
  39315. */
  39316. /**
  39317. * Sets the left trigger value
  39318. */
  39319. leftTrigger: number;
  39320. /**
  39321. * Gets the right trigger value
  39322. */
  39323. /**
  39324. * Sets the right trigger value
  39325. */
  39326. rightTrigger: number;
  39327. /**
  39328. * Defines the callback to call when a button is pressed
  39329. * @param callback defines the callback to use
  39330. */
  39331. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39332. /**
  39333. * Defines the callback to call when a button is released
  39334. * @param callback defines the callback to use
  39335. */
  39336. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39337. /**
  39338. * Defines the callback to call when a pad is pressed
  39339. * @param callback defines the callback to use
  39340. */
  39341. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39342. /**
  39343. * Defines the callback to call when a pad is released
  39344. * @param callback defines the callback to use
  39345. */
  39346. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39347. private _setButtonValue;
  39348. private _setDPadValue;
  39349. /**
  39350. * Gets the value of the `A` button
  39351. */
  39352. /**
  39353. * Sets the value of the `A` button
  39354. */
  39355. buttonA: number;
  39356. /**
  39357. * Gets the value of the `B` button
  39358. */
  39359. /**
  39360. * Sets the value of the `B` button
  39361. */
  39362. buttonB: number;
  39363. /**
  39364. * Gets the value of the `X` button
  39365. */
  39366. /**
  39367. * Sets the value of the `X` button
  39368. */
  39369. buttonX: number;
  39370. /**
  39371. * Gets the value of the `Y` button
  39372. */
  39373. /**
  39374. * Sets the value of the `Y` button
  39375. */
  39376. buttonY: number;
  39377. /**
  39378. * Gets the value of the `Start` button
  39379. */
  39380. /**
  39381. * Sets the value of the `Start` button
  39382. */
  39383. buttonStart: number;
  39384. /**
  39385. * Gets the value of the `Back` button
  39386. */
  39387. /**
  39388. * Sets the value of the `Back` button
  39389. */
  39390. buttonBack: number;
  39391. /**
  39392. * Gets the value of the `Left` button
  39393. */
  39394. /**
  39395. * Sets the value of the `Left` button
  39396. */
  39397. buttonLB: number;
  39398. /**
  39399. * Gets the value of the `Right` button
  39400. */
  39401. /**
  39402. * Sets the value of the `Right` button
  39403. */
  39404. buttonRB: number;
  39405. /**
  39406. * Gets the value of the Left joystick
  39407. */
  39408. /**
  39409. * Sets the value of the Left joystick
  39410. */
  39411. buttonLeftStick: number;
  39412. /**
  39413. * Gets the value of the Right joystick
  39414. */
  39415. /**
  39416. * Sets the value of the Right joystick
  39417. */
  39418. buttonRightStick: number;
  39419. /**
  39420. * Gets the value of D-pad up
  39421. */
  39422. /**
  39423. * Sets the value of D-pad up
  39424. */
  39425. dPadUp: number;
  39426. /**
  39427. * Gets the value of D-pad down
  39428. */
  39429. /**
  39430. * Sets the value of D-pad down
  39431. */
  39432. dPadDown: number;
  39433. /**
  39434. * Gets the value of D-pad left
  39435. */
  39436. /**
  39437. * Sets the value of D-pad left
  39438. */
  39439. dPadLeft: number;
  39440. /**
  39441. * Gets the value of D-pad right
  39442. */
  39443. /**
  39444. * Sets the value of D-pad right
  39445. */
  39446. dPadRight: number;
  39447. /**
  39448. * Force the gamepad to synchronize with device values
  39449. */
  39450. update(): void;
  39451. /**
  39452. * Disposes the gamepad
  39453. */
  39454. dispose(): void;
  39455. }
  39456. }
  39457. declare module "babylonjs/Materials/pushMaterial" {
  39458. import { Nullable } from "babylonjs/types";
  39459. import { Scene } from "babylonjs/scene";
  39460. import { Matrix } from "babylonjs/Maths/math";
  39461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39462. import { Mesh } from "babylonjs/Meshes/mesh";
  39463. import { Material } from "babylonjs/Materials/material";
  39464. import { Effect } from "babylonjs/Materials/effect";
  39465. /**
  39466. * Base class of materials working in push mode in babylon JS
  39467. * @hidden
  39468. */
  39469. export class PushMaterial extends Material {
  39470. protected _activeEffect: Effect;
  39471. protected _normalMatrix: Matrix;
  39472. /**
  39473. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39474. * This means that the material can keep using a previous shader while a new one is being compiled.
  39475. * This is mostly used when shader parallel compilation is supported (true by default)
  39476. */
  39477. allowShaderHotSwapping: boolean;
  39478. constructor(name: string, scene: Scene);
  39479. getEffect(): Effect;
  39480. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39481. /**
  39482. * Binds the given world matrix to the active effect
  39483. *
  39484. * @param world the matrix to bind
  39485. */
  39486. bindOnlyWorldMatrix(world: Matrix): void;
  39487. /**
  39488. * Binds the given normal matrix to the active effect
  39489. *
  39490. * @param normalMatrix the matrix to bind
  39491. */
  39492. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39493. bind(world: Matrix, mesh?: Mesh): void;
  39494. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39495. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39496. }
  39497. }
  39498. declare module "babylonjs/Materials/materialFlags" {
  39499. /**
  39500. * This groups all the flags used to control the materials channel.
  39501. */
  39502. export class MaterialFlags {
  39503. private static _DiffuseTextureEnabled;
  39504. /**
  39505. * Are diffuse textures enabled in the application.
  39506. */
  39507. static DiffuseTextureEnabled: boolean;
  39508. private static _AmbientTextureEnabled;
  39509. /**
  39510. * Are ambient textures enabled in the application.
  39511. */
  39512. static AmbientTextureEnabled: boolean;
  39513. private static _OpacityTextureEnabled;
  39514. /**
  39515. * Are opacity textures enabled in the application.
  39516. */
  39517. static OpacityTextureEnabled: boolean;
  39518. private static _ReflectionTextureEnabled;
  39519. /**
  39520. * Are reflection textures enabled in the application.
  39521. */
  39522. static ReflectionTextureEnabled: boolean;
  39523. private static _EmissiveTextureEnabled;
  39524. /**
  39525. * Are emissive textures enabled in the application.
  39526. */
  39527. static EmissiveTextureEnabled: boolean;
  39528. private static _SpecularTextureEnabled;
  39529. /**
  39530. * Are specular textures enabled in the application.
  39531. */
  39532. static SpecularTextureEnabled: boolean;
  39533. private static _BumpTextureEnabled;
  39534. /**
  39535. * Are bump textures enabled in the application.
  39536. */
  39537. static BumpTextureEnabled: boolean;
  39538. private static _LightmapTextureEnabled;
  39539. /**
  39540. * Are lightmap textures enabled in the application.
  39541. */
  39542. static LightmapTextureEnabled: boolean;
  39543. private static _RefractionTextureEnabled;
  39544. /**
  39545. * Are refraction textures enabled in the application.
  39546. */
  39547. static RefractionTextureEnabled: boolean;
  39548. private static _ColorGradingTextureEnabled;
  39549. /**
  39550. * Are color grading textures enabled in the application.
  39551. */
  39552. static ColorGradingTextureEnabled: boolean;
  39553. private static _FresnelEnabled;
  39554. /**
  39555. * Are fresnels enabled in the application.
  39556. */
  39557. static FresnelEnabled: boolean;
  39558. private static _ClearCoatTextureEnabled;
  39559. /**
  39560. * Are clear coat textures enabled in the application.
  39561. */
  39562. static ClearCoatTextureEnabled: boolean;
  39563. private static _ClearCoatBumpTextureEnabled;
  39564. /**
  39565. * Are clear coat bump textures enabled in the application.
  39566. */
  39567. static ClearCoatBumpTextureEnabled: boolean;
  39568. private static _ClearCoatTintTextureEnabled;
  39569. /**
  39570. * Are clear coat tint textures enabled in the application.
  39571. */
  39572. static ClearCoatTintTextureEnabled: boolean;
  39573. private static _SheenTextureEnabled;
  39574. /**
  39575. * Are sheen textures enabled in the application.
  39576. */
  39577. static SheenTextureEnabled: boolean;
  39578. private static _AnisotropicTextureEnabled;
  39579. /**
  39580. * Are anisotropic textures enabled in the application.
  39581. */
  39582. static AnisotropicTextureEnabled: boolean;
  39583. private static _ThicknessTextureEnabled;
  39584. /**
  39585. * Are thickness textures enabled in the application.
  39586. */
  39587. static ThicknessTextureEnabled: boolean;
  39588. }
  39589. }
  39590. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39591. /** @hidden */
  39592. export var defaultFragmentDeclaration: {
  39593. name: string;
  39594. shader: string;
  39595. };
  39596. }
  39597. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39598. /** @hidden */
  39599. export var defaultUboDeclaration: {
  39600. name: string;
  39601. shader: string;
  39602. };
  39603. }
  39604. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39605. /** @hidden */
  39606. export var lightFragmentDeclaration: {
  39607. name: string;
  39608. shader: string;
  39609. };
  39610. }
  39611. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39612. /** @hidden */
  39613. export var lightUboDeclaration: {
  39614. name: string;
  39615. shader: string;
  39616. };
  39617. }
  39618. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39619. /** @hidden */
  39620. export var lightsFragmentFunctions: {
  39621. name: string;
  39622. shader: string;
  39623. };
  39624. }
  39625. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39626. /** @hidden */
  39627. export var shadowsFragmentFunctions: {
  39628. name: string;
  39629. shader: string;
  39630. };
  39631. }
  39632. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39633. /** @hidden */
  39634. export var fresnelFunction: {
  39635. name: string;
  39636. shader: string;
  39637. };
  39638. }
  39639. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39640. /** @hidden */
  39641. export var reflectionFunction: {
  39642. name: string;
  39643. shader: string;
  39644. };
  39645. }
  39646. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39647. /** @hidden */
  39648. export var bumpFragmentFunctions: {
  39649. name: string;
  39650. shader: string;
  39651. };
  39652. }
  39653. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39654. /** @hidden */
  39655. export var logDepthDeclaration: {
  39656. name: string;
  39657. shader: string;
  39658. };
  39659. }
  39660. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39661. /** @hidden */
  39662. export var bumpFragment: {
  39663. name: string;
  39664. shader: string;
  39665. };
  39666. }
  39667. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39668. /** @hidden */
  39669. export var depthPrePass: {
  39670. name: string;
  39671. shader: string;
  39672. };
  39673. }
  39674. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39675. /** @hidden */
  39676. export var lightFragment: {
  39677. name: string;
  39678. shader: string;
  39679. };
  39680. }
  39681. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39682. /** @hidden */
  39683. export var logDepthFragment: {
  39684. name: string;
  39685. shader: string;
  39686. };
  39687. }
  39688. declare module "babylonjs/Shaders/default.fragment" {
  39689. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39690. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39691. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39692. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39693. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39694. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39695. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39696. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39697. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39698. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39699. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39700. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39701. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39702. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39703. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39704. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39705. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39706. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39707. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39708. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39709. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39710. /** @hidden */
  39711. export var defaultPixelShader: {
  39712. name: string;
  39713. shader: string;
  39714. };
  39715. }
  39716. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39717. /** @hidden */
  39718. export var defaultVertexDeclaration: {
  39719. name: string;
  39720. shader: string;
  39721. };
  39722. }
  39723. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39724. /** @hidden */
  39725. export var bumpVertexDeclaration: {
  39726. name: string;
  39727. shader: string;
  39728. };
  39729. }
  39730. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39731. /** @hidden */
  39732. export var bumpVertex: {
  39733. name: string;
  39734. shader: string;
  39735. };
  39736. }
  39737. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39738. /** @hidden */
  39739. export var fogVertex: {
  39740. name: string;
  39741. shader: string;
  39742. };
  39743. }
  39744. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39745. /** @hidden */
  39746. export var shadowsVertex: {
  39747. name: string;
  39748. shader: string;
  39749. };
  39750. }
  39751. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39752. /** @hidden */
  39753. export var pointCloudVertex: {
  39754. name: string;
  39755. shader: string;
  39756. };
  39757. }
  39758. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39759. /** @hidden */
  39760. export var logDepthVertex: {
  39761. name: string;
  39762. shader: string;
  39763. };
  39764. }
  39765. declare module "babylonjs/Shaders/default.vertex" {
  39766. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39767. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39768. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39769. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39770. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39771. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39772. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39773. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39774. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39775. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39776. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39777. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39778. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39779. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39780. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39781. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39782. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39783. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39784. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39785. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39786. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39787. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39788. /** @hidden */
  39789. export var defaultVertexShader: {
  39790. name: string;
  39791. shader: string;
  39792. };
  39793. }
  39794. declare module "babylonjs/Materials/standardMaterial" {
  39795. import { SmartArray } from "babylonjs/Misc/smartArray";
  39796. import { IAnimatable } from "babylonjs/Misc/tools";
  39797. import { Nullable } from "babylonjs/types";
  39798. import { Scene } from "babylonjs/scene";
  39799. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39800. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39802. import { Mesh } from "babylonjs/Meshes/mesh";
  39803. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39804. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39805. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39806. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39807. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39809. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39810. import "babylonjs/Shaders/default.fragment";
  39811. import "babylonjs/Shaders/default.vertex";
  39812. /** @hidden */
  39813. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39814. MAINUV1: boolean;
  39815. MAINUV2: boolean;
  39816. DIFFUSE: boolean;
  39817. DIFFUSEDIRECTUV: number;
  39818. AMBIENT: boolean;
  39819. AMBIENTDIRECTUV: number;
  39820. OPACITY: boolean;
  39821. OPACITYDIRECTUV: number;
  39822. OPACITYRGB: boolean;
  39823. REFLECTION: boolean;
  39824. EMISSIVE: boolean;
  39825. EMISSIVEDIRECTUV: number;
  39826. SPECULAR: boolean;
  39827. SPECULARDIRECTUV: number;
  39828. BUMP: boolean;
  39829. BUMPDIRECTUV: number;
  39830. PARALLAX: boolean;
  39831. PARALLAXOCCLUSION: boolean;
  39832. SPECULAROVERALPHA: boolean;
  39833. CLIPPLANE: boolean;
  39834. CLIPPLANE2: boolean;
  39835. CLIPPLANE3: boolean;
  39836. CLIPPLANE4: boolean;
  39837. ALPHATEST: boolean;
  39838. DEPTHPREPASS: boolean;
  39839. ALPHAFROMDIFFUSE: boolean;
  39840. POINTSIZE: boolean;
  39841. FOG: boolean;
  39842. SPECULARTERM: boolean;
  39843. DIFFUSEFRESNEL: boolean;
  39844. OPACITYFRESNEL: boolean;
  39845. REFLECTIONFRESNEL: boolean;
  39846. REFRACTIONFRESNEL: boolean;
  39847. EMISSIVEFRESNEL: boolean;
  39848. FRESNEL: boolean;
  39849. NORMAL: boolean;
  39850. UV1: boolean;
  39851. UV2: boolean;
  39852. VERTEXCOLOR: boolean;
  39853. VERTEXALPHA: boolean;
  39854. NUM_BONE_INFLUENCERS: number;
  39855. BonesPerMesh: number;
  39856. BONETEXTURE: boolean;
  39857. INSTANCES: boolean;
  39858. GLOSSINESS: boolean;
  39859. ROUGHNESS: boolean;
  39860. EMISSIVEASILLUMINATION: boolean;
  39861. LINKEMISSIVEWITHDIFFUSE: boolean;
  39862. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39863. LIGHTMAP: boolean;
  39864. LIGHTMAPDIRECTUV: number;
  39865. OBJECTSPACE_NORMALMAP: boolean;
  39866. USELIGHTMAPASSHADOWMAP: boolean;
  39867. REFLECTIONMAP_3D: boolean;
  39868. REFLECTIONMAP_SPHERICAL: boolean;
  39869. REFLECTIONMAP_PLANAR: boolean;
  39870. REFLECTIONMAP_CUBIC: boolean;
  39871. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39872. REFLECTIONMAP_PROJECTION: boolean;
  39873. REFLECTIONMAP_SKYBOX: boolean;
  39874. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39875. REFLECTIONMAP_EXPLICIT: boolean;
  39876. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39877. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39878. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39879. INVERTCUBICMAP: boolean;
  39880. LOGARITHMICDEPTH: boolean;
  39881. REFRACTION: boolean;
  39882. REFRACTIONMAP_3D: boolean;
  39883. REFLECTIONOVERALPHA: boolean;
  39884. TWOSIDEDLIGHTING: boolean;
  39885. SHADOWFLOAT: boolean;
  39886. MORPHTARGETS: boolean;
  39887. MORPHTARGETS_NORMAL: boolean;
  39888. MORPHTARGETS_TANGENT: boolean;
  39889. NUM_MORPH_INFLUENCERS: number;
  39890. NONUNIFORMSCALING: boolean;
  39891. PREMULTIPLYALPHA: boolean;
  39892. IMAGEPROCESSING: boolean;
  39893. VIGNETTE: boolean;
  39894. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39895. VIGNETTEBLENDMODEOPAQUE: boolean;
  39896. TONEMAPPING: boolean;
  39897. TONEMAPPING_ACES: boolean;
  39898. CONTRAST: boolean;
  39899. COLORCURVES: boolean;
  39900. COLORGRADING: boolean;
  39901. COLORGRADING3D: boolean;
  39902. SAMPLER3DGREENDEPTH: boolean;
  39903. SAMPLER3DBGRMAP: boolean;
  39904. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39905. MULTIVIEW: boolean;
  39906. /**
  39907. * If the reflection texture on this material is in linear color space
  39908. * @hidden
  39909. */
  39910. IS_REFLECTION_LINEAR: boolean;
  39911. /**
  39912. * If the refraction texture on this material is in linear color space
  39913. * @hidden
  39914. */
  39915. IS_REFRACTION_LINEAR: boolean;
  39916. EXPOSURE: boolean;
  39917. constructor();
  39918. setReflectionMode(modeToEnable: string): void;
  39919. }
  39920. /**
  39921. * This is the default material used in Babylon. It is the best trade off between quality
  39922. * and performances.
  39923. * @see http://doc.babylonjs.com/babylon101/materials
  39924. */
  39925. export class StandardMaterial extends PushMaterial {
  39926. private _diffuseTexture;
  39927. /**
  39928. * The basic texture of the material as viewed under a light.
  39929. */
  39930. diffuseTexture: Nullable<BaseTexture>;
  39931. private _ambientTexture;
  39932. /**
  39933. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39934. */
  39935. ambientTexture: Nullable<BaseTexture>;
  39936. private _opacityTexture;
  39937. /**
  39938. * Define the transparency of the material from a texture.
  39939. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39940. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39941. */
  39942. opacityTexture: Nullable<BaseTexture>;
  39943. private _reflectionTexture;
  39944. /**
  39945. * Define the texture used to display the reflection.
  39946. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39947. */
  39948. reflectionTexture: Nullable<BaseTexture>;
  39949. private _emissiveTexture;
  39950. /**
  39951. * Define texture of the material as if self lit.
  39952. * This will be mixed in the final result even in the absence of light.
  39953. */
  39954. emissiveTexture: Nullable<BaseTexture>;
  39955. private _specularTexture;
  39956. /**
  39957. * Define how the color and intensity of the highlight given by the light in the material.
  39958. */
  39959. specularTexture: Nullable<BaseTexture>;
  39960. private _bumpTexture;
  39961. /**
  39962. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39963. * 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.
  39964. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39965. */
  39966. bumpTexture: Nullable<BaseTexture>;
  39967. private _lightmapTexture;
  39968. /**
  39969. * Complex lighting can be computationally expensive to compute at runtime.
  39970. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39971. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39972. */
  39973. lightmapTexture: Nullable<BaseTexture>;
  39974. private _refractionTexture;
  39975. /**
  39976. * Define the texture used to display the refraction.
  39977. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39978. */
  39979. refractionTexture: Nullable<BaseTexture>;
  39980. /**
  39981. * The color of the material lit by the environmental background lighting.
  39982. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39983. */
  39984. ambientColor: Color3;
  39985. /**
  39986. * The basic color of the material as viewed under a light.
  39987. */
  39988. diffuseColor: Color3;
  39989. /**
  39990. * Define how the color and intensity of the highlight given by the light in the material.
  39991. */
  39992. specularColor: Color3;
  39993. /**
  39994. * Define the color of the material as if self lit.
  39995. * This will be mixed in the final result even in the absence of light.
  39996. */
  39997. emissiveColor: Color3;
  39998. /**
  39999. * Defines how sharp are the highlights in the material.
  40000. * The bigger the value the sharper giving a more glossy feeling to the result.
  40001. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40002. */
  40003. specularPower: number;
  40004. private _useAlphaFromDiffuseTexture;
  40005. /**
  40006. * Does the transparency come from the diffuse texture alpha channel.
  40007. */
  40008. useAlphaFromDiffuseTexture: boolean;
  40009. private _useEmissiveAsIllumination;
  40010. /**
  40011. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40012. */
  40013. useEmissiveAsIllumination: boolean;
  40014. private _linkEmissiveWithDiffuse;
  40015. /**
  40016. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40017. * the emissive level when the final color is close to one.
  40018. */
  40019. linkEmissiveWithDiffuse: boolean;
  40020. private _useSpecularOverAlpha;
  40021. /**
  40022. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40023. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40024. */
  40025. useSpecularOverAlpha: boolean;
  40026. private _useReflectionOverAlpha;
  40027. /**
  40028. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40029. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40030. */
  40031. useReflectionOverAlpha: boolean;
  40032. private _disableLighting;
  40033. /**
  40034. * Does lights from the scene impacts this material.
  40035. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40036. */
  40037. disableLighting: boolean;
  40038. private _useObjectSpaceNormalMap;
  40039. /**
  40040. * Allows using an object space normal map (instead of tangent space).
  40041. */
  40042. useObjectSpaceNormalMap: boolean;
  40043. private _useParallax;
  40044. /**
  40045. * Is parallax enabled or not.
  40046. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40047. */
  40048. useParallax: boolean;
  40049. private _useParallaxOcclusion;
  40050. /**
  40051. * Is parallax occlusion enabled or not.
  40052. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40053. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40054. */
  40055. useParallaxOcclusion: boolean;
  40056. /**
  40057. * 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.
  40058. */
  40059. parallaxScaleBias: number;
  40060. private _roughness;
  40061. /**
  40062. * Helps to define how blurry the reflections should appears in the material.
  40063. */
  40064. roughness: number;
  40065. /**
  40066. * In case of refraction, define the value of the indice of refraction.
  40067. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40068. */
  40069. indexOfRefraction: number;
  40070. /**
  40071. * Invert the refraction texture alongside the y axis.
  40072. * It can be useful with procedural textures or probe for instance.
  40073. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40074. */
  40075. invertRefractionY: boolean;
  40076. /**
  40077. * Defines the alpha limits in alpha test mode.
  40078. */
  40079. alphaCutOff: number;
  40080. private _useLightmapAsShadowmap;
  40081. /**
  40082. * In case of light mapping, define whether the map contains light or shadow informations.
  40083. */
  40084. useLightmapAsShadowmap: boolean;
  40085. private _diffuseFresnelParameters;
  40086. /**
  40087. * Define the diffuse fresnel parameters of the material.
  40088. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40089. */
  40090. diffuseFresnelParameters: FresnelParameters;
  40091. private _opacityFresnelParameters;
  40092. /**
  40093. * Define the opacity fresnel parameters of the material.
  40094. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40095. */
  40096. opacityFresnelParameters: FresnelParameters;
  40097. private _reflectionFresnelParameters;
  40098. /**
  40099. * Define the reflection fresnel parameters of the material.
  40100. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40101. */
  40102. reflectionFresnelParameters: FresnelParameters;
  40103. private _refractionFresnelParameters;
  40104. /**
  40105. * Define the refraction fresnel parameters of the material.
  40106. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40107. */
  40108. refractionFresnelParameters: FresnelParameters;
  40109. private _emissiveFresnelParameters;
  40110. /**
  40111. * Define the emissive fresnel parameters of the material.
  40112. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40113. */
  40114. emissiveFresnelParameters: FresnelParameters;
  40115. private _useReflectionFresnelFromSpecular;
  40116. /**
  40117. * If true automatically deducts the fresnels values from the material specularity.
  40118. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40119. */
  40120. useReflectionFresnelFromSpecular: boolean;
  40121. private _useGlossinessFromSpecularMapAlpha;
  40122. /**
  40123. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40124. */
  40125. useGlossinessFromSpecularMapAlpha: boolean;
  40126. private _maxSimultaneousLights;
  40127. /**
  40128. * Defines the maximum number of lights that can be used in the material
  40129. */
  40130. maxSimultaneousLights: number;
  40131. private _invertNormalMapX;
  40132. /**
  40133. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40134. */
  40135. invertNormalMapX: boolean;
  40136. private _invertNormalMapY;
  40137. /**
  40138. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40139. */
  40140. invertNormalMapY: boolean;
  40141. private _twoSidedLighting;
  40142. /**
  40143. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40144. */
  40145. twoSidedLighting: boolean;
  40146. /**
  40147. * Default configuration related to image processing available in the standard Material.
  40148. */
  40149. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40150. /**
  40151. * Gets the image processing configuration used either in this material.
  40152. */
  40153. /**
  40154. * Sets the Default image processing configuration used either in the this material.
  40155. *
  40156. * If sets to null, the scene one is in use.
  40157. */
  40158. imageProcessingConfiguration: ImageProcessingConfiguration;
  40159. /**
  40160. * Keep track of the image processing observer to allow dispose and replace.
  40161. */
  40162. private _imageProcessingObserver;
  40163. /**
  40164. * Attaches a new image processing configuration to the Standard Material.
  40165. * @param configuration
  40166. */
  40167. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40168. /**
  40169. * Gets wether the color curves effect is enabled.
  40170. */
  40171. /**
  40172. * Sets wether the color curves effect is enabled.
  40173. */
  40174. cameraColorCurvesEnabled: boolean;
  40175. /**
  40176. * Gets wether the color grading effect is enabled.
  40177. */
  40178. /**
  40179. * Gets wether the color grading effect is enabled.
  40180. */
  40181. cameraColorGradingEnabled: boolean;
  40182. /**
  40183. * Gets wether tonemapping is enabled or not.
  40184. */
  40185. /**
  40186. * Sets wether tonemapping is enabled or not
  40187. */
  40188. cameraToneMappingEnabled: boolean;
  40189. /**
  40190. * The camera exposure used on this material.
  40191. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40192. * This corresponds to a photographic exposure.
  40193. */
  40194. /**
  40195. * The camera exposure used on this material.
  40196. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40197. * This corresponds to a photographic exposure.
  40198. */
  40199. cameraExposure: number;
  40200. /**
  40201. * Gets The camera contrast used on this material.
  40202. */
  40203. /**
  40204. * Sets The camera contrast used on this material.
  40205. */
  40206. cameraContrast: number;
  40207. /**
  40208. * Gets the Color Grading 2D Lookup Texture.
  40209. */
  40210. /**
  40211. * Sets the Color Grading 2D Lookup Texture.
  40212. */
  40213. cameraColorGradingTexture: Nullable<BaseTexture>;
  40214. /**
  40215. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40216. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40217. * 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;
  40218. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40219. */
  40220. /**
  40221. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40222. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40223. * 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;
  40224. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40225. */
  40226. cameraColorCurves: Nullable<ColorCurves>;
  40227. /**
  40228. * Custom callback helping to override the default shader used in the material.
  40229. */
  40230. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40231. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40232. protected _worldViewProjectionMatrix: Matrix;
  40233. protected _globalAmbientColor: Color3;
  40234. protected _useLogarithmicDepth: boolean;
  40235. /**
  40236. * Instantiates a new standard material.
  40237. * This is the default material used in Babylon. It is the best trade off between quality
  40238. * and performances.
  40239. * @see http://doc.babylonjs.com/babylon101/materials
  40240. * @param name Define the name of the material in the scene
  40241. * @param scene Define the scene the material belong to
  40242. */
  40243. constructor(name: string, scene: Scene);
  40244. /**
  40245. * Gets a boolean indicating that current material needs to register RTT
  40246. */
  40247. readonly hasRenderTargetTextures: boolean;
  40248. /**
  40249. * Gets the current class name of the material e.g. "StandardMaterial"
  40250. * Mainly use in serialization.
  40251. * @returns the class name
  40252. */
  40253. getClassName(): string;
  40254. /**
  40255. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40256. * You can try switching to logarithmic depth.
  40257. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40258. */
  40259. useLogarithmicDepth: boolean;
  40260. /**
  40261. * Specifies if the material will require alpha blending
  40262. * @returns a boolean specifying if alpha blending is needed
  40263. */
  40264. needAlphaBlending(): boolean;
  40265. /**
  40266. * Specifies if this material should be rendered in alpha test mode
  40267. * @returns a boolean specifying if an alpha test is needed.
  40268. */
  40269. needAlphaTesting(): boolean;
  40270. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40271. /**
  40272. * Get the texture used for alpha test purpose.
  40273. * @returns the diffuse texture in case of the standard material.
  40274. */
  40275. getAlphaTestTexture(): Nullable<BaseTexture>;
  40276. /**
  40277. * Get if the submesh is ready to be used and all its information available.
  40278. * Child classes can use it to update shaders
  40279. * @param mesh defines the mesh to check
  40280. * @param subMesh defines which submesh to check
  40281. * @param useInstances specifies that instances should be used
  40282. * @returns a boolean indicating that the submesh is ready or not
  40283. */
  40284. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40285. /**
  40286. * Builds the material UBO layouts.
  40287. * Used internally during the effect preparation.
  40288. */
  40289. buildUniformLayout(): void;
  40290. /**
  40291. * Unbinds the material from the mesh
  40292. */
  40293. unbind(): void;
  40294. /**
  40295. * Binds the submesh to this material by preparing the effect and shader to draw
  40296. * @param world defines the world transformation matrix
  40297. * @param mesh defines the mesh containing the submesh
  40298. * @param subMesh defines the submesh to bind the material to
  40299. */
  40300. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40301. /**
  40302. * Get the list of animatables in the material.
  40303. * @returns the list of animatables object used in the material
  40304. */
  40305. getAnimatables(): IAnimatable[];
  40306. /**
  40307. * Gets the active textures from the material
  40308. * @returns an array of textures
  40309. */
  40310. getActiveTextures(): BaseTexture[];
  40311. /**
  40312. * Specifies if the material uses a texture
  40313. * @param texture defines the texture to check against the material
  40314. * @returns a boolean specifying if the material uses the texture
  40315. */
  40316. hasTexture(texture: BaseTexture): boolean;
  40317. /**
  40318. * Disposes the material
  40319. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40320. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40321. */
  40322. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40323. /**
  40324. * Makes a duplicate of the material, and gives it a new name
  40325. * @param name defines the new name for the duplicated material
  40326. * @returns the cloned material
  40327. */
  40328. clone(name: string): StandardMaterial;
  40329. /**
  40330. * Serializes this material in a JSON representation
  40331. * @returns the serialized material object
  40332. */
  40333. serialize(): any;
  40334. /**
  40335. * Creates a standard material from parsed material data
  40336. * @param source defines the JSON representation of the material
  40337. * @param scene defines the hosting scene
  40338. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40339. * @returns a new standard material
  40340. */
  40341. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40342. /**
  40343. * Are diffuse textures enabled in the application.
  40344. */
  40345. static DiffuseTextureEnabled: boolean;
  40346. /**
  40347. * Are ambient textures enabled in the application.
  40348. */
  40349. static AmbientTextureEnabled: boolean;
  40350. /**
  40351. * Are opacity textures enabled in the application.
  40352. */
  40353. static OpacityTextureEnabled: boolean;
  40354. /**
  40355. * Are reflection textures enabled in the application.
  40356. */
  40357. static ReflectionTextureEnabled: boolean;
  40358. /**
  40359. * Are emissive textures enabled in the application.
  40360. */
  40361. static EmissiveTextureEnabled: boolean;
  40362. /**
  40363. * Are specular textures enabled in the application.
  40364. */
  40365. static SpecularTextureEnabled: boolean;
  40366. /**
  40367. * Are bump textures enabled in the application.
  40368. */
  40369. static BumpTextureEnabled: boolean;
  40370. /**
  40371. * Are lightmap textures enabled in the application.
  40372. */
  40373. static LightmapTextureEnabled: boolean;
  40374. /**
  40375. * Are refraction textures enabled in the application.
  40376. */
  40377. static RefractionTextureEnabled: boolean;
  40378. /**
  40379. * Are color grading textures enabled in the application.
  40380. */
  40381. static ColorGradingTextureEnabled: boolean;
  40382. /**
  40383. * Are fresnels enabled in the application.
  40384. */
  40385. static FresnelEnabled: boolean;
  40386. }
  40387. }
  40388. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40389. import { Scene } from "babylonjs/scene";
  40390. import { Texture } from "babylonjs/Materials/Textures/texture";
  40391. /**
  40392. * A class extending Texture allowing drawing on a texture
  40393. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40394. */
  40395. export class DynamicTexture extends Texture {
  40396. private _generateMipMaps;
  40397. private _canvas;
  40398. private _context;
  40399. private _engine;
  40400. /**
  40401. * Creates a DynamicTexture
  40402. * @param name defines the name of the texture
  40403. * @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
  40404. * @param scene defines the scene where you want the texture
  40405. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40406. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40407. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40408. */
  40409. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40410. /**
  40411. * Get the current class name of the texture useful for serialization or dynamic coding.
  40412. * @returns "DynamicTexture"
  40413. */
  40414. getClassName(): string;
  40415. /**
  40416. * Gets the current state of canRescale
  40417. */
  40418. readonly canRescale: boolean;
  40419. private _recreate;
  40420. /**
  40421. * Scales the texture
  40422. * @param ratio the scale factor to apply to both width and height
  40423. */
  40424. scale(ratio: number): void;
  40425. /**
  40426. * Resizes the texture
  40427. * @param width the new width
  40428. * @param height the new height
  40429. */
  40430. scaleTo(width: number, height: number): void;
  40431. /**
  40432. * Gets the context of the canvas used by the texture
  40433. * @returns the canvas context of the dynamic texture
  40434. */
  40435. getContext(): CanvasRenderingContext2D;
  40436. /**
  40437. * Clears the texture
  40438. */
  40439. clear(): void;
  40440. /**
  40441. * Updates the texture
  40442. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40443. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40444. */
  40445. update(invertY?: boolean, premulAlpha?: boolean): void;
  40446. /**
  40447. * Draws text onto the texture
  40448. * @param text defines the text to be drawn
  40449. * @param x defines the placement of the text from the left
  40450. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40451. * @param font defines the font to be used with font-style, font-size, font-name
  40452. * @param color defines the color used for the text
  40453. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40454. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40455. * @param update defines whether texture is immediately update (default is true)
  40456. */
  40457. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40458. /**
  40459. * Clones the texture
  40460. * @returns the clone of the texture.
  40461. */
  40462. clone(): DynamicTexture;
  40463. /**
  40464. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40465. * @returns a serialized dynamic texture object
  40466. */
  40467. serialize(): any;
  40468. /** @hidden */
  40469. _rebuild(): void;
  40470. }
  40471. }
  40472. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40473. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40474. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40475. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40476. /** @hidden */
  40477. export var imageProcessingPixelShader: {
  40478. name: string;
  40479. shader: string;
  40480. };
  40481. }
  40482. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40483. import { Nullable } from "babylonjs/types";
  40484. import { Color4 } from "babylonjs/Maths/math";
  40485. import { Camera } from "babylonjs/Cameras/camera";
  40486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40487. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40488. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40489. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40490. import { Engine } from "babylonjs/Engines/engine";
  40491. import "babylonjs/Shaders/imageProcessing.fragment";
  40492. import "babylonjs/Shaders/postprocess.vertex";
  40493. /**
  40494. * ImageProcessingPostProcess
  40495. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40496. */
  40497. export class ImageProcessingPostProcess extends PostProcess {
  40498. /**
  40499. * Default configuration related to image processing available in the PBR Material.
  40500. */
  40501. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40502. /**
  40503. * Gets the image processing configuration used either in this material.
  40504. */
  40505. /**
  40506. * Sets the Default image processing configuration used either in the this material.
  40507. *
  40508. * If sets to null, the scene one is in use.
  40509. */
  40510. imageProcessingConfiguration: ImageProcessingConfiguration;
  40511. /**
  40512. * Keep track of the image processing observer to allow dispose and replace.
  40513. */
  40514. private _imageProcessingObserver;
  40515. /**
  40516. * Attaches a new image processing configuration to the PBR Material.
  40517. * @param configuration
  40518. */
  40519. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40520. /**
  40521. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40522. */
  40523. /**
  40524. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40525. */
  40526. colorCurves: Nullable<ColorCurves>;
  40527. /**
  40528. * Gets wether the color curves effect is enabled.
  40529. */
  40530. /**
  40531. * Sets wether the color curves effect is enabled.
  40532. */
  40533. colorCurvesEnabled: boolean;
  40534. /**
  40535. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40536. */
  40537. /**
  40538. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40539. */
  40540. colorGradingTexture: Nullable<BaseTexture>;
  40541. /**
  40542. * Gets wether the color grading effect is enabled.
  40543. */
  40544. /**
  40545. * Gets wether the color grading effect is enabled.
  40546. */
  40547. colorGradingEnabled: boolean;
  40548. /**
  40549. * Gets exposure used in the effect.
  40550. */
  40551. /**
  40552. * Sets exposure used in the effect.
  40553. */
  40554. exposure: number;
  40555. /**
  40556. * Gets wether tonemapping is enabled or not.
  40557. */
  40558. /**
  40559. * Sets wether tonemapping is enabled or not
  40560. */
  40561. toneMappingEnabled: boolean;
  40562. /**
  40563. * Gets the type of tone mapping effect.
  40564. */
  40565. /**
  40566. * Sets the type of tone mapping effect.
  40567. */
  40568. toneMappingType: number;
  40569. /**
  40570. * Gets contrast used in the effect.
  40571. */
  40572. /**
  40573. * Sets contrast used in the effect.
  40574. */
  40575. contrast: number;
  40576. /**
  40577. * Gets Vignette stretch size.
  40578. */
  40579. /**
  40580. * Sets Vignette stretch size.
  40581. */
  40582. vignetteStretch: number;
  40583. /**
  40584. * Gets Vignette centre X Offset.
  40585. */
  40586. /**
  40587. * Sets Vignette centre X Offset.
  40588. */
  40589. vignetteCentreX: number;
  40590. /**
  40591. * Gets Vignette centre Y Offset.
  40592. */
  40593. /**
  40594. * Sets Vignette centre Y Offset.
  40595. */
  40596. vignetteCentreY: number;
  40597. /**
  40598. * Gets Vignette weight or intensity of the vignette effect.
  40599. */
  40600. /**
  40601. * Sets Vignette weight or intensity of the vignette effect.
  40602. */
  40603. vignetteWeight: number;
  40604. /**
  40605. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40606. * if vignetteEnabled is set to true.
  40607. */
  40608. /**
  40609. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40610. * if vignetteEnabled is set to true.
  40611. */
  40612. vignetteColor: Color4;
  40613. /**
  40614. * Gets Camera field of view used by the Vignette effect.
  40615. */
  40616. /**
  40617. * Sets Camera field of view used by the Vignette effect.
  40618. */
  40619. vignetteCameraFov: number;
  40620. /**
  40621. * Gets the vignette blend mode allowing different kind of effect.
  40622. */
  40623. /**
  40624. * Sets the vignette blend mode allowing different kind of effect.
  40625. */
  40626. vignetteBlendMode: number;
  40627. /**
  40628. * Gets wether the vignette effect is enabled.
  40629. */
  40630. /**
  40631. * Sets wether the vignette effect is enabled.
  40632. */
  40633. vignetteEnabled: boolean;
  40634. private _fromLinearSpace;
  40635. /**
  40636. * Gets wether the input of the processing is in Gamma or Linear Space.
  40637. */
  40638. /**
  40639. * Sets wether the input of the processing is in Gamma or Linear Space.
  40640. */
  40641. fromLinearSpace: boolean;
  40642. /**
  40643. * Defines cache preventing GC.
  40644. */
  40645. private _defines;
  40646. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40647. /**
  40648. * "ImageProcessingPostProcess"
  40649. * @returns "ImageProcessingPostProcess"
  40650. */
  40651. getClassName(): string;
  40652. protected _updateParameters(): void;
  40653. dispose(camera?: Camera): void;
  40654. }
  40655. }
  40656. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40657. import { Scene } from "babylonjs/scene";
  40658. import { Color3 } from "babylonjs/Maths/math";
  40659. import { Mesh } from "babylonjs/Meshes/mesh";
  40660. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40661. import { Nullable } from "babylonjs/types";
  40662. /**
  40663. * Class containing static functions to help procedurally build meshes
  40664. */
  40665. export class GroundBuilder {
  40666. /**
  40667. * Creates a ground mesh
  40668. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40669. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40671. * @param name defines the name of the mesh
  40672. * @param options defines the options used to create the mesh
  40673. * @param scene defines the hosting scene
  40674. * @returns the ground mesh
  40675. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40676. */
  40677. static CreateGround(name: string, options: {
  40678. width?: number;
  40679. height?: number;
  40680. subdivisions?: number;
  40681. subdivisionsX?: number;
  40682. subdivisionsY?: number;
  40683. updatable?: boolean;
  40684. }, scene: any): Mesh;
  40685. /**
  40686. * Creates a tiled ground mesh
  40687. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40688. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40689. * * 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
  40690. * * 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
  40691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40692. * @param name defines the name of the mesh
  40693. * @param options defines the options used to create the mesh
  40694. * @param scene defines the hosting scene
  40695. * @returns the tiled ground mesh
  40696. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40697. */
  40698. static CreateTiledGround(name: string, options: {
  40699. xmin: number;
  40700. zmin: number;
  40701. xmax: number;
  40702. zmax: number;
  40703. subdivisions?: {
  40704. w: number;
  40705. h: number;
  40706. };
  40707. precision?: {
  40708. w: number;
  40709. h: number;
  40710. };
  40711. updatable?: boolean;
  40712. }, scene?: Nullable<Scene>): Mesh;
  40713. /**
  40714. * Creates a ground mesh from a height map
  40715. * * The parameter `url` sets the URL of the height map image resource.
  40716. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40717. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40718. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40719. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40720. * * 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.
  40721. * * 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).
  40722. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40724. * @param name defines the name of the mesh
  40725. * @param url defines the url to the height map
  40726. * @param options defines the options used to create the mesh
  40727. * @param scene defines the hosting scene
  40728. * @returns the ground mesh
  40729. * @see https://doc.babylonjs.com/babylon101/height_map
  40730. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40731. */
  40732. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40733. width?: number;
  40734. height?: number;
  40735. subdivisions?: number;
  40736. minHeight?: number;
  40737. maxHeight?: number;
  40738. colorFilter?: Color3;
  40739. alphaFilter?: number;
  40740. updatable?: boolean;
  40741. onReady?: (mesh: GroundMesh) => void;
  40742. }, scene?: Nullable<Scene>): GroundMesh;
  40743. }
  40744. }
  40745. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40746. import { Vector4 } from "babylonjs/Maths/math";
  40747. import { Mesh } from "babylonjs/Meshes/mesh";
  40748. /**
  40749. * Class containing static functions to help procedurally build meshes
  40750. */
  40751. export class TorusBuilder {
  40752. /**
  40753. * Creates a torus mesh
  40754. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40755. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40756. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40760. * @param name defines the name of the mesh
  40761. * @param options defines the options used to create the mesh
  40762. * @param scene defines the hosting scene
  40763. * @returns the torus mesh
  40764. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40765. */
  40766. static CreateTorus(name: string, options: {
  40767. diameter?: number;
  40768. thickness?: number;
  40769. tessellation?: number;
  40770. updatable?: boolean;
  40771. sideOrientation?: number;
  40772. frontUVs?: Vector4;
  40773. backUVs?: Vector4;
  40774. }, scene: any): Mesh;
  40775. }
  40776. }
  40777. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40778. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40779. import { Mesh } from "babylonjs/Meshes/mesh";
  40780. /**
  40781. * Class containing static functions to help procedurally build meshes
  40782. */
  40783. export class CylinderBuilder {
  40784. /**
  40785. * Creates a cylinder or a cone mesh
  40786. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40787. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40788. * * 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.
  40789. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40790. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40791. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40792. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40793. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40794. * * 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).
  40795. * * 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
  40796. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40797. * * 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
  40798. * * 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.
  40799. * * If `enclose` is false, a ring surface is one element.
  40800. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40801. * * 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
  40802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40805. * @param name defines the name of the mesh
  40806. * @param options defines the options used to create the mesh
  40807. * @param scene defines the hosting scene
  40808. * @returns the cylinder mesh
  40809. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40810. */
  40811. static CreateCylinder(name: string, options: {
  40812. height?: number;
  40813. diameterTop?: number;
  40814. diameterBottom?: number;
  40815. diameter?: number;
  40816. tessellation?: number;
  40817. subdivisions?: number;
  40818. arc?: number;
  40819. faceColors?: Color4[];
  40820. faceUV?: Vector4[];
  40821. updatable?: boolean;
  40822. hasRings?: boolean;
  40823. enclose?: boolean;
  40824. sideOrientation?: number;
  40825. frontUVs?: Vector4;
  40826. backUVs?: Vector4;
  40827. }, scene: any): Mesh;
  40828. }
  40829. }
  40830. declare module "babylonjs/Gamepads/gamepadManager" {
  40831. import { Observable } from "babylonjs/Misc/observable";
  40832. import { Nullable } from "babylonjs/types";
  40833. import { Scene } from "babylonjs/scene";
  40834. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40835. /**
  40836. * Manager for handling gamepads
  40837. */
  40838. export class GamepadManager {
  40839. private _scene?;
  40840. private _babylonGamepads;
  40841. private _oneGamepadConnected;
  40842. /** @hidden */
  40843. _isMonitoring: boolean;
  40844. private _gamepadEventSupported;
  40845. private _gamepadSupport;
  40846. /**
  40847. * observable to be triggered when the gamepad controller has been connected
  40848. */
  40849. onGamepadConnectedObservable: Observable<Gamepad>;
  40850. /**
  40851. * observable to be triggered when the gamepad controller has been disconnected
  40852. */
  40853. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40854. private _onGamepadConnectedEvent;
  40855. private _onGamepadDisconnectedEvent;
  40856. /**
  40857. * Initializes the gamepad manager
  40858. * @param _scene BabylonJS scene
  40859. */
  40860. constructor(_scene?: Scene | undefined);
  40861. /**
  40862. * The gamepads in the game pad manager
  40863. */
  40864. readonly gamepads: Gamepad[];
  40865. /**
  40866. * Get the gamepad controllers based on type
  40867. * @param type The type of gamepad controller
  40868. * @returns Nullable gamepad
  40869. */
  40870. getGamepadByType(type?: number): Nullable<Gamepad>;
  40871. /**
  40872. * Disposes the gamepad manager
  40873. */
  40874. dispose(): void;
  40875. private _addNewGamepad;
  40876. private _startMonitoringGamepads;
  40877. private _stopMonitoringGamepads;
  40878. /** @hidden */
  40879. _checkGamepadsStatus(): void;
  40880. private _updateGamepadObjects;
  40881. }
  40882. }
  40883. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40884. import { Nullable } from "babylonjs/types";
  40885. import { Scene } from "babylonjs/scene";
  40886. import { ISceneComponent } from "babylonjs/sceneComponent";
  40887. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40888. module "babylonjs/scene" {
  40889. interface Scene {
  40890. /** @hidden */
  40891. _gamepadManager: Nullable<GamepadManager>;
  40892. /**
  40893. * Gets the gamepad manager associated with the scene
  40894. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40895. */
  40896. gamepadManager: GamepadManager;
  40897. }
  40898. }
  40899. module "babylonjs/Cameras/freeCameraInputsManager" {
  40900. /**
  40901. * Interface representing a free camera inputs manager
  40902. */
  40903. interface FreeCameraInputsManager {
  40904. /**
  40905. * Adds gamepad input support to the FreeCameraInputsManager.
  40906. * @returns the FreeCameraInputsManager
  40907. */
  40908. addGamepad(): FreeCameraInputsManager;
  40909. }
  40910. }
  40911. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40912. /**
  40913. * Interface representing an arc rotate camera inputs manager
  40914. */
  40915. interface ArcRotateCameraInputsManager {
  40916. /**
  40917. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40918. * @returns the camera inputs manager
  40919. */
  40920. addGamepad(): ArcRotateCameraInputsManager;
  40921. }
  40922. }
  40923. /**
  40924. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40925. */
  40926. export class GamepadSystemSceneComponent implements ISceneComponent {
  40927. /**
  40928. * The component name helpfull to identify the component in the list of scene components.
  40929. */
  40930. readonly name: string;
  40931. /**
  40932. * The scene the component belongs to.
  40933. */
  40934. scene: Scene;
  40935. /**
  40936. * Creates a new instance of the component for the given scene
  40937. * @param scene Defines the scene to register the component in
  40938. */
  40939. constructor(scene: Scene);
  40940. /**
  40941. * Registers the component in a given scene
  40942. */
  40943. register(): void;
  40944. /**
  40945. * Rebuilds the elements related to this component in case of
  40946. * context lost for instance.
  40947. */
  40948. rebuild(): void;
  40949. /**
  40950. * Disposes the component and the associated ressources
  40951. */
  40952. dispose(): void;
  40953. private _beforeCameraUpdate;
  40954. }
  40955. }
  40956. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40957. import { Observable } from "babylonjs/Misc/observable";
  40958. import { Nullable } from "babylonjs/types";
  40959. import { Camera } from "babylonjs/Cameras/camera";
  40960. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40961. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40962. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40963. import { Scene } from "babylonjs/scene";
  40964. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40965. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40967. import { Mesh } from "babylonjs/Meshes/mesh";
  40968. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40969. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40970. import "babylonjs/Meshes/Builders/groundBuilder";
  40971. import "babylonjs/Meshes/Builders/torusBuilder";
  40972. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40973. import "babylonjs/Gamepads/gamepadSceneComponent";
  40974. import "babylonjs/Animations/animatable";
  40975. /**
  40976. * Options to modify the vr teleportation behavior.
  40977. */
  40978. export interface VRTeleportationOptions {
  40979. /**
  40980. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40981. */
  40982. floorMeshName?: string;
  40983. /**
  40984. * A list of meshes to be used as the teleportation floor. (default: empty)
  40985. */
  40986. floorMeshes?: Mesh[];
  40987. }
  40988. /**
  40989. * Options to modify the vr experience helper's behavior.
  40990. */
  40991. export interface VRExperienceHelperOptions extends WebVROptions {
  40992. /**
  40993. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40994. */
  40995. createDeviceOrientationCamera?: boolean;
  40996. /**
  40997. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40998. */
  40999. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41000. /**
  41001. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41002. */
  41003. laserToggle?: boolean;
  41004. /**
  41005. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41006. */
  41007. floorMeshes?: Mesh[];
  41008. /**
  41009. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41010. */
  41011. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41012. }
  41013. /**
  41014. * Event containing information after VR has been entered
  41015. */
  41016. export class OnAfterEnteringVRObservableEvent {
  41017. /**
  41018. * If entering vr was successful
  41019. */
  41020. success: boolean;
  41021. }
  41022. /**
  41023. * Helps to quickly add VR support to an existing scene.
  41024. * See http://doc.babylonjs.com/how_to/webvr_helper
  41025. */
  41026. export class VRExperienceHelper {
  41027. /** Options to modify the vr experience helper's behavior. */
  41028. webVROptions: VRExperienceHelperOptions;
  41029. private _scene;
  41030. private _position;
  41031. private _btnVR;
  41032. private _btnVRDisplayed;
  41033. private _webVRsupported;
  41034. private _webVRready;
  41035. private _webVRrequesting;
  41036. private _webVRpresenting;
  41037. private _hasEnteredVR;
  41038. private _fullscreenVRpresenting;
  41039. private _canvas;
  41040. private _webVRCamera;
  41041. private _vrDeviceOrientationCamera;
  41042. private _deviceOrientationCamera;
  41043. private _existingCamera;
  41044. private _onKeyDown;
  41045. private _onVrDisplayPresentChange;
  41046. private _onVRDisplayChanged;
  41047. private _onVRRequestPresentStart;
  41048. private _onVRRequestPresentComplete;
  41049. /**
  41050. * Observable raised right before entering VR.
  41051. */
  41052. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41053. /**
  41054. * Observable raised when entering VR has completed.
  41055. */
  41056. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41057. /**
  41058. * Observable raised when exiting VR.
  41059. */
  41060. onExitingVRObservable: Observable<VRExperienceHelper>;
  41061. /**
  41062. * Observable raised when controller mesh is loaded.
  41063. */
  41064. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41065. /** Return this.onEnteringVRObservable
  41066. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41067. */
  41068. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41069. /** Return this.onExitingVRObservable
  41070. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41071. */
  41072. readonly onExitingVR: Observable<VRExperienceHelper>;
  41073. /** Return this.onControllerMeshLoadedObservable
  41074. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41075. */
  41076. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41077. private _rayLength;
  41078. private _useCustomVRButton;
  41079. private _teleportationRequested;
  41080. private _teleportActive;
  41081. private _floorMeshName;
  41082. private _floorMeshesCollection;
  41083. private _rotationAllowed;
  41084. private _teleportBackwardsVector;
  41085. private _teleportationTarget;
  41086. private _isDefaultTeleportationTarget;
  41087. private _postProcessMove;
  41088. private _teleportationFillColor;
  41089. private _teleportationBorderColor;
  41090. private _rotationAngle;
  41091. private _haloCenter;
  41092. private _cameraGazer;
  41093. private _padSensibilityUp;
  41094. private _padSensibilityDown;
  41095. private _leftController;
  41096. private _rightController;
  41097. /**
  41098. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41099. */
  41100. onNewMeshSelected: Observable<AbstractMesh>;
  41101. /**
  41102. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41103. */
  41104. onNewMeshPicked: Observable<PickingInfo>;
  41105. private _circleEase;
  41106. /**
  41107. * Observable raised before camera teleportation
  41108. */
  41109. onBeforeCameraTeleport: Observable<Vector3>;
  41110. /**
  41111. * Observable raised after camera teleportation
  41112. */
  41113. onAfterCameraTeleport: Observable<Vector3>;
  41114. /**
  41115. * Observable raised when current selected mesh gets unselected
  41116. */
  41117. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41118. private _raySelectionPredicate;
  41119. /**
  41120. * To be optionaly changed by user to define custom ray selection
  41121. */
  41122. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41123. /**
  41124. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41125. */
  41126. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41127. /**
  41128. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41129. */
  41130. teleportationEnabled: boolean;
  41131. private _defaultHeight;
  41132. private _teleportationInitialized;
  41133. private _interactionsEnabled;
  41134. private _interactionsRequested;
  41135. private _displayGaze;
  41136. private _displayLaserPointer;
  41137. /**
  41138. * The mesh used to display where the user is going to teleport.
  41139. */
  41140. /**
  41141. * Sets the mesh to be used to display where the user is going to teleport.
  41142. */
  41143. teleportationTarget: Mesh;
  41144. /**
  41145. * 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
  41146. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41147. * See http://doc.babylonjs.com/resources/baking_transformations
  41148. */
  41149. gazeTrackerMesh: Mesh;
  41150. /**
  41151. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41152. */
  41153. updateGazeTrackerScale: boolean;
  41154. /**
  41155. * If the gaze trackers color should be updated when selecting meshes
  41156. */
  41157. updateGazeTrackerColor: boolean;
  41158. /**
  41159. * The gaze tracking mesh corresponding to the left controller
  41160. */
  41161. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41162. /**
  41163. * The gaze tracking mesh corresponding to the right controller
  41164. */
  41165. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41166. /**
  41167. * If the ray of the gaze should be displayed.
  41168. */
  41169. /**
  41170. * Sets if the ray of the gaze should be displayed.
  41171. */
  41172. displayGaze: boolean;
  41173. /**
  41174. * If the ray of the LaserPointer should be displayed.
  41175. */
  41176. /**
  41177. * Sets if the ray of the LaserPointer should be displayed.
  41178. */
  41179. displayLaserPointer: boolean;
  41180. /**
  41181. * The deviceOrientationCamera used as the camera when not in VR.
  41182. */
  41183. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41184. /**
  41185. * Based on the current WebVR support, returns the current VR camera used.
  41186. */
  41187. readonly currentVRCamera: Nullable<Camera>;
  41188. /**
  41189. * The webVRCamera which is used when in VR.
  41190. */
  41191. readonly webVRCamera: WebVRFreeCamera;
  41192. /**
  41193. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41194. */
  41195. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41196. private readonly _teleportationRequestInitiated;
  41197. /**
  41198. * Defines wether or not Pointer lock should be requested when switching to
  41199. * full screen.
  41200. */
  41201. requestPointerLockOnFullScreen: boolean;
  41202. /**
  41203. * Instantiates a VRExperienceHelper.
  41204. * Helps to quickly add VR support to an existing scene.
  41205. * @param scene The scene the VRExperienceHelper belongs to.
  41206. * @param webVROptions Options to modify the vr experience helper's behavior.
  41207. */
  41208. constructor(scene: Scene,
  41209. /** Options to modify the vr experience helper's behavior. */
  41210. webVROptions?: VRExperienceHelperOptions);
  41211. private _onDefaultMeshLoaded;
  41212. private _onResize;
  41213. private _onFullscreenChange;
  41214. /**
  41215. * Gets a value indicating if we are currently in VR mode.
  41216. */
  41217. readonly isInVRMode: boolean;
  41218. private onVrDisplayPresentChange;
  41219. private onVRDisplayChanged;
  41220. private moveButtonToBottomRight;
  41221. private displayVRButton;
  41222. private updateButtonVisibility;
  41223. private _cachedAngularSensibility;
  41224. /**
  41225. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41226. * Otherwise, will use the fullscreen API.
  41227. */
  41228. enterVR(): void;
  41229. /**
  41230. * Attempt to exit VR, or fullscreen.
  41231. */
  41232. exitVR(): void;
  41233. /**
  41234. * The position of the vr experience helper.
  41235. */
  41236. /**
  41237. * Sets the position of the vr experience helper.
  41238. */
  41239. position: Vector3;
  41240. /**
  41241. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41242. */
  41243. enableInteractions(): void;
  41244. private readonly _noControllerIsActive;
  41245. private beforeRender;
  41246. private _isTeleportationFloor;
  41247. /**
  41248. * Adds a floor mesh to be used for teleportation.
  41249. * @param floorMesh the mesh to be used for teleportation.
  41250. */
  41251. addFloorMesh(floorMesh: Mesh): void;
  41252. /**
  41253. * Removes a floor mesh from being used for teleportation.
  41254. * @param floorMesh the mesh to be removed.
  41255. */
  41256. removeFloorMesh(floorMesh: Mesh): void;
  41257. /**
  41258. * Enables interactions and teleportation using the VR controllers and gaze.
  41259. * @param vrTeleportationOptions options to modify teleportation behavior.
  41260. */
  41261. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41262. private _onNewGamepadConnected;
  41263. private _tryEnableInteractionOnController;
  41264. private _onNewGamepadDisconnected;
  41265. private _enableInteractionOnController;
  41266. private _checkTeleportWithRay;
  41267. private _checkRotate;
  41268. private _checkTeleportBackwards;
  41269. private _enableTeleportationOnController;
  41270. private _createTeleportationCircles;
  41271. private _displayTeleportationTarget;
  41272. private _hideTeleportationTarget;
  41273. private _rotateCamera;
  41274. private _moveTeleportationSelectorTo;
  41275. private _workingVector;
  41276. private _workingQuaternion;
  41277. private _workingMatrix;
  41278. /**
  41279. * Teleports the users feet to the desired location
  41280. * @param location The location where the user's feet should be placed
  41281. */
  41282. teleportCamera(location: Vector3): void;
  41283. private _convertNormalToDirectionOfRay;
  41284. private _castRayAndSelectObject;
  41285. private _notifySelectedMeshUnselected;
  41286. /**
  41287. * Sets the color of the laser ray from the vr controllers.
  41288. * @param color new color for the ray.
  41289. */
  41290. changeLaserColor(color: Color3): void;
  41291. /**
  41292. * Sets the color of the ray from the vr headsets gaze.
  41293. * @param color new color for the ray.
  41294. */
  41295. changeGazeColor(color: Color3): void;
  41296. /**
  41297. * Exits VR and disposes of the vr experience helper
  41298. */
  41299. dispose(): void;
  41300. /**
  41301. * Gets the name of the VRExperienceHelper class
  41302. * @returns "VRExperienceHelper"
  41303. */
  41304. getClassName(): string;
  41305. }
  41306. }
  41307. declare module "babylonjs/Cameras/VR/index" {
  41308. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41309. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41310. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41311. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41312. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41313. export * from "babylonjs/Cameras/VR/webVRCamera";
  41314. }
  41315. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41316. import { Observable } from "babylonjs/Misc/observable";
  41317. import { Nullable } from "babylonjs/types";
  41318. import { IDisposable, Scene } from "babylonjs/scene";
  41319. import { Vector3 } from "babylonjs/Maths/math";
  41320. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41321. import { Ray } from "babylonjs/Culling/ray";
  41322. /**
  41323. * Manages an XRSession
  41324. * @see https://doc.babylonjs.com/how_to/webxr
  41325. */
  41326. export class WebXRSessionManager implements IDisposable {
  41327. private scene;
  41328. /**
  41329. * Fires every time a new xrFrame arrives which can be used to update the camera
  41330. */
  41331. onXRFrameObservable: Observable<any>;
  41332. /**
  41333. * Fires when the xr session is ended either by the device or manually done
  41334. */
  41335. onXRSessionEnded: Observable<any>;
  41336. /** @hidden */
  41337. _xrSession: XRSession;
  41338. /** @hidden */
  41339. _frameOfReference: XRFrameOfReference;
  41340. /** @hidden */
  41341. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41342. /** @hidden */
  41343. _currentXRFrame: Nullable<XRFrame>;
  41344. private _xrNavigator;
  41345. private _xrDevice;
  41346. private _tmpMatrix;
  41347. /**
  41348. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41349. * @param scene The scene which the session should be created for
  41350. */
  41351. constructor(scene: Scene);
  41352. /**
  41353. * Initializes the manager
  41354. * After initialization enterXR can be called to start an XR session
  41355. * @returns Promise which resolves after it is initialized
  41356. */
  41357. initializeAsync(): Promise<void>;
  41358. /**
  41359. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41360. * @param sessionCreationOptions xr options to create the session with
  41361. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41362. * @returns Promise which resolves after it enters XR
  41363. */
  41364. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41365. /**
  41366. * Stops the xrSession and restores the renderloop
  41367. * @returns Promise which resolves after it exits XR
  41368. */
  41369. exitXRAsync(): Promise<void>;
  41370. /**
  41371. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41372. * @param ray ray to cast into the environment
  41373. * @returns Promise which resolves with a collision point in the environment if it exists
  41374. */
  41375. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41376. /**
  41377. * Checks if a session would be supported for the creation options specified
  41378. * @param options creation options to check if they are supported
  41379. * @returns true if supported
  41380. */
  41381. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41382. /**
  41383. * @hidden
  41384. * Converts the render layer of xrSession to a render target
  41385. * @param session session to create render target for
  41386. * @param scene scene the new render target should be created for
  41387. */
  41388. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41389. /**
  41390. * Disposes of the session manager
  41391. */
  41392. dispose(): void;
  41393. }
  41394. }
  41395. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41396. import { Scene } from "babylonjs/scene";
  41397. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41398. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41399. /**
  41400. * WebXR Camera which holds the views for the xrSession
  41401. * @see https://doc.babylonjs.com/how_to/webxr
  41402. */
  41403. export class WebXRCamera extends FreeCamera {
  41404. private static _TmpMatrix;
  41405. /**
  41406. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41407. * @param name the name of the camera
  41408. * @param scene the scene to add the camera to
  41409. */
  41410. constructor(name: string, scene: Scene);
  41411. private _updateNumberOfRigCameras;
  41412. /** @hidden */
  41413. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41414. /**
  41415. * Updates the cameras position from the current pose information of the XR session
  41416. * @param xrSessionManager the session containing pose information
  41417. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41418. */
  41419. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41420. }
  41421. }
  41422. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41423. import { Nullable } from "babylonjs/types";
  41424. import { Observable } from "babylonjs/Misc/observable";
  41425. import { IDisposable, Scene } from "babylonjs/scene";
  41426. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41428. import { Ray } from "babylonjs/Culling/ray";
  41429. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41430. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41431. /**
  41432. * States of the webXR experience
  41433. */
  41434. export enum WebXRState {
  41435. /**
  41436. * Transitioning to being in XR mode
  41437. */
  41438. ENTERING_XR = 0,
  41439. /**
  41440. * Transitioning to non XR mode
  41441. */
  41442. EXITING_XR = 1,
  41443. /**
  41444. * In XR mode and presenting
  41445. */
  41446. IN_XR = 2,
  41447. /**
  41448. * Not entered XR mode
  41449. */
  41450. NOT_IN_XR = 3
  41451. }
  41452. /**
  41453. * Helper class used to enable XR
  41454. * @see https://doc.babylonjs.com/how_to/webxr
  41455. */
  41456. export class WebXRExperienceHelper implements IDisposable {
  41457. private scene;
  41458. /**
  41459. * 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
  41460. */
  41461. container: AbstractMesh;
  41462. /**
  41463. * Camera used to render xr content
  41464. */
  41465. camera: WebXRCamera;
  41466. /**
  41467. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41468. */
  41469. state: WebXRState;
  41470. private _setState;
  41471. private static _TmpVector;
  41472. /**
  41473. * Fires when the state of the experience helper has changed
  41474. */
  41475. onStateChangedObservable: Observable<WebXRState>;
  41476. /** @hidden */
  41477. _sessionManager: WebXRSessionManager;
  41478. private _nonVRCamera;
  41479. private _originalSceneAutoClear;
  41480. private _supported;
  41481. /**
  41482. * Creates the experience helper
  41483. * @param scene the scene to attach the experience helper to
  41484. * @returns a promise for the experience helper
  41485. */
  41486. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41487. /**
  41488. * Creates a WebXRExperienceHelper
  41489. * @param scene The scene the helper should be created in
  41490. */
  41491. private constructor();
  41492. /**
  41493. * Exits XR mode and returns the scene to its original state
  41494. * @returns promise that resolves after xr mode has exited
  41495. */
  41496. exitXRAsync(): Promise<void>;
  41497. /**
  41498. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41499. * @param sessionCreationOptions options for the XR session
  41500. * @param frameOfReference frame of reference of the XR session
  41501. * @returns promise that resolves after xr mode has entered
  41502. */
  41503. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41504. /**
  41505. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41506. * @param ray ray to cast into the environment
  41507. * @returns Promise which resolves with a collision point in the environment if it exists
  41508. */
  41509. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41510. /**
  41511. * Updates the global position of the camera by moving the camera's container
  41512. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41513. * @param position The desired global position of the camera
  41514. */
  41515. setPositionOfCameraUsingContainer(position: Vector3): void;
  41516. /**
  41517. * Rotates the xr camera by rotating the camera's container around the camera's position
  41518. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41519. * @param rotation the desired quaternion rotation to apply to the camera
  41520. */
  41521. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41522. /**
  41523. * Checks if the creation options are supported by the xr session
  41524. * @param options creation options
  41525. * @returns true if supported
  41526. */
  41527. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41528. /**
  41529. * Disposes of the experience helper
  41530. */
  41531. dispose(): void;
  41532. }
  41533. }
  41534. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41535. import { Nullable } from "babylonjs/types";
  41536. import { Observable } from "babylonjs/Misc/observable";
  41537. import { IDisposable, Scene } from "babylonjs/scene";
  41538. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41539. /**
  41540. * Button which can be used to enter a different mode of XR
  41541. */
  41542. export class WebXREnterExitUIButton {
  41543. /** button element */
  41544. element: HTMLElement;
  41545. /** XR initialization options for the button */
  41546. initializationOptions: XRSessionCreationOptions;
  41547. /**
  41548. * Creates a WebXREnterExitUIButton
  41549. * @param element button element
  41550. * @param initializationOptions XR initialization options for the button
  41551. */
  41552. constructor(
  41553. /** button element */
  41554. element: HTMLElement,
  41555. /** XR initialization options for the button */
  41556. initializationOptions: XRSessionCreationOptions);
  41557. /**
  41558. * Overwritable function which can be used to update the button's visuals when the state changes
  41559. * @param activeButton the current active button in the UI
  41560. */
  41561. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41562. }
  41563. /**
  41564. * Options to create the webXR UI
  41565. */
  41566. export class WebXREnterExitUIOptions {
  41567. /**
  41568. * Context to enter xr with
  41569. */
  41570. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41571. /**
  41572. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41573. */
  41574. customButtons?: Array<WebXREnterExitUIButton>;
  41575. }
  41576. /**
  41577. * UI to allow the user to enter/exit XR mode
  41578. */
  41579. export class WebXREnterExitUI implements IDisposable {
  41580. private scene;
  41581. private _overlay;
  41582. private _buttons;
  41583. private _activeButton;
  41584. /**
  41585. * Fired every time the active button is changed.
  41586. *
  41587. * When xr is entered via a button that launches xr that button will be the callback parameter
  41588. *
  41589. * When exiting xr the callback parameter will be null)
  41590. */
  41591. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41592. /**
  41593. * Creates UI to allow the user to enter/exit XR mode
  41594. * @param scene the scene to add the ui to
  41595. * @param helper the xr experience helper to enter/exit xr with
  41596. * @param options options to configure the UI
  41597. * @returns the created ui
  41598. */
  41599. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41600. private constructor();
  41601. private _updateButtons;
  41602. /**
  41603. * Disposes of the object
  41604. */
  41605. dispose(): void;
  41606. }
  41607. }
  41608. declare module "babylonjs/Cameras/XR/webXRInput" {
  41609. import { IDisposable, Scene } from "babylonjs/scene";
  41610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41611. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41612. /**
  41613. * Represents an XR input
  41614. */
  41615. export class WebXRController {
  41616. /**
  41617. * 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
  41618. */
  41619. grip?: AbstractMesh;
  41620. /**
  41621. * Pointer which can be used to select objects or attach a visible laser to
  41622. */
  41623. pointer: AbstractMesh;
  41624. /**
  41625. * Creates the controller
  41626. * @see https://doc.babylonjs.com/how_to/webxr
  41627. * @param scene the scene which the controller should be associated to
  41628. */
  41629. constructor(scene: Scene);
  41630. /**
  41631. * Disposes of the object
  41632. */
  41633. dispose(): void;
  41634. }
  41635. /**
  41636. * XR input used to track XR inputs such as controllers/rays
  41637. */
  41638. export class WebXRInput implements IDisposable {
  41639. private helper;
  41640. /**
  41641. * XR controllers being tracked
  41642. */
  41643. controllers: Array<WebXRController>;
  41644. private _tmpMatrix;
  41645. private _frameObserver;
  41646. /**
  41647. * Initializes the WebXRInput
  41648. * @param helper experience helper which the input should be created for
  41649. */
  41650. constructor(helper: WebXRExperienceHelper);
  41651. /**
  41652. * Disposes of the object
  41653. */
  41654. dispose(): void;
  41655. }
  41656. }
  41657. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41658. import { Nullable } from "babylonjs/types";
  41659. import { IDisposable } from "babylonjs/scene";
  41660. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41661. /**
  41662. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41663. */
  41664. export class WebXRManagedOutputCanvas implements IDisposable {
  41665. private _canvas;
  41666. /**
  41667. * xrpresent context of the canvas which can be used to display/mirror xr content
  41668. */
  41669. canvasContext: Nullable<WebGLRenderingContext>;
  41670. /**
  41671. * Initializes the canvas to be added/removed upon entering/exiting xr
  41672. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41673. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41674. */
  41675. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41676. /**
  41677. * Disposes of the object
  41678. */
  41679. dispose(): void;
  41680. private _setManagedOutputCanvas;
  41681. private _addCanvas;
  41682. private _removeCanvas;
  41683. }
  41684. }
  41685. declare module "babylonjs/Cameras/XR/index" {
  41686. export * from "babylonjs/Cameras/XR/webXRCamera";
  41687. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41688. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41689. export * from "babylonjs/Cameras/XR/webXRInput";
  41690. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41691. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41692. }
  41693. declare module "babylonjs/Cameras/RigModes/index" {
  41694. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41695. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41696. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41697. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41698. }
  41699. declare module "babylonjs/Cameras/index" {
  41700. export * from "babylonjs/Cameras/Inputs/index";
  41701. export * from "babylonjs/Cameras/cameraInputsManager";
  41702. export * from "babylonjs/Cameras/camera";
  41703. export * from "babylonjs/Cameras/targetCamera";
  41704. export * from "babylonjs/Cameras/freeCamera";
  41705. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41706. export * from "babylonjs/Cameras/touchCamera";
  41707. export * from "babylonjs/Cameras/arcRotateCamera";
  41708. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41709. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41710. export * from "babylonjs/Cameras/flyCamera";
  41711. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41712. export * from "babylonjs/Cameras/followCamera";
  41713. export * from "babylonjs/Cameras/gamepadCamera";
  41714. export * from "babylonjs/Cameras/Stereoscopic/index";
  41715. export * from "babylonjs/Cameras/universalCamera";
  41716. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41717. export * from "babylonjs/Cameras/VR/index";
  41718. export * from "babylonjs/Cameras/XR/index";
  41719. export * from "babylonjs/Cameras/RigModes/index";
  41720. }
  41721. declare module "babylonjs/Collisions/index" {
  41722. export * from "babylonjs/Collisions/collider";
  41723. export * from "babylonjs/Collisions/collisionCoordinator";
  41724. export * from "babylonjs/Collisions/pickingInfo";
  41725. export * from "babylonjs/Collisions/intersectionInfo";
  41726. }
  41727. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41728. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41729. import { Vector3, Plane } from "babylonjs/Maths/math";
  41730. import { Ray } from "babylonjs/Culling/ray";
  41731. /**
  41732. * Contains an array of blocks representing the octree
  41733. */
  41734. export interface IOctreeContainer<T> {
  41735. /**
  41736. * Blocks within the octree
  41737. */
  41738. blocks: Array<OctreeBlock<T>>;
  41739. }
  41740. /**
  41741. * Class used to store a cell in an octree
  41742. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41743. */
  41744. export class OctreeBlock<T> {
  41745. /**
  41746. * Gets the content of the current block
  41747. */
  41748. entries: T[];
  41749. /**
  41750. * Gets the list of block children
  41751. */
  41752. blocks: Array<OctreeBlock<T>>;
  41753. private _depth;
  41754. private _maxDepth;
  41755. private _capacity;
  41756. private _minPoint;
  41757. private _maxPoint;
  41758. private _boundingVectors;
  41759. private _creationFunc;
  41760. /**
  41761. * Creates a new block
  41762. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41763. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41764. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41765. * @param depth defines the current depth of this block in the octree
  41766. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41767. * @param creationFunc defines a callback to call when an element is added to the block
  41768. */
  41769. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41770. /**
  41771. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41772. */
  41773. readonly capacity: number;
  41774. /**
  41775. * Gets the minimum vector (in world space) of the block's bounding box
  41776. */
  41777. readonly minPoint: Vector3;
  41778. /**
  41779. * Gets the maximum vector (in world space) of the block's bounding box
  41780. */
  41781. readonly maxPoint: Vector3;
  41782. /**
  41783. * Add a new element to this block
  41784. * @param entry defines the element to add
  41785. */
  41786. addEntry(entry: T): void;
  41787. /**
  41788. * Remove an element from this block
  41789. * @param entry defines the element to remove
  41790. */
  41791. removeEntry(entry: T): void;
  41792. /**
  41793. * Add an array of elements to this block
  41794. * @param entries defines the array of elements to add
  41795. */
  41796. addEntries(entries: T[]): void;
  41797. /**
  41798. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41799. * @param frustumPlanes defines the frustum planes to test
  41800. * @param selection defines the array to store current content if selection is positive
  41801. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41802. */
  41803. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41804. /**
  41805. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41806. * @param sphereCenter defines the bounding sphere center
  41807. * @param sphereRadius defines the bounding sphere radius
  41808. * @param selection defines the array to store current content if selection is positive
  41809. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41810. */
  41811. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41812. /**
  41813. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41814. * @param ray defines the ray to test with
  41815. * @param selection defines the array to store current content if selection is positive
  41816. */
  41817. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41818. /**
  41819. * Subdivide the content into child blocks (this block will then be empty)
  41820. */
  41821. createInnerBlocks(): void;
  41822. /**
  41823. * @hidden
  41824. */
  41825. 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;
  41826. }
  41827. }
  41828. declare module "babylonjs/Culling/Octrees/octree" {
  41829. import { SmartArray } from "babylonjs/Misc/smartArray";
  41830. import { Vector3, Plane } from "babylonjs/Maths/math";
  41831. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41833. import { Ray } from "babylonjs/Culling/ray";
  41834. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41835. /**
  41836. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41837. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41838. */
  41839. export class Octree<T> {
  41840. /** 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.) */
  41841. maxDepth: number;
  41842. /**
  41843. * Blocks within the octree containing objects
  41844. */
  41845. blocks: Array<OctreeBlock<T>>;
  41846. /**
  41847. * Content stored in the octree
  41848. */
  41849. dynamicContent: T[];
  41850. private _maxBlockCapacity;
  41851. private _selectionContent;
  41852. private _creationFunc;
  41853. /**
  41854. * Creates a octree
  41855. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41856. * @param creationFunc function to be used to instatiate the octree
  41857. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41858. * @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.)
  41859. */
  41860. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41861. /** 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.) */
  41862. maxDepth?: number);
  41863. /**
  41864. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41865. * @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);
  41866. * @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);
  41867. * @param entries meshes to be added to the octree blocks
  41868. */
  41869. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41870. /**
  41871. * Adds a mesh to the octree
  41872. * @param entry Mesh to add to the octree
  41873. */
  41874. addMesh(entry: T): void;
  41875. /**
  41876. * Remove an element from the octree
  41877. * @param entry defines the element to remove
  41878. */
  41879. removeMesh(entry: T): void;
  41880. /**
  41881. * Selects an array of meshes within the frustum
  41882. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41883. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41884. * @returns array of meshes within the frustum
  41885. */
  41886. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41887. /**
  41888. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41889. * @param sphereCenter defines the bounding sphere center
  41890. * @param sphereRadius defines the bounding sphere radius
  41891. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41892. * @returns an array of objects that intersect the sphere
  41893. */
  41894. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41895. /**
  41896. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41897. * @param ray defines the ray to test with
  41898. * @returns array of intersected objects
  41899. */
  41900. intersectsRay(ray: Ray): SmartArray<T>;
  41901. /**
  41902. * Adds a mesh into the octree block if it intersects the block
  41903. */
  41904. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41905. /**
  41906. * Adds a submesh into the octree block if it intersects the block
  41907. */
  41908. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41909. }
  41910. }
  41911. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41912. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41913. import { Scene } from "babylonjs/scene";
  41914. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41916. import { Ray } from "babylonjs/Culling/ray";
  41917. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41918. import { Collider } from "babylonjs/Collisions/collider";
  41919. module "babylonjs/scene" {
  41920. interface Scene {
  41921. /**
  41922. * @hidden
  41923. * Backing Filed
  41924. */
  41925. _selectionOctree: Octree<AbstractMesh>;
  41926. /**
  41927. * Gets the octree used to boost mesh selection (picking)
  41928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41929. */
  41930. selectionOctree: Octree<AbstractMesh>;
  41931. /**
  41932. * Creates or updates the octree used to boost selection (picking)
  41933. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41934. * @param maxCapacity defines the maximum capacity per leaf
  41935. * @param maxDepth defines the maximum depth of the octree
  41936. * @returns an octree of AbstractMesh
  41937. */
  41938. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41939. }
  41940. }
  41941. module "babylonjs/Meshes/abstractMesh" {
  41942. interface AbstractMesh {
  41943. /**
  41944. * @hidden
  41945. * Backing Field
  41946. */
  41947. _submeshesOctree: Octree<SubMesh>;
  41948. /**
  41949. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41950. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41951. * @param maxCapacity defines the maximum size of each block (64 by default)
  41952. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41953. * @returns the new octree
  41954. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41955. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41956. */
  41957. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41958. }
  41959. }
  41960. /**
  41961. * Defines the octree scene component responsible to manage any octrees
  41962. * in a given scene.
  41963. */
  41964. export class OctreeSceneComponent {
  41965. /**
  41966. * The component name help to identify the component in the list of scene components.
  41967. */
  41968. readonly name: string;
  41969. /**
  41970. * The scene the component belongs to.
  41971. */
  41972. scene: Scene;
  41973. /**
  41974. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41975. */
  41976. readonly checksIsEnabled: boolean;
  41977. /**
  41978. * Creates a new instance of the component for the given scene
  41979. * @param scene Defines the scene to register the component in
  41980. */
  41981. constructor(scene: Scene);
  41982. /**
  41983. * Registers the component in a given scene
  41984. */
  41985. register(): void;
  41986. /**
  41987. * Return the list of active meshes
  41988. * @returns the list of active meshes
  41989. */
  41990. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41991. /**
  41992. * Return the list of active sub meshes
  41993. * @param mesh The mesh to get the candidates sub meshes from
  41994. * @returns the list of active sub meshes
  41995. */
  41996. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41997. private _tempRay;
  41998. /**
  41999. * Return the list of sub meshes intersecting with a given local ray
  42000. * @param mesh defines the mesh to find the submesh for
  42001. * @param localRay defines the ray in local space
  42002. * @returns the list of intersecting sub meshes
  42003. */
  42004. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42005. /**
  42006. * Return the list of sub meshes colliding with a collider
  42007. * @param mesh defines the mesh to find the submesh for
  42008. * @param collider defines the collider to evaluate the collision against
  42009. * @returns the list of colliding sub meshes
  42010. */
  42011. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42012. /**
  42013. * Rebuilds the elements related to this component in case of
  42014. * context lost for instance.
  42015. */
  42016. rebuild(): void;
  42017. /**
  42018. * Disposes the component and the associated ressources.
  42019. */
  42020. dispose(): void;
  42021. }
  42022. }
  42023. declare module "babylonjs/Culling/Octrees/index" {
  42024. export * from "babylonjs/Culling/Octrees/octree";
  42025. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42026. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42027. }
  42028. declare module "babylonjs/Culling/index" {
  42029. export * from "babylonjs/Culling/boundingBox";
  42030. export * from "babylonjs/Culling/boundingInfo";
  42031. export * from "babylonjs/Culling/boundingSphere";
  42032. export * from "babylonjs/Culling/Octrees/index";
  42033. export * from "babylonjs/Culling/ray";
  42034. }
  42035. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42036. import { IDisposable, Scene } from "babylonjs/scene";
  42037. import { Nullable } from "babylonjs/types";
  42038. import { Observable } from "babylonjs/Misc/observable";
  42039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42040. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42041. /**
  42042. * Renders a layer on top of an existing scene
  42043. */
  42044. export class UtilityLayerRenderer implements IDisposable {
  42045. /** the original scene that will be rendered on top of */
  42046. originalScene: Scene;
  42047. private _pointerCaptures;
  42048. private _lastPointerEvents;
  42049. private static _DefaultUtilityLayer;
  42050. private static _DefaultKeepDepthUtilityLayer;
  42051. private _sharedGizmoLight;
  42052. /**
  42053. * @hidden
  42054. * Light which used by gizmos to get light shading
  42055. */
  42056. _getSharedGizmoLight(): HemisphericLight;
  42057. /**
  42058. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42059. */
  42060. pickUtilitySceneFirst: boolean;
  42061. /**
  42062. * 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)
  42063. */
  42064. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42065. /**
  42066. * 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)
  42067. */
  42068. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42069. /**
  42070. * The scene that is rendered on top of the original scene
  42071. */
  42072. utilityLayerScene: Scene;
  42073. /**
  42074. * If the utility layer should automatically be rendered on top of existing scene
  42075. */
  42076. shouldRender: boolean;
  42077. /**
  42078. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42079. */
  42080. onlyCheckPointerDownEvents: boolean;
  42081. /**
  42082. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42083. */
  42084. processAllEvents: boolean;
  42085. /**
  42086. * Observable raised when the pointer move from the utility layer scene to the main scene
  42087. */
  42088. onPointerOutObservable: Observable<number>;
  42089. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42090. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42091. private _afterRenderObserver;
  42092. private _sceneDisposeObserver;
  42093. private _originalPointerObserver;
  42094. /**
  42095. * Instantiates a UtilityLayerRenderer
  42096. * @param originalScene the original scene that will be rendered on top of
  42097. * @param handleEvents boolean indicating if the utility layer should handle events
  42098. */
  42099. constructor(
  42100. /** the original scene that will be rendered on top of */
  42101. originalScene: Scene, handleEvents?: boolean);
  42102. private _notifyObservers;
  42103. /**
  42104. * Renders the utility layers scene on top of the original scene
  42105. */
  42106. render(): void;
  42107. /**
  42108. * Disposes of the renderer
  42109. */
  42110. dispose(): void;
  42111. private _updateCamera;
  42112. }
  42113. }
  42114. declare module "babylonjs/Gizmos/gizmo" {
  42115. import { Nullable } from "babylonjs/types";
  42116. import { IDisposable } from "babylonjs/scene";
  42117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42118. import { Mesh } from "babylonjs/Meshes/mesh";
  42119. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42120. /**
  42121. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42122. */
  42123. export class Gizmo implements IDisposable {
  42124. /** The utility layer the gizmo will be added to */
  42125. gizmoLayer: UtilityLayerRenderer;
  42126. /**
  42127. * The root mesh of the gizmo
  42128. */
  42129. _rootMesh: Mesh;
  42130. private _attachedMesh;
  42131. /**
  42132. * Ratio for the scale of the gizmo (Default: 1)
  42133. */
  42134. scaleRatio: number;
  42135. /**
  42136. * If a custom mesh has been set (Default: false)
  42137. */
  42138. protected _customMeshSet: boolean;
  42139. /**
  42140. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42141. * * When set, interactions will be enabled
  42142. */
  42143. attachedMesh: Nullable<AbstractMesh>;
  42144. /**
  42145. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42146. * @param mesh The mesh to replace the default mesh of the gizmo
  42147. */
  42148. setCustomMesh(mesh: Mesh): void;
  42149. /**
  42150. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42151. */
  42152. updateGizmoRotationToMatchAttachedMesh: boolean;
  42153. /**
  42154. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42155. */
  42156. updateGizmoPositionToMatchAttachedMesh: boolean;
  42157. /**
  42158. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42159. */
  42160. protected _updateScale: boolean;
  42161. protected _interactionsEnabled: boolean;
  42162. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42163. private _beforeRenderObserver;
  42164. private _tempVector;
  42165. /**
  42166. * Creates a gizmo
  42167. * @param gizmoLayer The utility layer the gizmo will be added to
  42168. */
  42169. constructor(
  42170. /** The utility layer the gizmo will be added to */
  42171. gizmoLayer?: UtilityLayerRenderer);
  42172. /**
  42173. * Updates the gizmo to match the attached mesh's position/rotation
  42174. */
  42175. protected _update(): void;
  42176. /**
  42177. * Disposes of the gizmo
  42178. */
  42179. dispose(): void;
  42180. }
  42181. }
  42182. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42183. import { Observable } from "babylonjs/Misc/observable";
  42184. import { Nullable } from "babylonjs/types";
  42185. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42186. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42188. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42189. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42190. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42191. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42192. import { Scene } from "babylonjs/scene";
  42193. /**
  42194. * Single axis drag gizmo
  42195. */
  42196. export class AxisDragGizmo extends Gizmo {
  42197. /**
  42198. * Drag behavior responsible for the gizmos dragging interactions
  42199. */
  42200. dragBehavior: PointerDragBehavior;
  42201. private _pointerObserver;
  42202. /**
  42203. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42204. */
  42205. snapDistance: number;
  42206. /**
  42207. * Event that fires each time the gizmo snaps to a new location.
  42208. * * snapDistance is the the change in distance
  42209. */
  42210. onSnapObservable: Observable<{
  42211. snapDistance: number;
  42212. }>;
  42213. /** @hidden */
  42214. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42215. /** @hidden */
  42216. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42217. /**
  42218. * Creates an AxisDragGizmo
  42219. * @param gizmoLayer The utility layer the gizmo will be added to
  42220. * @param dragAxis The axis which the gizmo will be able to drag on
  42221. * @param color The color of the gizmo
  42222. */
  42223. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42224. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42225. /**
  42226. * Disposes of the gizmo
  42227. */
  42228. dispose(): void;
  42229. }
  42230. }
  42231. declare module "babylonjs/Debug/axesViewer" {
  42232. import { Vector3 } from "babylonjs/Maths/math";
  42233. import { Nullable } from "babylonjs/types";
  42234. import { Scene } from "babylonjs/scene";
  42235. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42236. /**
  42237. * The Axes viewer will show 3 axes in a specific point in space
  42238. */
  42239. export class AxesViewer {
  42240. private _xAxis;
  42241. private _yAxis;
  42242. private _zAxis;
  42243. private _scaleLinesFactor;
  42244. private _instanced;
  42245. /**
  42246. * Gets the hosting scene
  42247. */
  42248. scene: Scene;
  42249. /**
  42250. * Gets or sets a number used to scale line length
  42251. */
  42252. scaleLines: number;
  42253. /** Gets the node hierarchy used to render x-axis */
  42254. readonly xAxis: TransformNode;
  42255. /** Gets the node hierarchy used to render y-axis */
  42256. readonly yAxis: TransformNode;
  42257. /** Gets the node hierarchy used to render z-axis */
  42258. readonly zAxis: TransformNode;
  42259. /**
  42260. * Creates a new AxesViewer
  42261. * @param scene defines the hosting scene
  42262. * @param scaleLines defines a number used to scale line length (1 by default)
  42263. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42264. * @param xAxis defines the node hierarchy used to render the x-axis
  42265. * @param yAxis defines the node hierarchy used to render the y-axis
  42266. * @param zAxis defines the node hierarchy used to render the z-axis
  42267. */
  42268. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42269. /**
  42270. * Force the viewer to update
  42271. * @param position defines the position of the viewer
  42272. * @param xaxis defines the x axis of the viewer
  42273. * @param yaxis defines the y axis of the viewer
  42274. * @param zaxis defines the z axis of the viewer
  42275. */
  42276. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42277. /**
  42278. * Creates an instance of this axes viewer.
  42279. * @returns a new axes viewer with instanced meshes
  42280. */
  42281. createInstance(): AxesViewer;
  42282. /** Releases resources */
  42283. dispose(): void;
  42284. private static _SetRenderingGroupId;
  42285. }
  42286. }
  42287. declare module "babylonjs/Debug/boneAxesViewer" {
  42288. import { Nullable } from "babylonjs/types";
  42289. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42290. import { Vector3 } from "babylonjs/Maths/math";
  42291. import { Mesh } from "babylonjs/Meshes/mesh";
  42292. import { Bone } from "babylonjs/Bones/bone";
  42293. import { Scene } from "babylonjs/scene";
  42294. /**
  42295. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42296. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42297. */
  42298. export class BoneAxesViewer extends AxesViewer {
  42299. /**
  42300. * Gets or sets the target mesh where to display the axes viewer
  42301. */
  42302. mesh: Nullable<Mesh>;
  42303. /**
  42304. * Gets or sets the target bone where to display the axes viewer
  42305. */
  42306. bone: Nullable<Bone>;
  42307. /** Gets current position */
  42308. pos: Vector3;
  42309. /** Gets direction of X axis */
  42310. xaxis: Vector3;
  42311. /** Gets direction of Y axis */
  42312. yaxis: Vector3;
  42313. /** Gets direction of Z axis */
  42314. zaxis: Vector3;
  42315. /**
  42316. * Creates a new BoneAxesViewer
  42317. * @param scene defines the hosting scene
  42318. * @param bone defines the target bone
  42319. * @param mesh defines the target mesh
  42320. * @param scaleLines defines a scaling factor for line length (1 by default)
  42321. */
  42322. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42323. /**
  42324. * Force the viewer to update
  42325. */
  42326. update(): void;
  42327. /** Releases resources */
  42328. dispose(): void;
  42329. }
  42330. }
  42331. declare module "babylonjs/Debug/debugLayer" {
  42332. import { Observable } from "babylonjs/Misc/observable";
  42333. import { Scene } from "babylonjs/scene";
  42334. /**
  42335. * Interface used to define scene explorer extensibility option
  42336. */
  42337. export interface IExplorerExtensibilityOption {
  42338. /**
  42339. * Define the option label
  42340. */
  42341. label: string;
  42342. /**
  42343. * Defines the action to execute on click
  42344. */
  42345. action: (entity: any) => void;
  42346. }
  42347. /**
  42348. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42349. */
  42350. export interface IExplorerExtensibilityGroup {
  42351. /**
  42352. * Defines a predicate to test if a given type mut be extended
  42353. */
  42354. predicate: (entity: any) => boolean;
  42355. /**
  42356. * Gets the list of options added to a type
  42357. */
  42358. entries: IExplorerExtensibilityOption[];
  42359. }
  42360. /**
  42361. * Interface used to define the options to use to create the Inspector
  42362. */
  42363. export interface IInspectorOptions {
  42364. /**
  42365. * Display in overlay mode (default: false)
  42366. */
  42367. overlay?: boolean;
  42368. /**
  42369. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42370. */
  42371. globalRoot?: HTMLElement;
  42372. /**
  42373. * Display the Scene explorer
  42374. */
  42375. showExplorer?: boolean;
  42376. /**
  42377. * Display the property inspector
  42378. */
  42379. showInspector?: boolean;
  42380. /**
  42381. * Display in embed mode (both panes on the right)
  42382. */
  42383. embedMode?: boolean;
  42384. /**
  42385. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42386. */
  42387. handleResize?: boolean;
  42388. /**
  42389. * Allow the panes to popup (default: true)
  42390. */
  42391. enablePopup?: boolean;
  42392. /**
  42393. * Allow the panes to be closed by users (default: true)
  42394. */
  42395. enableClose?: boolean;
  42396. /**
  42397. * Optional list of extensibility entries
  42398. */
  42399. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42400. /**
  42401. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42402. */
  42403. inspectorURL?: string;
  42404. }
  42405. module "babylonjs/scene" {
  42406. interface Scene {
  42407. /**
  42408. * @hidden
  42409. * Backing field
  42410. */
  42411. _debugLayer: DebugLayer;
  42412. /**
  42413. * Gets the debug layer (aka Inspector) associated with the scene
  42414. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42415. */
  42416. debugLayer: DebugLayer;
  42417. }
  42418. }
  42419. /**
  42420. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42421. * what is happening in your scene
  42422. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42423. */
  42424. export class DebugLayer {
  42425. /**
  42426. * Define the url to get the inspector script from.
  42427. * By default it uses the babylonjs CDN.
  42428. * @ignoreNaming
  42429. */
  42430. static InspectorURL: string;
  42431. private _scene;
  42432. private BJSINSPECTOR;
  42433. /**
  42434. * Observable triggered when a property is changed through the inspector.
  42435. */
  42436. onPropertyChangedObservable: Observable<{
  42437. object: any;
  42438. property: string;
  42439. value: any;
  42440. initialValue: any;
  42441. }>;
  42442. /**
  42443. * Instantiates a new debug layer.
  42444. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42445. * what is happening in your scene
  42446. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42447. * @param scene Defines the scene to inspect
  42448. */
  42449. constructor(scene: Scene);
  42450. /** Creates the inspector window. */
  42451. private _createInspector;
  42452. /**
  42453. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42454. * @param entity defines the entity to select
  42455. * @param lineContainerTitle defines the specific block to highlight
  42456. */
  42457. select(entity: any, lineContainerTitle?: string): void;
  42458. /** Get the inspector from bundle or global */
  42459. private _getGlobalInspector;
  42460. /**
  42461. * Get if the inspector is visible or not.
  42462. * @returns true if visible otherwise, false
  42463. */
  42464. isVisible(): boolean;
  42465. /**
  42466. * Hide the inspector and close its window.
  42467. */
  42468. hide(): void;
  42469. /**
  42470. * Launch the debugLayer.
  42471. * @param config Define the configuration of the inspector
  42472. * @return a promise fulfilled when the debug layer is visible
  42473. */
  42474. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42475. }
  42476. }
  42477. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42478. import { Nullable } from "babylonjs/types";
  42479. import { Scene } from "babylonjs/scene";
  42480. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42481. import { Mesh } from "babylonjs/Meshes/mesh";
  42482. /**
  42483. * Class containing static functions to help procedurally build meshes
  42484. */
  42485. export class BoxBuilder {
  42486. /**
  42487. * Creates a box mesh
  42488. * * The parameter `size` sets the size (float) of each box side (default 1)
  42489. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42490. * * 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)
  42491. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42495. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42496. * @param name defines the name of the mesh
  42497. * @param options defines the options used to create the mesh
  42498. * @param scene defines the hosting scene
  42499. * @returns the box mesh
  42500. */
  42501. static CreateBox(name: string, options: {
  42502. size?: number;
  42503. width?: number;
  42504. height?: number;
  42505. depth?: number;
  42506. faceUV?: Vector4[];
  42507. faceColors?: Color4[];
  42508. sideOrientation?: number;
  42509. frontUVs?: Vector4;
  42510. backUVs?: Vector4;
  42511. wrap?: boolean;
  42512. topBaseAt?: number;
  42513. bottomBaseAt?: number;
  42514. updatable?: boolean;
  42515. }, scene?: Nullable<Scene>): Mesh;
  42516. }
  42517. }
  42518. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42519. import { Vector4 } from "babylonjs/Maths/math";
  42520. import { Mesh } from "babylonjs/Meshes/mesh";
  42521. /**
  42522. * Class containing static functions to help procedurally build meshes
  42523. */
  42524. export class SphereBuilder {
  42525. /**
  42526. * Creates a sphere mesh
  42527. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42528. * * 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`)
  42529. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42530. * * 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
  42531. * * 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)
  42532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42535. * @param name defines the name of the mesh
  42536. * @param options defines the options used to create the mesh
  42537. * @param scene defines the hosting scene
  42538. * @returns the sphere mesh
  42539. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42540. */
  42541. static CreateSphere(name: string, options: {
  42542. segments?: number;
  42543. diameter?: number;
  42544. diameterX?: number;
  42545. diameterY?: number;
  42546. diameterZ?: number;
  42547. arc?: number;
  42548. slice?: number;
  42549. sideOrientation?: number;
  42550. frontUVs?: Vector4;
  42551. backUVs?: Vector4;
  42552. updatable?: boolean;
  42553. }, scene: any): Mesh;
  42554. }
  42555. }
  42556. declare module "babylonjs/Debug/physicsViewer" {
  42557. import { Nullable } from "babylonjs/types";
  42558. import { Scene } from "babylonjs/scene";
  42559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42560. import { Mesh } from "babylonjs/Meshes/mesh";
  42561. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42562. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42563. /**
  42564. * Used to show the physics impostor around the specific mesh
  42565. */
  42566. export class PhysicsViewer {
  42567. /** @hidden */
  42568. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42569. /** @hidden */
  42570. protected _meshes: Array<Nullable<AbstractMesh>>;
  42571. /** @hidden */
  42572. protected _scene: Nullable<Scene>;
  42573. /** @hidden */
  42574. protected _numMeshes: number;
  42575. /** @hidden */
  42576. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42577. private _renderFunction;
  42578. private _utilityLayer;
  42579. private _debugBoxMesh;
  42580. private _debugSphereMesh;
  42581. private _debugCylinderMesh;
  42582. private _debugMaterial;
  42583. private _debugMeshMeshes;
  42584. /**
  42585. * Creates a new PhysicsViewer
  42586. * @param scene defines the hosting scene
  42587. */
  42588. constructor(scene: Scene);
  42589. /** @hidden */
  42590. protected _updateDebugMeshes(): void;
  42591. /**
  42592. * Renders a specified physic impostor
  42593. * @param impostor defines the impostor to render
  42594. * @param targetMesh defines the mesh represented by the impostor
  42595. * @returns the new debug mesh used to render the impostor
  42596. */
  42597. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42598. /**
  42599. * Hides a specified physic impostor
  42600. * @param impostor defines the impostor to hide
  42601. */
  42602. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42603. private _getDebugMaterial;
  42604. private _getDebugBoxMesh;
  42605. private _getDebugSphereMesh;
  42606. private _getDebugCylinderMesh;
  42607. private _getDebugMeshMesh;
  42608. private _getDebugMesh;
  42609. /** Releases all resources */
  42610. dispose(): void;
  42611. }
  42612. }
  42613. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42614. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42615. import { Nullable } from "babylonjs/types";
  42616. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42617. import { Scene } from "babylonjs/scene";
  42618. /**
  42619. * Class containing static functions to help procedurally build meshes
  42620. */
  42621. export class LinesBuilder {
  42622. /**
  42623. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42624. * * 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
  42625. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42626. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42627. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42628. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42629. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42630. * * 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
  42631. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42634. * @param name defines the name of the new line system
  42635. * @param options defines the options used to create the line system
  42636. * @param scene defines the hosting scene
  42637. * @returns a new line system mesh
  42638. */
  42639. static CreateLineSystem(name: string, options: {
  42640. lines: Vector3[][];
  42641. updatable?: boolean;
  42642. instance?: Nullable<LinesMesh>;
  42643. colors?: Nullable<Color4[][]>;
  42644. useVertexAlpha?: boolean;
  42645. }, scene: Nullable<Scene>): LinesMesh;
  42646. /**
  42647. * Creates a line mesh
  42648. * 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
  42649. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42650. * * The parameter `points` is an array successive Vector3
  42651. * * 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
  42652. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42653. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42654. * * When updating an instance, remember that only point positions can change, not the number of points
  42655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42657. * @param name defines the name of the new line system
  42658. * @param options defines the options used to create the line system
  42659. * @param scene defines the hosting scene
  42660. * @returns a new line mesh
  42661. */
  42662. static CreateLines(name: string, options: {
  42663. points: Vector3[];
  42664. updatable?: boolean;
  42665. instance?: Nullable<LinesMesh>;
  42666. colors?: Color4[];
  42667. useVertexAlpha?: boolean;
  42668. }, scene?: Nullable<Scene>): LinesMesh;
  42669. /**
  42670. * Creates a dashed line mesh
  42671. * * 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
  42672. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42673. * * The parameter `points` is an array successive Vector3
  42674. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42675. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42676. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42677. * * 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
  42678. * * When updating an instance, remember that only point positions can change, not the number of points
  42679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42680. * @param name defines the name of the mesh
  42681. * @param options defines the options used to create the mesh
  42682. * @param scene defines the hosting scene
  42683. * @returns the dashed line mesh
  42684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42685. */
  42686. static CreateDashedLines(name: string, options: {
  42687. points: Vector3[];
  42688. dashSize?: number;
  42689. gapSize?: number;
  42690. dashNb?: number;
  42691. updatable?: boolean;
  42692. instance?: LinesMesh;
  42693. }, scene?: Nullable<Scene>): LinesMesh;
  42694. }
  42695. }
  42696. declare module "babylonjs/Debug/rayHelper" {
  42697. import { Nullable } from "babylonjs/types";
  42698. import { Ray } from "babylonjs/Culling/ray";
  42699. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42700. import { Scene } from "babylonjs/scene";
  42701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42702. import "babylonjs/Meshes/Builders/linesBuilder";
  42703. /**
  42704. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42705. * in order to better appreciate the issue one might have.
  42706. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42707. */
  42708. export class RayHelper {
  42709. /**
  42710. * Defines the ray we are currently tryin to visualize.
  42711. */
  42712. ray: Nullable<Ray>;
  42713. private _renderPoints;
  42714. private _renderLine;
  42715. private _renderFunction;
  42716. private _scene;
  42717. private _updateToMeshFunction;
  42718. private _attachedToMesh;
  42719. private _meshSpaceDirection;
  42720. private _meshSpaceOrigin;
  42721. /**
  42722. * Helper function to create a colored helper in a scene in one line.
  42723. * @param ray Defines the ray we are currently tryin to visualize
  42724. * @param scene Defines the scene the ray is used in
  42725. * @param color Defines the color we want to see the ray in
  42726. * @returns The newly created ray helper.
  42727. */
  42728. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42729. /**
  42730. * Instantiate a new ray helper.
  42731. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42732. * in order to better appreciate the issue one might have.
  42733. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42734. * @param ray Defines the ray we are currently tryin to visualize
  42735. */
  42736. constructor(ray: Ray);
  42737. /**
  42738. * Shows the ray we are willing to debug.
  42739. * @param scene Defines the scene the ray needs to be rendered in
  42740. * @param color Defines the color the ray needs to be rendered in
  42741. */
  42742. show(scene: Scene, color?: Color3): void;
  42743. /**
  42744. * Hides the ray we are debugging.
  42745. */
  42746. hide(): void;
  42747. private _render;
  42748. /**
  42749. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42750. * @param mesh Defines the mesh we want the helper attached to
  42751. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42752. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42753. * @param length Defines the length of the ray
  42754. */
  42755. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42756. /**
  42757. * Detach the ray helper from the mesh it has previously been attached to.
  42758. */
  42759. detachFromMesh(): void;
  42760. private _updateToMesh;
  42761. /**
  42762. * Dispose the helper and release its associated resources.
  42763. */
  42764. dispose(): void;
  42765. }
  42766. }
  42767. declare module "babylonjs/Debug/skeletonViewer" {
  42768. import { Color3 } from "babylonjs/Maths/math";
  42769. import { Scene } from "babylonjs/scene";
  42770. import { Nullable } from "babylonjs/types";
  42771. import { Skeleton } from "babylonjs/Bones/skeleton";
  42772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42773. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42774. /**
  42775. * Class used to render a debug view of a given skeleton
  42776. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42777. */
  42778. export class SkeletonViewer {
  42779. /** defines the skeleton to render */
  42780. skeleton: Skeleton;
  42781. /** defines the mesh attached to the skeleton */
  42782. mesh: AbstractMesh;
  42783. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42784. autoUpdateBonesMatrices: boolean;
  42785. /** defines the rendering group id to use with the viewer */
  42786. renderingGroupId: number;
  42787. /** Gets or sets the color used to render the skeleton */
  42788. color: Color3;
  42789. private _scene;
  42790. private _debugLines;
  42791. private _debugMesh;
  42792. private _isEnabled;
  42793. private _renderFunction;
  42794. private _utilityLayer;
  42795. /**
  42796. * Returns the mesh used to render the bones
  42797. */
  42798. readonly debugMesh: Nullable<LinesMesh>;
  42799. /**
  42800. * Creates a new SkeletonViewer
  42801. * @param skeleton defines the skeleton to render
  42802. * @param mesh defines the mesh attached to the skeleton
  42803. * @param scene defines the hosting scene
  42804. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42805. * @param renderingGroupId defines the rendering group id to use with the viewer
  42806. */
  42807. constructor(
  42808. /** defines the skeleton to render */
  42809. skeleton: Skeleton,
  42810. /** defines the mesh attached to the skeleton */
  42811. mesh: AbstractMesh, scene: Scene,
  42812. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42813. autoUpdateBonesMatrices?: boolean,
  42814. /** defines the rendering group id to use with the viewer */
  42815. renderingGroupId?: number);
  42816. /** Gets or sets a boolean indicating if the viewer is enabled */
  42817. isEnabled: boolean;
  42818. private _getBonePosition;
  42819. private _getLinesForBonesWithLength;
  42820. private _getLinesForBonesNoLength;
  42821. /** Update the viewer to sync with current skeleton state */
  42822. update(): void;
  42823. /** Release associated resources */
  42824. dispose(): void;
  42825. }
  42826. }
  42827. declare module "babylonjs/Debug/index" {
  42828. export * from "babylonjs/Debug/axesViewer";
  42829. export * from "babylonjs/Debug/boneAxesViewer";
  42830. export * from "babylonjs/Debug/debugLayer";
  42831. export * from "babylonjs/Debug/physicsViewer";
  42832. export * from "babylonjs/Debug/rayHelper";
  42833. export * from "babylonjs/Debug/skeletonViewer";
  42834. }
  42835. declare module "babylonjs/Engines/nullEngine" {
  42836. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42837. import { Scene } from "babylonjs/scene";
  42838. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42839. import { Engine } from "babylonjs/Engines/engine";
  42840. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42841. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42843. import { Effect } from "babylonjs/Materials/effect";
  42844. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42845. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42846. /**
  42847. * Options to create the null engine
  42848. */
  42849. export class NullEngineOptions {
  42850. /**
  42851. * Render width (Default: 512)
  42852. */
  42853. renderWidth: number;
  42854. /**
  42855. * Render height (Default: 256)
  42856. */
  42857. renderHeight: number;
  42858. /**
  42859. * Texture size (Default: 512)
  42860. */
  42861. textureSize: number;
  42862. /**
  42863. * If delta time between frames should be constant
  42864. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42865. */
  42866. deterministicLockstep: boolean;
  42867. /**
  42868. * Maximum about of steps between frames (Default: 4)
  42869. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42870. */
  42871. lockstepMaxSteps: number;
  42872. }
  42873. /**
  42874. * The null engine class provides support for headless version of babylon.js.
  42875. * This can be used in server side scenario or for testing purposes
  42876. */
  42877. export class NullEngine extends Engine {
  42878. private _options;
  42879. /**
  42880. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42881. */
  42882. isDeterministicLockStep(): boolean;
  42883. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42884. getLockstepMaxSteps(): number;
  42885. /**
  42886. * Sets hardware scaling, used to save performance if needed
  42887. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42888. */
  42889. getHardwareScalingLevel(): number;
  42890. constructor(options?: NullEngineOptions);
  42891. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42892. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42893. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42894. getRenderWidth(useScreen?: boolean): number;
  42895. getRenderHeight(useScreen?: boolean): number;
  42896. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42897. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42898. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42899. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42900. bindSamplers(effect: Effect): void;
  42901. enableEffect(effect: Effect): void;
  42902. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42903. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42904. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42905. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42906. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42907. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42908. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42909. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42910. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42911. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42912. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42913. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42914. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42915. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42916. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42917. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42918. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42919. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42920. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42921. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42922. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42923. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42924. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42925. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42926. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42927. bindBuffers(vertexBuffers: {
  42928. [key: string]: VertexBuffer;
  42929. }, indexBuffer: DataBuffer, effect: Effect): void;
  42930. wipeCaches(bruteForce?: boolean): void;
  42931. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42932. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42933. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42934. /** @hidden */
  42935. _createTexture(): WebGLTexture;
  42936. /** @hidden */
  42937. _releaseTexture(texture: InternalTexture): void;
  42938. 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;
  42939. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42940. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42941. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42942. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42943. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42944. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42945. areAllEffectsReady(): boolean;
  42946. /**
  42947. * @hidden
  42948. * Get the current error code of the webGL context
  42949. * @returns the error code
  42950. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42951. */
  42952. getError(): number;
  42953. /** @hidden */
  42954. _getUnpackAlignement(): number;
  42955. /** @hidden */
  42956. _unpackFlipY(value: boolean): void;
  42957. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42958. /**
  42959. * Updates a dynamic vertex buffer.
  42960. * @param vertexBuffer the vertex buffer to update
  42961. * @param data the data used to update the vertex buffer
  42962. * @param byteOffset the byte offset of the data (optional)
  42963. * @param byteLength the byte length of the data (optional)
  42964. */
  42965. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42966. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42967. /** @hidden */
  42968. _bindTexture(channel: number, texture: InternalTexture): void;
  42969. /** @hidden */
  42970. _releaseBuffer(buffer: DataBuffer): boolean;
  42971. releaseEffects(): void;
  42972. displayLoadingUI(): void;
  42973. hideLoadingUI(): void;
  42974. /** @hidden */
  42975. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42976. /** @hidden */
  42977. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42978. /** @hidden */
  42979. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42980. /** @hidden */
  42981. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42982. }
  42983. }
  42984. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42985. import { Nullable, int } from "babylonjs/types";
  42986. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42987. /** @hidden */
  42988. export class _OcclusionDataStorage {
  42989. /** @hidden */
  42990. occlusionInternalRetryCounter: number;
  42991. /** @hidden */
  42992. isOcclusionQueryInProgress: boolean;
  42993. /** @hidden */
  42994. isOccluded: boolean;
  42995. /** @hidden */
  42996. occlusionRetryCount: number;
  42997. /** @hidden */
  42998. occlusionType: number;
  42999. /** @hidden */
  43000. occlusionQueryAlgorithmType: number;
  43001. }
  43002. module "babylonjs/Engines/engine" {
  43003. interface Engine {
  43004. /**
  43005. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43006. * @return the new query
  43007. */
  43008. createQuery(): WebGLQuery;
  43009. /**
  43010. * Delete and release a webGL query
  43011. * @param query defines the query to delete
  43012. * @return the current engine
  43013. */
  43014. deleteQuery(query: WebGLQuery): Engine;
  43015. /**
  43016. * Check if a given query has resolved and got its value
  43017. * @param query defines the query to check
  43018. * @returns true if the query got its value
  43019. */
  43020. isQueryResultAvailable(query: WebGLQuery): boolean;
  43021. /**
  43022. * Gets the value of a given query
  43023. * @param query defines the query to check
  43024. * @returns the value of the query
  43025. */
  43026. getQueryResult(query: WebGLQuery): number;
  43027. /**
  43028. * Initiates an occlusion query
  43029. * @param algorithmType defines the algorithm to use
  43030. * @param query defines the query to use
  43031. * @returns the current engine
  43032. * @see http://doc.babylonjs.com/features/occlusionquery
  43033. */
  43034. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43035. /**
  43036. * Ends an occlusion query
  43037. * @see http://doc.babylonjs.com/features/occlusionquery
  43038. * @param algorithmType defines the algorithm to use
  43039. * @returns the current engine
  43040. */
  43041. endOcclusionQuery(algorithmType: number): Engine;
  43042. /**
  43043. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43044. * Please note that only one query can be issued at a time
  43045. * @returns a time token used to track the time span
  43046. */
  43047. startTimeQuery(): Nullable<_TimeToken>;
  43048. /**
  43049. * Ends a time query
  43050. * @param token defines the token used to measure the time span
  43051. * @returns the time spent (in ns)
  43052. */
  43053. endTimeQuery(token: _TimeToken): int;
  43054. /** @hidden */
  43055. _currentNonTimestampToken: Nullable<_TimeToken>;
  43056. /** @hidden */
  43057. _createTimeQuery(): WebGLQuery;
  43058. /** @hidden */
  43059. _deleteTimeQuery(query: WebGLQuery): void;
  43060. /** @hidden */
  43061. _getGlAlgorithmType(algorithmType: number): number;
  43062. /** @hidden */
  43063. _getTimeQueryResult(query: WebGLQuery): any;
  43064. /** @hidden */
  43065. _getTimeQueryAvailability(query: WebGLQuery): any;
  43066. }
  43067. }
  43068. module "babylonjs/Meshes/abstractMesh" {
  43069. interface AbstractMesh {
  43070. /**
  43071. * Backing filed
  43072. * @hidden
  43073. */
  43074. __occlusionDataStorage: _OcclusionDataStorage;
  43075. /**
  43076. * Access property
  43077. * @hidden
  43078. */
  43079. _occlusionDataStorage: _OcclusionDataStorage;
  43080. /**
  43081. * 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.
  43082. * The default value is -1 which means don't break the query and wait till the result
  43083. * @see http://doc.babylonjs.com/features/occlusionquery
  43084. */
  43085. occlusionRetryCount: number;
  43086. /**
  43087. * 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:
  43088. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43089. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43090. * * 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.
  43091. * @see http://doc.babylonjs.com/features/occlusionquery
  43092. */
  43093. occlusionType: number;
  43094. /**
  43095. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43096. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43097. * * 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.
  43098. * @see http://doc.babylonjs.com/features/occlusionquery
  43099. */
  43100. occlusionQueryAlgorithmType: number;
  43101. /**
  43102. * 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
  43103. * @see http://doc.babylonjs.com/features/occlusionquery
  43104. */
  43105. isOccluded: boolean;
  43106. /**
  43107. * Flag to check the progress status of the query
  43108. * @see http://doc.babylonjs.com/features/occlusionquery
  43109. */
  43110. isOcclusionQueryInProgress: boolean;
  43111. }
  43112. }
  43113. }
  43114. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43115. import { Nullable } from "babylonjs/types";
  43116. /** @hidden */
  43117. export var _forceTransformFeedbackToBundle: boolean;
  43118. module "babylonjs/Engines/engine" {
  43119. interface Engine {
  43120. /**
  43121. * Creates a webGL transform feedback object
  43122. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43123. * @returns the webGL transform feedback object
  43124. */
  43125. createTransformFeedback(): WebGLTransformFeedback;
  43126. /**
  43127. * Delete a webGL transform feedback object
  43128. * @param value defines the webGL transform feedback object to delete
  43129. */
  43130. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43131. /**
  43132. * Bind a webGL transform feedback object to the webgl context
  43133. * @param value defines the webGL transform feedback object to bind
  43134. */
  43135. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43136. /**
  43137. * Begins a transform feedback operation
  43138. * @param usePoints defines if points or triangles must be used
  43139. */
  43140. beginTransformFeedback(usePoints: boolean): void;
  43141. /**
  43142. * Ends a transform feedback operation
  43143. */
  43144. endTransformFeedback(): void;
  43145. /**
  43146. * Specify the varyings to use with transform feedback
  43147. * @param program defines the associated webGL program
  43148. * @param value defines the list of strings representing the varying names
  43149. */
  43150. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43151. /**
  43152. * Bind a webGL buffer for a transform feedback operation
  43153. * @param value defines the webGL buffer to bind
  43154. */
  43155. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43156. }
  43157. }
  43158. }
  43159. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43160. import { Scene } from "babylonjs/scene";
  43161. import { Engine } from "babylonjs/Engines/engine";
  43162. import { Texture } from "babylonjs/Materials/Textures/texture";
  43163. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43164. import "babylonjs/Engines/Extensions/engine.multiRender";
  43165. /**
  43166. * Creation options of the multi render target texture.
  43167. */
  43168. export interface IMultiRenderTargetOptions {
  43169. /**
  43170. * Define if the texture needs to create mip maps after render.
  43171. */
  43172. generateMipMaps?: boolean;
  43173. /**
  43174. * Define the types of all the draw buffers we want to create
  43175. */
  43176. types?: number[];
  43177. /**
  43178. * Define the sampling modes of all the draw buffers we want to create
  43179. */
  43180. samplingModes?: number[];
  43181. /**
  43182. * Define if a depth buffer is required
  43183. */
  43184. generateDepthBuffer?: boolean;
  43185. /**
  43186. * Define if a stencil buffer is required
  43187. */
  43188. generateStencilBuffer?: boolean;
  43189. /**
  43190. * Define if a depth texture is required instead of a depth buffer
  43191. */
  43192. generateDepthTexture?: boolean;
  43193. /**
  43194. * Define the number of desired draw buffers
  43195. */
  43196. textureCount?: number;
  43197. /**
  43198. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43199. */
  43200. doNotChangeAspectRatio?: boolean;
  43201. /**
  43202. * Define the default type of the buffers we are creating
  43203. */
  43204. defaultType?: number;
  43205. }
  43206. /**
  43207. * A multi render target, like a render target provides the ability to render to a texture.
  43208. * Unlike the render target, it can render to several draw buffers in one draw.
  43209. * This is specially interesting in deferred rendering or for any effects requiring more than
  43210. * just one color from a single pass.
  43211. */
  43212. export class MultiRenderTarget extends RenderTargetTexture {
  43213. private _internalTextures;
  43214. private _textures;
  43215. private _multiRenderTargetOptions;
  43216. /**
  43217. * Get if draw buffers are currently supported by the used hardware and browser.
  43218. */
  43219. readonly isSupported: boolean;
  43220. /**
  43221. * Get the list of textures generated by the multi render target.
  43222. */
  43223. readonly textures: Texture[];
  43224. /**
  43225. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43226. */
  43227. readonly depthTexture: Texture;
  43228. /**
  43229. * Set the wrapping mode on U of all the textures we are rendering to.
  43230. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43231. */
  43232. wrapU: number;
  43233. /**
  43234. * Set the wrapping mode on V of all the textures we are rendering to.
  43235. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43236. */
  43237. wrapV: number;
  43238. /**
  43239. * Instantiate a new multi render target texture.
  43240. * A multi render target, like a render target provides the ability to render to a texture.
  43241. * Unlike the render target, it can render to several draw buffers in one draw.
  43242. * This is specially interesting in deferred rendering or for any effects requiring more than
  43243. * just one color from a single pass.
  43244. * @param name Define the name of the texture
  43245. * @param size Define the size of the buffers to render to
  43246. * @param count Define the number of target we are rendering into
  43247. * @param scene Define the scene the texture belongs to
  43248. * @param options Define the options used to create the multi render target
  43249. */
  43250. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43251. /** @hidden */
  43252. _rebuild(): void;
  43253. private _createInternalTextures;
  43254. private _createTextures;
  43255. /**
  43256. * Define the number of samples used if MSAA is enabled.
  43257. */
  43258. samples: number;
  43259. /**
  43260. * Resize all the textures in the multi render target.
  43261. * Be carrefull as it will recreate all the data in the new texture.
  43262. * @param size Define the new size
  43263. */
  43264. resize(size: any): void;
  43265. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43266. /**
  43267. * Dispose the render targets and their associated resources
  43268. */
  43269. dispose(): void;
  43270. /**
  43271. * Release all the underlying texture used as draw buffers.
  43272. */
  43273. releaseInternalTextures(): void;
  43274. }
  43275. }
  43276. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43277. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43278. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43279. import { Nullable } from "babylonjs/types";
  43280. module "babylonjs/Engines/engine" {
  43281. interface Engine {
  43282. /**
  43283. * Unbind a list of render target textures from the webGL context
  43284. * This is used only when drawBuffer extension or webGL2 are active
  43285. * @param textures defines the render target textures to unbind
  43286. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43287. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43288. */
  43289. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43290. /**
  43291. * Create a multi render target texture
  43292. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43293. * @param size defines the size of the texture
  43294. * @param options defines the creation options
  43295. * @returns the cube texture as an InternalTexture
  43296. */
  43297. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43298. /**
  43299. * Update the sample count for a given multiple render target texture
  43300. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43301. * @param textures defines the textures to update
  43302. * @param samples defines the sample count to set
  43303. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43304. */
  43305. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43306. }
  43307. }
  43308. }
  43309. declare module "babylonjs/Engines/Extensions/index" {
  43310. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43311. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43312. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43313. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43314. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43315. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43316. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43317. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43318. }
  43319. declare module "babylonjs/Engines/index" {
  43320. export * from "babylonjs/Engines/constants";
  43321. export * from "babylonjs/Engines/engine";
  43322. export * from "babylonjs/Engines/engineStore";
  43323. export * from "babylonjs/Engines/nullEngine";
  43324. export * from "babylonjs/Engines/Extensions/index";
  43325. export * from "babylonjs/Engines/IPipelineContext";
  43326. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43327. }
  43328. declare module "babylonjs/Events/clipboardEvents" {
  43329. /**
  43330. * Gather the list of clipboard event types as constants.
  43331. */
  43332. export class ClipboardEventTypes {
  43333. /**
  43334. * The clipboard event is fired when a copy command is active (pressed).
  43335. */
  43336. static readonly COPY: number;
  43337. /**
  43338. * The clipboard event is fired when a cut command is active (pressed).
  43339. */
  43340. static readonly CUT: number;
  43341. /**
  43342. * The clipboard event is fired when a paste command is active (pressed).
  43343. */
  43344. static readonly PASTE: number;
  43345. }
  43346. /**
  43347. * This class is used to store clipboard related info for the onClipboardObservable event.
  43348. */
  43349. export class ClipboardInfo {
  43350. /**
  43351. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43352. */
  43353. type: number;
  43354. /**
  43355. * Defines the related dom event
  43356. */
  43357. event: ClipboardEvent;
  43358. /**
  43359. *Creates an instance of ClipboardInfo.
  43360. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43361. * @param event Defines the related dom event
  43362. */
  43363. constructor(
  43364. /**
  43365. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43366. */
  43367. type: number,
  43368. /**
  43369. * Defines the related dom event
  43370. */
  43371. event: ClipboardEvent);
  43372. /**
  43373. * Get the clipboard event's type from the keycode.
  43374. * @param keyCode Defines the keyCode for the current keyboard event.
  43375. * @return {number}
  43376. */
  43377. static GetTypeFromCharacter(keyCode: number): number;
  43378. }
  43379. }
  43380. declare module "babylonjs/Events/index" {
  43381. export * from "babylonjs/Events/keyboardEvents";
  43382. export * from "babylonjs/Events/pointerEvents";
  43383. export * from "babylonjs/Events/clipboardEvents";
  43384. }
  43385. declare module "babylonjs/Loading/sceneLoader" {
  43386. import { Observable } from "babylonjs/Misc/observable";
  43387. import { Nullable } from "babylonjs/types";
  43388. import { Scene } from "babylonjs/scene";
  43389. import { Engine } from "babylonjs/Engines/engine";
  43390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43391. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43392. import { AssetContainer } from "babylonjs/assetContainer";
  43393. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43394. import { Skeleton } from "babylonjs/Bones/skeleton";
  43395. /**
  43396. * Class used to represent data loading progression
  43397. */
  43398. export class SceneLoaderProgressEvent {
  43399. /** defines if data length to load can be evaluated */
  43400. readonly lengthComputable: boolean;
  43401. /** defines the loaded data length */
  43402. readonly loaded: number;
  43403. /** defines the data length to load */
  43404. readonly total: number;
  43405. /**
  43406. * Create a new progress event
  43407. * @param lengthComputable defines if data length to load can be evaluated
  43408. * @param loaded defines the loaded data length
  43409. * @param total defines the data length to load
  43410. */
  43411. constructor(
  43412. /** defines if data length to load can be evaluated */
  43413. lengthComputable: boolean,
  43414. /** defines the loaded data length */
  43415. loaded: number,
  43416. /** defines the data length to load */
  43417. total: number);
  43418. /**
  43419. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43420. * @param event defines the source event
  43421. * @returns a new SceneLoaderProgressEvent
  43422. */
  43423. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43424. }
  43425. /**
  43426. * Interface used by SceneLoader plugins to define supported file extensions
  43427. */
  43428. export interface ISceneLoaderPluginExtensions {
  43429. /**
  43430. * Defines the list of supported extensions
  43431. */
  43432. [extension: string]: {
  43433. isBinary: boolean;
  43434. };
  43435. }
  43436. /**
  43437. * Interface used by SceneLoader plugin factory
  43438. */
  43439. export interface ISceneLoaderPluginFactory {
  43440. /**
  43441. * Defines the name of the factory
  43442. */
  43443. name: string;
  43444. /**
  43445. * Function called to create a new plugin
  43446. * @return the new plugin
  43447. */
  43448. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43449. /**
  43450. * Boolean indicating if the plugin can direct load specific data
  43451. */
  43452. canDirectLoad?: (data: string) => boolean;
  43453. }
  43454. /**
  43455. * Interface used to define a SceneLoader plugin
  43456. */
  43457. export interface ISceneLoaderPlugin {
  43458. /**
  43459. * The friendly name of this plugin.
  43460. */
  43461. name: string;
  43462. /**
  43463. * The file extensions supported by this plugin.
  43464. */
  43465. extensions: string | ISceneLoaderPluginExtensions;
  43466. /**
  43467. * Import meshes into a scene.
  43468. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43469. * @param scene The scene to import into
  43470. * @param data The data to import
  43471. * @param rootUrl The root url for scene and resources
  43472. * @param meshes The meshes array to import into
  43473. * @param particleSystems The particle systems array to import into
  43474. * @param skeletons The skeletons array to import into
  43475. * @param onError The callback when import fails
  43476. * @returns True if successful or false otherwise
  43477. */
  43478. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43479. /**
  43480. * Load into a scene.
  43481. * @param scene The scene to load into
  43482. * @param data The data to import
  43483. * @param rootUrl The root url for scene and resources
  43484. * @param onError The callback when import fails
  43485. * @returns true if successful or false otherwise
  43486. */
  43487. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43488. /**
  43489. * The callback that returns true if the data can be directly loaded.
  43490. */
  43491. canDirectLoad?: (data: string) => boolean;
  43492. /**
  43493. * The callback that allows custom handling of the root url based on the response url.
  43494. */
  43495. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43496. /**
  43497. * Load into an asset container.
  43498. * @param scene The scene to load into
  43499. * @param data The data to import
  43500. * @param rootUrl The root url for scene and resources
  43501. * @param onError The callback when import fails
  43502. * @returns The loaded asset container
  43503. */
  43504. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43505. }
  43506. /**
  43507. * Interface used to define an async SceneLoader plugin
  43508. */
  43509. export interface ISceneLoaderPluginAsync {
  43510. /**
  43511. * The friendly name of this plugin.
  43512. */
  43513. name: string;
  43514. /**
  43515. * The file extensions supported by this plugin.
  43516. */
  43517. extensions: string | ISceneLoaderPluginExtensions;
  43518. /**
  43519. * Import meshes into a scene.
  43520. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43521. * @param scene The scene to import into
  43522. * @param data The data to import
  43523. * @param rootUrl The root url for scene and resources
  43524. * @param onProgress The callback when the load progresses
  43525. * @param fileName Defines the name of the file to load
  43526. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43527. */
  43528. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43529. meshes: AbstractMesh[];
  43530. particleSystems: IParticleSystem[];
  43531. skeletons: Skeleton[];
  43532. animationGroups: AnimationGroup[];
  43533. }>;
  43534. /**
  43535. * Load into a scene.
  43536. * @param scene The scene to load into
  43537. * @param data The data to import
  43538. * @param rootUrl The root url for scene and resources
  43539. * @param onProgress The callback when the load progresses
  43540. * @param fileName Defines the name of the file to load
  43541. * @returns Nothing
  43542. */
  43543. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43544. /**
  43545. * The callback that returns true if the data can be directly loaded.
  43546. */
  43547. canDirectLoad?: (data: string) => boolean;
  43548. /**
  43549. * The callback that allows custom handling of the root url based on the response url.
  43550. */
  43551. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43552. /**
  43553. * Load into an asset container.
  43554. * @param scene The scene to load into
  43555. * @param data The data to import
  43556. * @param rootUrl The root url for scene and resources
  43557. * @param onProgress The callback when the load progresses
  43558. * @param fileName Defines the name of the file to load
  43559. * @returns The loaded asset container
  43560. */
  43561. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43562. }
  43563. /**
  43564. * Class used to load scene from various file formats using registered plugins
  43565. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43566. */
  43567. export class SceneLoader {
  43568. /**
  43569. * No logging while loading
  43570. */
  43571. static readonly NO_LOGGING: number;
  43572. /**
  43573. * Minimal logging while loading
  43574. */
  43575. static readonly MINIMAL_LOGGING: number;
  43576. /**
  43577. * Summary logging while loading
  43578. */
  43579. static readonly SUMMARY_LOGGING: number;
  43580. /**
  43581. * Detailled logging while loading
  43582. */
  43583. static readonly DETAILED_LOGGING: number;
  43584. /**
  43585. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43586. */
  43587. static ForceFullSceneLoadingForIncremental: boolean;
  43588. /**
  43589. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43590. */
  43591. static ShowLoadingScreen: boolean;
  43592. /**
  43593. * Defines the current logging level (while loading the scene)
  43594. * @ignorenaming
  43595. */
  43596. static loggingLevel: number;
  43597. /**
  43598. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43599. */
  43600. static CleanBoneMatrixWeights: boolean;
  43601. /**
  43602. * Event raised when a plugin is used to load a scene
  43603. */
  43604. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43605. private static _registeredPlugins;
  43606. private static _getDefaultPlugin;
  43607. private static _getPluginForExtension;
  43608. private static _getPluginForDirectLoad;
  43609. private static _getPluginForFilename;
  43610. private static _getDirectLoad;
  43611. private static _loadData;
  43612. private static _getFileInfo;
  43613. /**
  43614. * Gets a plugin that can load the given extension
  43615. * @param extension defines the extension to load
  43616. * @returns a plugin or null if none works
  43617. */
  43618. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43619. /**
  43620. * Gets a boolean indicating that the given extension can be loaded
  43621. * @param extension defines the extension to load
  43622. * @returns true if the extension is supported
  43623. */
  43624. static IsPluginForExtensionAvailable(extension: string): boolean;
  43625. /**
  43626. * Adds a new plugin to the list of registered plugins
  43627. * @param plugin defines the plugin to add
  43628. */
  43629. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43630. /**
  43631. * Import meshes into a scene
  43632. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43633. * @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)
  43634. * @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)
  43635. * @param scene the instance of BABYLON.Scene to append to
  43636. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43637. * @param onProgress a callback with a progress event for each file being loaded
  43638. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43639. * @param pluginExtension the extension used to determine the plugin
  43640. * @returns The loaded plugin
  43641. */
  43642. 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>;
  43643. /**
  43644. * Import meshes into a scene
  43645. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43646. * @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)
  43647. * @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)
  43648. * @param scene the instance of BABYLON.Scene to append to
  43649. * @param onProgress a callback with a progress event for each file being loaded
  43650. * @param pluginExtension the extension used to determine the plugin
  43651. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43652. */
  43653. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43654. meshes: AbstractMesh[];
  43655. particleSystems: IParticleSystem[];
  43656. skeletons: Skeleton[];
  43657. animationGroups: AnimationGroup[];
  43658. }>;
  43659. /**
  43660. * Load a scene
  43661. * @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)
  43662. * @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)
  43663. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43664. * @param onSuccess a callback with the scene when import succeeds
  43665. * @param onProgress a callback with a progress event for each file being loaded
  43666. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43667. * @param pluginExtension the extension used to determine the plugin
  43668. * @returns The loaded plugin
  43669. */
  43670. 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>;
  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 onProgress a callback with a progress event for each file being loaded
  43677. * @param pluginExtension the extension used to determine the plugin
  43678. * @returns The loaded scene
  43679. */
  43680. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43681. /**
  43682. * Append a scene
  43683. * @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)
  43684. * @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)
  43685. * @param scene is the instance of BABYLON.Scene to append to
  43686. * @param onSuccess a callback with the scene when import succeeds
  43687. * @param onProgress a callback with a progress event for each file being loaded
  43688. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43689. * @param pluginExtension the extension used to determine the plugin
  43690. * @returns The loaded plugin
  43691. */
  43692. 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>;
  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 onProgress a callback with a progress event for each file being loaded
  43699. * @param pluginExtension the extension used to determine the plugin
  43700. * @returns The given scene
  43701. */
  43702. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43703. /**
  43704. * Load a scene into an asset container
  43705. * @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)
  43706. * @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)
  43707. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43708. * @param onSuccess a callback with the scene when import succeeds
  43709. * @param onProgress a callback with a progress event for each file being loaded
  43710. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43711. * @param pluginExtension the extension used to determine the plugin
  43712. * @returns The loaded plugin
  43713. */
  43714. 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>;
  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 (default: empty string)
  43719. * @param scene is the instance of Scene to append to
  43720. * @param onProgress a callback with a progress event for each file being loaded
  43721. * @param pluginExtension the extension used to determine the plugin
  43722. * @returns The loaded asset container
  43723. */
  43724. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43725. }
  43726. }
  43727. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43728. import { Scene } from "babylonjs/scene";
  43729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43730. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43731. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43732. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43733. /**
  43734. * Google Daydream controller
  43735. */
  43736. export class DaydreamController extends WebVRController {
  43737. /**
  43738. * Base Url for the controller model.
  43739. */
  43740. static MODEL_BASE_URL: string;
  43741. /**
  43742. * File name for the controller model.
  43743. */
  43744. static MODEL_FILENAME: string;
  43745. /**
  43746. * Gamepad Id prefix used to identify Daydream Controller.
  43747. */
  43748. static readonly GAMEPAD_ID_PREFIX: string;
  43749. /**
  43750. * Creates a new DaydreamController from a gamepad
  43751. * @param vrGamepad the gamepad that the controller should be created from
  43752. */
  43753. constructor(vrGamepad: any);
  43754. /**
  43755. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43756. * @param scene scene in which to add meshes
  43757. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43758. */
  43759. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43760. /**
  43761. * Called once for each button that changed state since the last frame
  43762. * @param buttonIdx Which button index changed
  43763. * @param state New state of the button
  43764. * @param changes Which properties on the state changed since last frame
  43765. */
  43766. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43767. }
  43768. }
  43769. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43770. import { Scene } from "babylonjs/scene";
  43771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43772. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43773. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43774. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43775. /**
  43776. * Gear VR Controller
  43777. */
  43778. export class GearVRController extends WebVRController {
  43779. /**
  43780. * Base Url for the controller model.
  43781. */
  43782. static MODEL_BASE_URL: string;
  43783. /**
  43784. * File name for the controller model.
  43785. */
  43786. static MODEL_FILENAME: string;
  43787. /**
  43788. * Gamepad Id prefix used to identify this controller.
  43789. */
  43790. static readonly GAMEPAD_ID_PREFIX: string;
  43791. private readonly _buttonIndexToObservableNameMap;
  43792. /**
  43793. * Creates a new GearVRController from a gamepad
  43794. * @param vrGamepad the gamepad that the controller should be created from
  43795. */
  43796. constructor(vrGamepad: any);
  43797. /**
  43798. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43799. * @param scene scene in which to add meshes
  43800. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43801. */
  43802. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43803. /**
  43804. * Called once for each button that changed state since the last frame
  43805. * @param buttonIdx Which button index changed
  43806. * @param state New state of the button
  43807. * @param changes Which properties on the state changed since last frame
  43808. */
  43809. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43810. }
  43811. }
  43812. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43813. import { Scene } from "babylonjs/scene";
  43814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43815. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43816. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43817. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43818. /**
  43819. * Generic Controller
  43820. */
  43821. export class GenericController extends WebVRController {
  43822. /**
  43823. * Base Url for the controller model.
  43824. */
  43825. static readonly MODEL_BASE_URL: string;
  43826. /**
  43827. * File name for the controller model.
  43828. */
  43829. static readonly MODEL_FILENAME: string;
  43830. /**
  43831. * Creates a new GenericController from a gamepad
  43832. * @param vrGamepad the gamepad that the controller should be created from
  43833. */
  43834. constructor(vrGamepad: any);
  43835. /**
  43836. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43837. * @param scene scene in which to add meshes
  43838. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43839. */
  43840. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43841. /**
  43842. * Called once for each button that changed state since the last frame
  43843. * @param buttonIdx Which button index changed
  43844. * @param state New state of the button
  43845. * @param changes Which properties on the state changed since last frame
  43846. */
  43847. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43848. }
  43849. }
  43850. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43851. import { Observable } from "babylonjs/Misc/observable";
  43852. import { Scene } from "babylonjs/scene";
  43853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43854. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43855. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43856. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43857. /**
  43858. * Oculus Touch Controller
  43859. */
  43860. export class OculusTouchController extends WebVRController {
  43861. /**
  43862. * Base Url for the controller model.
  43863. */
  43864. static MODEL_BASE_URL: string;
  43865. /**
  43866. * File name for the left controller model.
  43867. */
  43868. static MODEL_LEFT_FILENAME: string;
  43869. /**
  43870. * File name for the right controller model.
  43871. */
  43872. static MODEL_RIGHT_FILENAME: string;
  43873. /**
  43874. * Fired when the secondary trigger on this controller is modified
  43875. */
  43876. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43877. /**
  43878. * Fired when the thumb rest on this controller is modified
  43879. */
  43880. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43881. /**
  43882. * Creates a new OculusTouchController from a gamepad
  43883. * @param vrGamepad the gamepad that the controller should be created from
  43884. */
  43885. constructor(vrGamepad: any);
  43886. /**
  43887. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43888. * @param scene scene in which to add meshes
  43889. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43890. */
  43891. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43892. /**
  43893. * Fired when the A button on this controller is modified
  43894. */
  43895. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43896. /**
  43897. * Fired when the B button on this controller is modified
  43898. */
  43899. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43900. /**
  43901. * Fired when the X button on this controller is modified
  43902. */
  43903. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43904. /**
  43905. * Fired when the Y button on this controller is modified
  43906. */
  43907. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43908. /**
  43909. * Called once for each button that changed state since the last frame
  43910. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43911. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43912. * 2) secondary trigger (same)
  43913. * 3) A (right) X (left), touch, pressed = value
  43914. * 4) B / Y
  43915. * 5) thumb rest
  43916. * @param buttonIdx Which button index changed
  43917. * @param state New state of the button
  43918. * @param changes Which properties on the state changed since last frame
  43919. */
  43920. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43921. }
  43922. }
  43923. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43924. import { Scene } from "babylonjs/scene";
  43925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43926. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43927. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43928. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43929. import { Observable } from "babylonjs/Misc/observable";
  43930. /**
  43931. * Vive Controller
  43932. */
  43933. export class ViveController extends WebVRController {
  43934. /**
  43935. * Base Url for the controller model.
  43936. */
  43937. static MODEL_BASE_URL: string;
  43938. /**
  43939. * File name for the controller model.
  43940. */
  43941. static MODEL_FILENAME: string;
  43942. /**
  43943. * Creates a new ViveController from a gamepad
  43944. * @param vrGamepad the gamepad that the controller should be created from
  43945. */
  43946. constructor(vrGamepad: any);
  43947. /**
  43948. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43949. * @param scene scene in which to add meshes
  43950. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43951. */
  43952. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43953. /**
  43954. * Fired when the left button on this controller is modified
  43955. */
  43956. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43957. /**
  43958. * Fired when the right button on this controller is modified
  43959. */
  43960. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43961. /**
  43962. * Fired when the menu button on this controller is modified
  43963. */
  43964. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43965. /**
  43966. * Called once for each button that changed state since the last frame
  43967. * Vive mapping:
  43968. * 0: touchpad
  43969. * 1: trigger
  43970. * 2: left AND right buttons
  43971. * 3: menu button
  43972. * @param buttonIdx Which button index changed
  43973. * @param state New state of the button
  43974. * @param changes Which properties on the state changed since last frame
  43975. */
  43976. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43977. }
  43978. }
  43979. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43980. import { Observable } from "babylonjs/Misc/observable";
  43981. import { Scene } from "babylonjs/scene";
  43982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43983. import { Ray } from "babylonjs/Culling/ray";
  43984. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43985. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43986. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43987. /**
  43988. * Defines the WindowsMotionController object that the state of the windows motion controller
  43989. */
  43990. export class WindowsMotionController extends WebVRController {
  43991. /**
  43992. * The base url used to load the left and right controller models
  43993. */
  43994. static MODEL_BASE_URL: string;
  43995. /**
  43996. * The name of the left controller model file
  43997. */
  43998. static MODEL_LEFT_FILENAME: string;
  43999. /**
  44000. * The name of the right controller model file
  44001. */
  44002. static MODEL_RIGHT_FILENAME: string;
  44003. /**
  44004. * The controller name prefix for this controller type
  44005. */
  44006. static readonly GAMEPAD_ID_PREFIX: string;
  44007. /**
  44008. * The controller id pattern for this controller type
  44009. */
  44010. private static readonly GAMEPAD_ID_PATTERN;
  44011. private _loadedMeshInfo;
  44012. private readonly _mapping;
  44013. /**
  44014. * Fired when the trackpad on this controller is clicked
  44015. */
  44016. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44017. /**
  44018. * Fired when the trackpad on this controller is modified
  44019. */
  44020. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44021. /**
  44022. * The current x and y values of this controller's trackpad
  44023. */
  44024. trackpad: StickValues;
  44025. /**
  44026. * Creates a new WindowsMotionController from a gamepad
  44027. * @param vrGamepad the gamepad that the controller should be created from
  44028. */
  44029. constructor(vrGamepad: any);
  44030. /**
  44031. * Fired when the trigger on this controller is modified
  44032. */
  44033. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44034. /**
  44035. * Fired when the menu button on this controller is modified
  44036. */
  44037. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44038. /**
  44039. * Fired when the grip button on this controller is modified
  44040. */
  44041. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44042. /**
  44043. * Fired when the thumbstick button on this controller is modified
  44044. */
  44045. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44046. /**
  44047. * Fired when the touchpad button on this controller is modified
  44048. */
  44049. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44050. /**
  44051. * Fired when the touchpad values on this controller are modified
  44052. */
  44053. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44054. private _updateTrackpad;
  44055. /**
  44056. * Called once per frame by the engine.
  44057. */
  44058. update(): void;
  44059. /**
  44060. * Called once for each button that changed state since the last frame
  44061. * @param buttonIdx Which button index changed
  44062. * @param state New state of the button
  44063. * @param changes Which properties on the state changed since last frame
  44064. */
  44065. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44066. /**
  44067. * Moves the buttons on the controller mesh based on their current state
  44068. * @param buttonName the name of the button to move
  44069. * @param buttonValue the value of the button which determines the buttons new position
  44070. */
  44071. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44072. /**
  44073. * Moves the axis on the controller mesh based on its current state
  44074. * @param axis the index of the axis
  44075. * @param axisValue the value of the axis which determines the meshes new position
  44076. * @hidden
  44077. */
  44078. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44079. /**
  44080. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44081. * @param scene scene in which to add meshes
  44082. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44083. */
  44084. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44085. /**
  44086. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44087. * can be transformed by button presses and axes values, based on this._mapping.
  44088. *
  44089. * @param scene scene in which the meshes exist
  44090. * @param meshes list of meshes that make up the controller model to process
  44091. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44092. */
  44093. private processModel;
  44094. private createMeshInfo;
  44095. /**
  44096. * Gets the ray of the controller in the direction the controller is pointing
  44097. * @param length the length the resulting ray should be
  44098. * @returns a ray in the direction the controller is pointing
  44099. */
  44100. getForwardRay(length?: number): Ray;
  44101. /**
  44102. * Disposes of the controller
  44103. */
  44104. dispose(): void;
  44105. }
  44106. }
  44107. declare module "babylonjs/Gamepads/Controllers/index" {
  44108. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44109. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44110. export * from "babylonjs/Gamepads/Controllers/genericController";
  44111. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44112. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44113. export * from "babylonjs/Gamepads/Controllers/viveController";
  44114. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44115. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44116. }
  44117. declare module "babylonjs/Gamepads/index" {
  44118. export * from "babylonjs/Gamepads/Controllers/index";
  44119. export * from "babylonjs/Gamepads/gamepad";
  44120. export * from "babylonjs/Gamepads/gamepadManager";
  44121. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44122. export * from "babylonjs/Gamepads/xboxGamepad";
  44123. }
  44124. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44125. import { Observable } from "babylonjs/Misc/observable";
  44126. import { Nullable } from "babylonjs/types";
  44127. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44129. import { Mesh } from "babylonjs/Meshes/mesh";
  44130. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44131. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44132. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44133. /**
  44134. * Single axis scale gizmo
  44135. */
  44136. export class AxisScaleGizmo extends Gizmo {
  44137. private _coloredMaterial;
  44138. /**
  44139. * Drag behavior responsible for the gizmos dragging interactions
  44140. */
  44141. dragBehavior: PointerDragBehavior;
  44142. private _pointerObserver;
  44143. /**
  44144. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44145. */
  44146. snapDistance: number;
  44147. /**
  44148. * Event that fires each time the gizmo snaps to a new location.
  44149. * * snapDistance is the the change in distance
  44150. */
  44151. onSnapObservable: Observable<{
  44152. snapDistance: number;
  44153. }>;
  44154. /**
  44155. * If the scaling operation should be done on all axis (default: false)
  44156. */
  44157. uniformScaling: boolean;
  44158. /**
  44159. * Creates an AxisScaleGizmo
  44160. * @param gizmoLayer The utility layer the gizmo will be added to
  44161. * @param dragAxis The axis which the gizmo will be able to scale on
  44162. * @param color The color of the gizmo
  44163. */
  44164. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44165. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44166. /**
  44167. * Disposes of the gizmo
  44168. */
  44169. dispose(): void;
  44170. /**
  44171. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44172. * @param mesh The mesh to replace the default mesh of the gizmo
  44173. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44174. */
  44175. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44176. }
  44177. }
  44178. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44179. import { Observable } from "babylonjs/Misc/observable";
  44180. import { Nullable } from "babylonjs/types";
  44181. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44183. import { Mesh } from "babylonjs/Meshes/mesh";
  44184. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44185. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44186. import "babylonjs/Meshes/Builders/boxBuilder";
  44187. /**
  44188. * Bounding box gizmo
  44189. */
  44190. export class BoundingBoxGizmo extends Gizmo {
  44191. private _lineBoundingBox;
  44192. private _rotateSpheresParent;
  44193. private _scaleBoxesParent;
  44194. private _boundingDimensions;
  44195. private _renderObserver;
  44196. private _pointerObserver;
  44197. private _scaleDragSpeed;
  44198. private _tmpQuaternion;
  44199. private _tmpVector;
  44200. private _tmpRotationMatrix;
  44201. /**
  44202. * 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)
  44203. */
  44204. ignoreChildren: boolean;
  44205. /**
  44206. * 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)
  44207. */
  44208. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44209. /**
  44210. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44211. */
  44212. rotationSphereSize: number;
  44213. /**
  44214. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44215. */
  44216. scaleBoxSize: number;
  44217. /**
  44218. * 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)
  44219. */
  44220. fixedDragMeshScreenSize: boolean;
  44221. /**
  44222. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44223. */
  44224. fixedDragMeshScreenSizeDistanceFactor: number;
  44225. /**
  44226. * Fired when a rotation sphere or scale box is dragged
  44227. */
  44228. onDragStartObservable: Observable<{}>;
  44229. /**
  44230. * Fired when a scale box is dragged
  44231. */
  44232. onScaleBoxDragObservable: Observable<{}>;
  44233. /**
  44234. * Fired when a scale box drag is ended
  44235. */
  44236. onScaleBoxDragEndObservable: Observable<{}>;
  44237. /**
  44238. * Fired when a rotation sphere is dragged
  44239. */
  44240. onRotationSphereDragObservable: Observable<{}>;
  44241. /**
  44242. * Fired when a rotation sphere drag is ended
  44243. */
  44244. onRotationSphereDragEndObservable: Observable<{}>;
  44245. /**
  44246. * 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)
  44247. */
  44248. scalePivot: Nullable<Vector3>;
  44249. /**
  44250. * Mesh used as a pivot to rotate the attached mesh
  44251. */
  44252. private _anchorMesh;
  44253. private _existingMeshScale;
  44254. private _dragMesh;
  44255. private pointerDragBehavior;
  44256. private coloredMaterial;
  44257. private hoverColoredMaterial;
  44258. /**
  44259. * Sets the color of the bounding box gizmo
  44260. * @param color the color to set
  44261. */
  44262. setColor(color: Color3): void;
  44263. /**
  44264. * Creates an BoundingBoxGizmo
  44265. * @param gizmoLayer The utility layer the gizmo will be added to
  44266. * @param color The color of the gizmo
  44267. */
  44268. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44269. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44270. private _selectNode;
  44271. /**
  44272. * Updates the bounding box information for the Gizmo
  44273. */
  44274. updateBoundingBox(): void;
  44275. private _updateRotationSpheres;
  44276. private _updateScaleBoxes;
  44277. /**
  44278. * Enables rotation on the specified axis and disables rotation on the others
  44279. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44280. */
  44281. setEnabledRotationAxis(axis: string): void;
  44282. /**
  44283. * Enables/disables scaling
  44284. * @param enable if scaling should be enabled
  44285. */
  44286. setEnabledScaling(enable: boolean): void;
  44287. private _updateDummy;
  44288. /**
  44289. * Enables a pointer drag behavior on the bounding box of the gizmo
  44290. */
  44291. enableDragBehavior(): void;
  44292. /**
  44293. * Disposes of the gizmo
  44294. */
  44295. dispose(): void;
  44296. /**
  44297. * 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)
  44298. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44299. * @returns the bounding box mesh with the passed in mesh as a child
  44300. */
  44301. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44302. /**
  44303. * CustomMeshes are not supported by this gizmo
  44304. * @param mesh The mesh to replace the default mesh of the gizmo
  44305. */
  44306. setCustomMesh(mesh: Mesh): void;
  44307. }
  44308. }
  44309. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44310. import { Observable } from "babylonjs/Misc/observable";
  44311. import { Nullable } from "babylonjs/types";
  44312. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44314. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44315. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44316. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44317. import "babylonjs/Meshes/Builders/linesBuilder";
  44318. /**
  44319. * Single plane rotation gizmo
  44320. */
  44321. export class PlaneRotationGizmo extends Gizmo {
  44322. /**
  44323. * Drag behavior responsible for the gizmos dragging interactions
  44324. */
  44325. dragBehavior: PointerDragBehavior;
  44326. private _pointerObserver;
  44327. /**
  44328. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44329. */
  44330. snapDistance: number;
  44331. /**
  44332. * Event that fires each time the gizmo snaps to a new location.
  44333. * * snapDistance is the the change in distance
  44334. */
  44335. onSnapObservable: Observable<{
  44336. snapDistance: number;
  44337. }>;
  44338. /**
  44339. * Creates a PlaneRotationGizmo
  44340. * @param gizmoLayer The utility layer the gizmo will be added to
  44341. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44342. * @param color The color of the gizmo
  44343. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44344. */
  44345. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44346. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44347. /**
  44348. * Disposes of the gizmo
  44349. */
  44350. dispose(): void;
  44351. }
  44352. }
  44353. declare module "babylonjs/Gizmos/rotationGizmo" {
  44354. import { Observable } from "babylonjs/Misc/observable";
  44355. import { Nullable } from "babylonjs/types";
  44356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44357. import { Mesh } from "babylonjs/Meshes/mesh";
  44358. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44359. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44360. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44361. /**
  44362. * Gizmo that enables rotating a mesh along 3 axis
  44363. */
  44364. export class RotationGizmo extends Gizmo {
  44365. /**
  44366. * Internal gizmo used for interactions on the x axis
  44367. */
  44368. xGizmo: PlaneRotationGizmo;
  44369. /**
  44370. * Internal gizmo used for interactions on the y axis
  44371. */
  44372. yGizmo: PlaneRotationGizmo;
  44373. /**
  44374. * Internal gizmo used for interactions on the z axis
  44375. */
  44376. zGizmo: PlaneRotationGizmo;
  44377. /** Fires an event when any of it's sub gizmos are dragged */
  44378. onDragStartObservable: Observable<{}>;
  44379. /** Fires an event when any of it's sub gizmos are released from dragging */
  44380. onDragEndObservable: Observable<{}>;
  44381. attachedMesh: Nullable<AbstractMesh>;
  44382. /**
  44383. * Creates a RotationGizmo
  44384. * @param gizmoLayer The utility layer the gizmo will be added to
  44385. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44386. */
  44387. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44388. updateGizmoRotationToMatchAttachedMesh: boolean;
  44389. /**
  44390. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44391. */
  44392. snapDistance: number;
  44393. /**
  44394. * Ratio for the scale of the gizmo (Default: 1)
  44395. */
  44396. scaleRatio: number;
  44397. /**
  44398. * Disposes of the gizmo
  44399. */
  44400. dispose(): void;
  44401. /**
  44402. * CustomMeshes are not supported by this gizmo
  44403. * @param mesh The mesh to replace the default mesh of the gizmo
  44404. */
  44405. setCustomMesh(mesh: Mesh): void;
  44406. }
  44407. }
  44408. declare module "babylonjs/Gizmos/positionGizmo" {
  44409. import { Observable } from "babylonjs/Misc/observable";
  44410. import { Nullable } from "babylonjs/types";
  44411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44412. import { Mesh } from "babylonjs/Meshes/mesh";
  44413. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44414. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44415. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44416. /**
  44417. * Gizmo that enables dragging a mesh along 3 axis
  44418. */
  44419. export class PositionGizmo extends Gizmo {
  44420. /**
  44421. * Internal gizmo used for interactions on the x axis
  44422. */
  44423. xGizmo: AxisDragGizmo;
  44424. /**
  44425. * Internal gizmo used for interactions on the y axis
  44426. */
  44427. yGizmo: AxisDragGizmo;
  44428. /**
  44429. * Internal gizmo used for interactions on the z axis
  44430. */
  44431. zGizmo: AxisDragGizmo;
  44432. /** Fires an event when any of it's sub gizmos are dragged */
  44433. onDragStartObservable: Observable<{}>;
  44434. /** Fires an event when any of it's sub gizmos are released from dragging */
  44435. onDragEndObservable: Observable<{}>;
  44436. attachedMesh: Nullable<AbstractMesh>;
  44437. /**
  44438. * Creates a PositionGizmo
  44439. * @param gizmoLayer The utility layer the gizmo will be added to
  44440. */
  44441. constructor(gizmoLayer?: UtilityLayerRenderer);
  44442. updateGizmoRotationToMatchAttachedMesh: boolean;
  44443. /**
  44444. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44445. */
  44446. snapDistance: number;
  44447. /**
  44448. * Ratio for the scale of the gizmo (Default: 1)
  44449. */
  44450. scaleRatio: number;
  44451. /**
  44452. * Disposes of the gizmo
  44453. */
  44454. dispose(): void;
  44455. /**
  44456. * CustomMeshes are not supported by this gizmo
  44457. * @param mesh The mesh to replace the default mesh of the gizmo
  44458. */
  44459. setCustomMesh(mesh: Mesh): void;
  44460. }
  44461. }
  44462. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44463. import { Scene } from "babylonjs/scene";
  44464. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44465. import { Mesh } from "babylonjs/Meshes/mesh";
  44466. import { Nullable } from "babylonjs/types";
  44467. /**
  44468. * Class containing static functions to help procedurally build meshes
  44469. */
  44470. export class PolyhedronBuilder {
  44471. /**
  44472. * Creates a polyhedron mesh
  44473. * * 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
  44474. * * The parameter `size` (positive float, default 1) sets the polygon size
  44475. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44476. * * 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`
  44477. * * 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
  44478. * * 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)`)
  44479. * * 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
  44480. * * 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
  44481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44482. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44484. * @param name defines the name of the mesh
  44485. * @param options defines the options used to create the mesh
  44486. * @param scene defines the hosting scene
  44487. * @returns the polyhedron mesh
  44488. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44489. */
  44490. static CreatePolyhedron(name: string, options: {
  44491. type?: number;
  44492. size?: number;
  44493. sizeX?: number;
  44494. sizeY?: number;
  44495. sizeZ?: number;
  44496. custom?: any;
  44497. faceUV?: Vector4[];
  44498. faceColors?: Color4[];
  44499. flat?: boolean;
  44500. updatable?: boolean;
  44501. sideOrientation?: number;
  44502. frontUVs?: Vector4;
  44503. backUVs?: Vector4;
  44504. }, scene?: Nullable<Scene>): Mesh;
  44505. }
  44506. }
  44507. declare module "babylonjs/Gizmos/scaleGizmo" {
  44508. import { Observable } from "babylonjs/Misc/observable";
  44509. import { Nullable } from "babylonjs/types";
  44510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44511. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44512. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44513. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44514. /**
  44515. * Gizmo that enables scaling a mesh along 3 axis
  44516. */
  44517. export class ScaleGizmo extends Gizmo {
  44518. /**
  44519. * Internal gizmo used for interactions on the x axis
  44520. */
  44521. xGizmo: AxisScaleGizmo;
  44522. /**
  44523. * Internal gizmo used for interactions on the y axis
  44524. */
  44525. yGizmo: AxisScaleGizmo;
  44526. /**
  44527. * Internal gizmo used for interactions on the z axis
  44528. */
  44529. zGizmo: AxisScaleGizmo;
  44530. /**
  44531. * Internal gizmo used to scale all axis equally
  44532. */
  44533. uniformScaleGizmo: AxisScaleGizmo;
  44534. /** Fires an event when any of it's sub gizmos are dragged */
  44535. onDragStartObservable: Observable<{}>;
  44536. /** Fires an event when any of it's sub gizmos are released from dragging */
  44537. onDragEndObservable: Observable<{}>;
  44538. attachedMesh: Nullable<AbstractMesh>;
  44539. /**
  44540. * Creates a ScaleGizmo
  44541. * @param gizmoLayer The utility layer the gizmo will be added to
  44542. */
  44543. constructor(gizmoLayer?: UtilityLayerRenderer);
  44544. updateGizmoRotationToMatchAttachedMesh: boolean;
  44545. /**
  44546. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44547. */
  44548. snapDistance: number;
  44549. /**
  44550. * Ratio for the scale of the gizmo (Default: 1)
  44551. */
  44552. scaleRatio: number;
  44553. /**
  44554. * Disposes of the gizmo
  44555. */
  44556. dispose(): void;
  44557. }
  44558. }
  44559. declare module "babylonjs/Gizmos/gizmoManager" {
  44560. import { Observable } from "babylonjs/Misc/observable";
  44561. import { Nullable } from "babylonjs/types";
  44562. import { Scene, IDisposable } from "babylonjs/scene";
  44563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44564. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44565. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44566. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44567. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44568. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44569. /**
  44570. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44571. */
  44572. export class GizmoManager implements IDisposable {
  44573. private scene;
  44574. /**
  44575. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44576. */
  44577. gizmos: {
  44578. positionGizmo: Nullable<PositionGizmo>;
  44579. rotationGizmo: Nullable<RotationGizmo>;
  44580. scaleGizmo: Nullable<ScaleGizmo>;
  44581. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44582. };
  44583. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44584. clearGizmoOnEmptyPointerEvent: boolean;
  44585. /** Fires an event when the manager is attached to a mesh */
  44586. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44587. private _gizmosEnabled;
  44588. private _pointerObserver;
  44589. private _attachedMesh;
  44590. private _boundingBoxColor;
  44591. private _defaultUtilityLayer;
  44592. private _defaultKeepDepthUtilityLayer;
  44593. /**
  44594. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44595. */
  44596. boundingBoxDragBehavior: SixDofDragBehavior;
  44597. /**
  44598. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44599. */
  44600. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44601. /**
  44602. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44603. */
  44604. usePointerToAttachGizmos: boolean;
  44605. /**
  44606. * Instatiates a gizmo manager
  44607. * @param scene the scene to overlay the gizmos on top of
  44608. */
  44609. constructor(scene: Scene);
  44610. /**
  44611. * Attaches a set of gizmos to the specified mesh
  44612. * @param mesh The mesh the gizmo's should be attached to
  44613. */
  44614. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44615. /**
  44616. * If the position gizmo is enabled
  44617. */
  44618. positionGizmoEnabled: boolean;
  44619. /**
  44620. * If the rotation gizmo is enabled
  44621. */
  44622. rotationGizmoEnabled: boolean;
  44623. /**
  44624. * If the scale gizmo is enabled
  44625. */
  44626. scaleGizmoEnabled: boolean;
  44627. /**
  44628. * If the boundingBox gizmo is enabled
  44629. */
  44630. boundingBoxGizmoEnabled: boolean;
  44631. /**
  44632. * Disposes of the gizmo manager
  44633. */
  44634. dispose(): void;
  44635. }
  44636. }
  44637. declare module "babylonjs/Lights/directionalLight" {
  44638. import { Camera } from "babylonjs/Cameras/camera";
  44639. import { Scene } from "babylonjs/scene";
  44640. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44642. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44643. import { Effect } from "babylonjs/Materials/effect";
  44644. /**
  44645. * A directional light is defined by a direction (what a surprise!).
  44646. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44647. * 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.
  44648. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44649. */
  44650. export class DirectionalLight extends ShadowLight {
  44651. private _shadowFrustumSize;
  44652. /**
  44653. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44654. */
  44655. /**
  44656. * Specifies a fix frustum size for the shadow generation.
  44657. */
  44658. shadowFrustumSize: number;
  44659. private _shadowOrthoScale;
  44660. /**
  44661. * Gets the shadow projection scale against the optimal computed one.
  44662. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44663. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44664. */
  44665. /**
  44666. * Sets the shadow projection scale against the optimal computed one.
  44667. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44668. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44669. */
  44670. shadowOrthoScale: number;
  44671. /**
  44672. * Automatically compute the projection matrix to best fit (including all the casters)
  44673. * on each frame.
  44674. */
  44675. autoUpdateExtends: boolean;
  44676. private _orthoLeft;
  44677. private _orthoRight;
  44678. private _orthoTop;
  44679. private _orthoBottom;
  44680. /**
  44681. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44682. * The directional light is emitted from everywhere in the given direction.
  44683. * It can cast shadows.
  44684. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44685. * @param name The friendly name of the light
  44686. * @param direction The direction of the light
  44687. * @param scene The scene the light belongs to
  44688. */
  44689. constructor(name: string, direction: Vector3, scene: Scene);
  44690. /**
  44691. * Returns the string "DirectionalLight".
  44692. * @return The class name
  44693. */
  44694. getClassName(): string;
  44695. /**
  44696. * Returns the integer 1.
  44697. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44698. */
  44699. getTypeID(): number;
  44700. /**
  44701. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44702. * Returns the DirectionalLight Shadow projection matrix.
  44703. */
  44704. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44705. /**
  44706. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44707. * Returns the DirectionalLight Shadow projection matrix.
  44708. */
  44709. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44710. /**
  44711. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44712. * Returns the DirectionalLight Shadow projection matrix.
  44713. */
  44714. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44715. protected _buildUniformLayout(): void;
  44716. /**
  44717. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44718. * @param effect The effect to update
  44719. * @param lightIndex The index of the light in the effect to update
  44720. * @returns The directional light
  44721. */
  44722. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44723. /**
  44724. * Gets the minZ used for shadow according to both the scene and the light.
  44725. *
  44726. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44727. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44728. * @param activeCamera The camera we are returning the min for
  44729. * @returns the depth min z
  44730. */
  44731. getDepthMinZ(activeCamera: Camera): number;
  44732. /**
  44733. * Gets the maxZ used for shadow according to both the scene and the light.
  44734. *
  44735. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44736. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44737. * @param activeCamera The camera we are returning the max for
  44738. * @returns the depth max z
  44739. */
  44740. getDepthMaxZ(activeCamera: Camera): number;
  44741. /**
  44742. * Prepares the list of defines specific to the light type.
  44743. * @param defines the list of defines
  44744. * @param lightIndex defines the index of the light for the effect
  44745. */
  44746. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44747. }
  44748. }
  44749. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44750. import { Mesh } from "babylonjs/Meshes/mesh";
  44751. /**
  44752. * Class containing static functions to help procedurally build meshes
  44753. */
  44754. export class HemisphereBuilder {
  44755. /**
  44756. * Creates a hemisphere mesh
  44757. * @param name defines the name of the mesh
  44758. * @param options defines the options used to create the mesh
  44759. * @param scene defines the hosting scene
  44760. * @returns the hemisphere mesh
  44761. */
  44762. static CreateHemisphere(name: string, options: {
  44763. segments?: number;
  44764. diameter?: number;
  44765. sideOrientation?: number;
  44766. }, scene: any): Mesh;
  44767. }
  44768. }
  44769. declare module "babylonjs/Lights/spotLight" {
  44770. import { Nullable } from "babylonjs/types";
  44771. import { Scene } from "babylonjs/scene";
  44772. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44774. import { Effect } from "babylonjs/Materials/effect";
  44775. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44776. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44777. /**
  44778. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44779. * These values define a cone of light starting from the position, emitting toward the direction.
  44780. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44781. * and the exponent defines the speed of the decay of the light with distance (reach).
  44782. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44783. */
  44784. export class SpotLight extends ShadowLight {
  44785. private _angle;
  44786. private _innerAngle;
  44787. private _cosHalfAngle;
  44788. private _lightAngleScale;
  44789. private _lightAngleOffset;
  44790. /**
  44791. * Gets the cone angle of the spot light in Radians.
  44792. */
  44793. /**
  44794. * Sets the cone angle of the spot light in Radians.
  44795. */
  44796. angle: number;
  44797. /**
  44798. * Only used in gltf falloff mode, this defines the angle where
  44799. * the directional falloff will start before cutting at angle which could be seen
  44800. * as outer angle.
  44801. */
  44802. /**
  44803. * Only used in gltf falloff mode, this defines the angle where
  44804. * the directional falloff will start before cutting at angle which could be seen
  44805. * as outer angle.
  44806. */
  44807. innerAngle: number;
  44808. private _shadowAngleScale;
  44809. /**
  44810. * Allows scaling the angle of the light for shadow generation only.
  44811. */
  44812. /**
  44813. * Allows scaling the angle of the light for shadow generation only.
  44814. */
  44815. shadowAngleScale: number;
  44816. /**
  44817. * The light decay speed with the distance from the emission spot.
  44818. */
  44819. exponent: number;
  44820. private _projectionTextureMatrix;
  44821. /**
  44822. * Allows reading the projecton texture
  44823. */
  44824. readonly projectionTextureMatrix: Matrix;
  44825. protected _projectionTextureLightNear: number;
  44826. /**
  44827. * Gets the near clip of the Spotlight for texture projection.
  44828. */
  44829. /**
  44830. * Sets the near clip of the Spotlight for texture projection.
  44831. */
  44832. projectionTextureLightNear: number;
  44833. protected _projectionTextureLightFar: number;
  44834. /**
  44835. * Gets the far clip of the Spotlight for texture projection.
  44836. */
  44837. /**
  44838. * Sets the far clip of the Spotlight for texture projection.
  44839. */
  44840. projectionTextureLightFar: number;
  44841. protected _projectionTextureUpDirection: Vector3;
  44842. /**
  44843. * Gets the Up vector of the Spotlight for texture projection.
  44844. */
  44845. /**
  44846. * Sets the Up vector of the Spotlight for texture projection.
  44847. */
  44848. projectionTextureUpDirection: Vector3;
  44849. private _projectionTexture;
  44850. /**
  44851. * Gets the projection texture of the light.
  44852. */
  44853. /**
  44854. * Sets the projection texture of the light.
  44855. */
  44856. projectionTexture: Nullable<BaseTexture>;
  44857. private _projectionTextureViewLightDirty;
  44858. private _projectionTextureProjectionLightDirty;
  44859. private _projectionTextureDirty;
  44860. private _projectionTextureViewTargetVector;
  44861. private _projectionTextureViewLightMatrix;
  44862. private _projectionTextureProjectionLightMatrix;
  44863. private _projectionTextureScalingMatrix;
  44864. /**
  44865. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44866. * It can cast shadows.
  44867. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44868. * @param name The light friendly name
  44869. * @param position The position of the spot light in the scene
  44870. * @param direction The direction of the light in the scene
  44871. * @param angle The cone angle of the light in Radians
  44872. * @param exponent The light decay speed with the distance from the emission spot
  44873. * @param scene The scene the lights belongs to
  44874. */
  44875. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44876. /**
  44877. * Returns the string "SpotLight".
  44878. * @returns the class name
  44879. */
  44880. getClassName(): string;
  44881. /**
  44882. * Returns the integer 2.
  44883. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44884. */
  44885. getTypeID(): number;
  44886. /**
  44887. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44888. */
  44889. protected _setDirection(value: Vector3): void;
  44890. /**
  44891. * Overrides the position setter to recompute the projection texture view light Matrix.
  44892. */
  44893. protected _setPosition(value: Vector3): void;
  44894. /**
  44895. * 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.
  44896. * Returns the SpotLight.
  44897. */
  44898. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44899. protected _computeProjectionTextureViewLightMatrix(): void;
  44900. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44901. /**
  44902. * Main function for light texture projection matrix computing.
  44903. */
  44904. protected _computeProjectionTextureMatrix(): void;
  44905. protected _buildUniformLayout(): void;
  44906. private _computeAngleValues;
  44907. /**
  44908. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44909. * @param effect The effect to update
  44910. * @param lightIndex The index of the light in the effect to update
  44911. * @returns The spot light
  44912. */
  44913. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44914. /**
  44915. * Disposes the light and the associated resources.
  44916. */
  44917. dispose(): void;
  44918. /**
  44919. * Prepares the list of defines specific to the light type.
  44920. * @param defines the list of defines
  44921. * @param lightIndex defines the index of the light for the effect
  44922. */
  44923. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44924. }
  44925. }
  44926. declare module "babylonjs/Gizmos/lightGizmo" {
  44927. import { Nullable } from "babylonjs/types";
  44928. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44929. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44930. import { Light } from "babylonjs/Lights/light";
  44931. /**
  44932. * Gizmo that enables viewing a light
  44933. */
  44934. export class LightGizmo extends Gizmo {
  44935. private _lightMesh;
  44936. private _material;
  44937. /**
  44938. * Creates a LightGizmo
  44939. * @param gizmoLayer The utility layer the gizmo will be added to
  44940. */
  44941. constructor(gizmoLayer?: UtilityLayerRenderer);
  44942. private _light;
  44943. /**
  44944. * The light that the gizmo is attached to
  44945. */
  44946. light: Nullable<Light>;
  44947. /**
  44948. * @hidden
  44949. * Updates the gizmo to match the attached mesh's position/rotation
  44950. */
  44951. protected _update(): void;
  44952. private static _Scale;
  44953. /**
  44954. * Creates the lines for a light mesh
  44955. */
  44956. private static _createLightLines;
  44957. private static _CreateHemisphericLightMesh;
  44958. private static _CreatePointLightMesh;
  44959. private static _CreateSpotLightMesh;
  44960. private static _CreateDirectionalLightMesh;
  44961. }
  44962. }
  44963. declare module "babylonjs/Gizmos/index" {
  44964. export * from "babylonjs/Gizmos/axisDragGizmo";
  44965. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44966. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44967. export * from "babylonjs/Gizmos/gizmo";
  44968. export * from "babylonjs/Gizmos/gizmoManager";
  44969. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44970. export * from "babylonjs/Gizmos/positionGizmo";
  44971. export * from "babylonjs/Gizmos/rotationGizmo";
  44972. export * from "babylonjs/Gizmos/scaleGizmo";
  44973. export * from "babylonjs/Gizmos/lightGizmo";
  44974. }
  44975. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44976. /** @hidden */
  44977. export var backgroundFragmentDeclaration: {
  44978. name: string;
  44979. shader: string;
  44980. };
  44981. }
  44982. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44983. /** @hidden */
  44984. export var backgroundUboDeclaration: {
  44985. name: string;
  44986. shader: string;
  44987. };
  44988. }
  44989. declare module "babylonjs/Shaders/background.fragment" {
  44990. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44991. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44992. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44993. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44994. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44995. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44996. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44997. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44998. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44999. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45000. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45001. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45002. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45003. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45004. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45005. /** @hidden */
  45006. export var backgroundPixelShader: {
  45007. name: string;
  45008. shader: string;
  45009. };
  45010. }
  45011. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45012. /** @hidden */
  45013. export var backgroundVertexDeclaration: {
  45014. name: string;
  45015. shader: string;
  45016. };
  45017. }
  45018. declare module "babylonjs/Shaders/background.vertex" {
  45019. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45020. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45021. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45022. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45023. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45024. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45025. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45026. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45027. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45028. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45029. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45030. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45031. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45032. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45033. /** @hidden */
  45034. export var backgroundVertexShader: {
  45035. name: string;
  45036. shader: string;
  45037. };
  45038. }
  45039. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45040. import { Nullable, int, float } from "babylonjs/types";
  45041. import { Scene } from "babylonjs/scene";
  45042. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45043. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45045. import { Mesh } from "babylonjs/Meshes/mesh";
  45046. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45047. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45048. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45050. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45051. import "babylonjs/Shaders/background.fragment";
  45052. import "babylonjs/Shaders/background.vertex";
  45053. /**
  45054. * Background material used to create an efficient environement around your scene.
  45055. */
  45056. export class BackgroundMaterial extends PushMaterial {
  45057. /**
  45058. * Standard reflectance value at parallel view angle.
  45059. */
  45060. static StandardReflectance0: number;
  45061. /**
  45062. * Standard reflectance value at grazing angle.
  45063. */
  45064. static StandardReflectance90: number;
  45065. protected _primaryColor: Color3;
  45066. /**
  45067. * Key light Color (multiply against the environement texture)
  45068. */
  45069. primaryColor: Color3;
  45070. protected __perceptualColor: Nullable<Color3>;
  45071. /**
  45072. * Experimental Internal Use Only.
  45073. *
  45074. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45075. * This acts as a helper to set the primary color to a more "human friendly" value.
  45076. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45077. * output color as close as possible from the chosen value.
  45078. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45079. * part of lighting setup.)
  45080. */
  45081. _perceptualColor: Nullable<Color3>;
  45082. protected _primaryColorShadowLevel: float;
  45083. /**
  45084. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45085. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45086. */
  45087. primaryColorShadowLevel: float;
  45088. protected _primaryColorHighlightLevel: float;
  45089. /**
  45090. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45091. * The primary color is used at the level chosen to define what the white area would look.
  45092. */
  45093. primaryColorHighlightLevel: float;
  45094. protected _reflectionTexture: Nullable<BaseTexture>;
  45095. /**
  45096. * Reflection Texture used in the material.
  45097. * Should be author in a specific way for the best result (refer to the documentation).
  45098. */
  45099. reflectionTexture: Nullable<BaseTexture>;
  45100. protected _reflectionBlur: float;
  45101. /**
  45102. * Reflection Texture level of blur.
  45103. *
  45104. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45105. * texture twice.
  45106. */
  45107. reflectionBlur: float;
  45108. protected _diffuseTexture: Nullable<BaseTexture>;
  45109. /**
  45110. * Diffuse Texture used in the material.
  45111. * Should be author in a specific way for the best result (refer to the documentation).
  45112. */
  45113. diffuseTexture: Nullable<BaseTexture>;
  45114. protected _shadowLights: Nullable<IShadowLight[]>;
  45115. /**
  45116. * Specify the list of lights casting shadow on the material.
  45117. * All scene shadow lights will be included if null.
  45118. */
  45119. shadowLights: Nullable<IShadowLight[]>;
  45120. protected _shadowLevel: float;
  45121. /**
  45122. * Helps adjusting the shadow to a softer level if required.
  45123. * 0 means black shadows and 1 means no shadows.
  45124. */
  45125. shadowLevel: float;
  45126. protected _sceneCenter: Vector3;
  45127. /**
  45128. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45129. * It is usually zero but might be interesting to modify according to your setup.
  45130. */
  45131. sceneCenter: Vector3;
  45132. protected _opacityFresnel: boolean;
  45133. /**
  45134. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45135. * This helps ensuring a nice transition when the camera goes under the ground.
  45136. */
  45137. opacityFresnel: boolean;
  45138. protected _reflectionFresnel: boolean;
  45139. /**
  45140. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45141. * This helps adding a mirror texture on the ground.
  45142. */
  45143. reflectionFresnel: boolean;
  45144. protected _reflectionFalloffDistance: number;
  45145. /**
  45146. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45147. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45148. */
  45149. reflectionFalloffDistance: number;
  45150. protected _reflectionAmount: number;
  45151. /**
  45152. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45153. */
  45154. reflectionAmount: number;
  45155. protected _reflectionReflectance0: number;
  45156. /**
  45157. * This specifies the weight of the reflection at grazing angle.
  45158. */
  45159. reflectionReflectance0: number;
  45160. protected _reflectionReflectance90: number;
  45161. /**
  45162. * This specifies the weight of the reflection at a perpendicular point of view.
  45163. */
  45164. reflectionReflectance90: number;
  45165. /**
  45166. * Sets the reflection reflectance fresnel values according to the default standard
  45167. * empirically know to work well :-)
  45168. */
  45169. reflectionStandardFresnelWeight: number;
  45170. protected _useRGBColor: boolean;
  45171. /**
  45172. * Helps to directly use the maps channels instead of their level.
  45173. */
  45174. useRGBColor: boolean;
  45175. protected _enableNoise: boolean;
  45176. /**
  45177. * This helps reducing the banding effect that could occur on the background.
  45178. */
  45179. enableNoise: boolean;
  45180. /**
  45181. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45182. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45183. * Recommended to be keep at 1.0 except for special cases.
  45184. */
  45185. fovMultiplier: number;
  45186. private _fovMultiplier;
  45187. /**
  45188. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45189. */
  45190. useEquirectangularFOV: boolean;
  45191. private _maxSimultaneousLights;
  45192. /**
  45193. * Number of Simultaneous lights allowed on the material.
  45194. */
  45195. maxSimultaneousLights: int;
  45196. /**
  45197. * Default configuration related to image processing available in the Background Material.
  45198. */
  45199. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45200. /**
  45201. * Keep track of the image processing observer to allow dispose and replace.
  45202. */
  45203. private _imageProcessingObserver;
  45204. /**
  45205. * Attaches a new image processing configuration to the PBR Material.
  45206. * @param configuration (if null the scene configuration will be use)
  45207. */
  45208. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45209. /**
  45210. * Gets the image processing configuration used either in this material.
  45211. */
  45212. /**
  45213. * Sets the Default image processing configuration used either in the this material.
  45214. *
  45215. * If sets to null, the scene one is in use.
  45216. */
  45217. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45218. /**
  45219. * Gets wether the color curves effect is enabled.
  45220. */
  45221. /**
  45222. * Sets wether the color curves effect is enabled.
  45223. */
  45224. cameraColorCurvesEnabled: boolean;
  45225. /**
  45226. * Gets wether the color grading effect is enabled.
  45227. */
  45228. /**
  45229. * Gets wether the color grading effect is enabled.
  45230. */
  45231. cameraColorGradingEnabled: boolean;
  45232. /**
  45233. * Gets wether tonemapping is enabled or not.
  45234. */
  45235. /**
  45236. * Sets wether tonemapping is enabled or not
  45237. */
  45238. cameraToneMappingEnabled: boolean;
  45239. /**
  45240. * The camera exposure used on this material.
  45241. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45242. * This corresponds to a photographic exposure.
  45243. */
  45244. /**
  45245. * The camera exposure used on this material.
  45246. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45247. * This corresponds to a photographic exposure.
  45248. */
  45249. cameraExposure: float;
  45250. /**
  45251. * Gets The camera contrast used on this material.
  45252. */
  45253. /**
  45254. * Sets The camera contrast used on this material.
  45255. */
  45256. cameraContrast: float;
  45257. /**
  45258. * Gets the Color Grading 2D Lookup Texture.
  45259. */
  45260. /**
  45261. * Sets the Color Grading 2D Lookup Texture.
  45262. */
  45263. cameraColorGradingTexture: Nullable<BaseTexture>;
  45264. /**
  45265. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45266. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45267. * 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;
  45268. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45269. */
  45270. /**
  45271. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45272. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45273. * 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;
  45274. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45275. */
  45276. cameraColorCurves: Nullable<ColorCurves>;
  45277. /**
  45278. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45279. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45280. */
  45281. switchToBGR: boolean;
  45282. private _renderTargets;
  45283. private _reflectionControls;
  45284. private _white;
  45285. private _primaryShadowColor;
  45286. private _primaryHighlightColor;
  45287. /**
  45288. * Instantiates a Background Material in the given scene
  45289. * @param name The friendly name of the material
  45290. * @param scene The scene to add the material to
  45291. */
  45292. constructor(name: string, scene: Scene);
  45293. /**
  45294. * Gets a boolean indicating that current material needs to register RTT
  45295. */
  45296. readonly hasRenderTargetTextures: boolean;
  45297. /**
  45298. * The entire material has been created in order to prevent overdraw.
  45299. * @returns false
  45300. */
  45301. needAlphaTesting(): boolean;
  45302. /**
  45303. * The entire material has been created in order to prevent overdraw.
  45304. * @returns true if blending is enable
  45305. */
  45306. needAlphaBlending(): boolean;
  45307. /**
  45308. * Checks wether the material is ready to be rendered for a given mesh.
  45309. * @param mesh The mesh to render
  45310. * @param subMesh The submesh to check against
  45311. * @param useInstances Specify wether or not the material is used with instances
  45312. * @returns true if all the dependencies are ready (Textures, Effects...)
  45313. */
  45314. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45315. /**
  45316. * Compute the primary color according to the chosen perceptual color.
  45317. */
  45318. private _computePrimaryColorFromPerceptualColor;
  45319. /**
  45320. * Compute the highlights and shadow colors according to their chosen levels.
  45321. */
  45322. private _computePrimaryColors;
  45323. /**
  45324. * Build the uniform buffer used in the material.
  45325. */
  45326. buildUniformLayout(): void;
  45327. /**
  45328. * Unbind the material.
  45329. */
  45330. unbind(): void;
  45331. /**
  45332. * Bind only the world matrix to the material.
  45333. * @param world The world matrix to bind.
  45334. */
  45335. bindOnlyWorldMatrix(world: Matrix): void;
  45336. /**
  45337. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45338. * @param world The world matrix to bind.
  45339. * @param subMesh The submesh to bind for.
  45340. */
  45341. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45342. /**
  45343. * Dispose the material.
  45344. * @param forceDisposeEffect Force disposal of the associated effect.
  45345. * @param forceDisposeTextures Force disposal of the associated textures.
  45346. */
  45347. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45348. /**
  45349. * Clones the material.
  45350. * @param name The cloned name.
  45351. * @returns The cloned material.
  45352. */
  45353. clone(name: string): BackgroundMaterial;
  45354. /**
  45355. * Serializes the current material to its JSON representation.
  45356. * @returns The JSON representation.
  45357. */
  45358. serialize(): any;
  45359. /**
  45360. * Gets the class name of the material
  45361. * @returns "BackgroundMaterial"
  45362. */
  45363. getClassName(): string;
  45364. /**
  45365. * Parse a JSON input to create back a background material.
  45366. * @param source The JSON data to parse
  45367. * @param scene The scene to create the parsed material in
  45368. * @param rootUrl The root url of the assets the material depends upon
  45369. * @returns the instantiated BackgroundMaterial.
  45370. */
  45371. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45372. }
  45373. }
  45374. declare module "babylonjs/Helpers/environmentHelper" {
  45375. import { Observable } from "babylonjs/Misc/observable";
  45376. import { Nullable } from "babylonjs/types";
  45377. import { Scene } from "babylonjs/scene";
  45378. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45380. import { Mesh } from "babylonjs/Meshes/mesh";
  45381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45382. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45383. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45384. import "babylonjs/Meshes/Builders/planeBuilder";
  45385. import "babylonjs/Meshes/Builders/boxBuilder";
  45386. /**
  45387. * Represents the different options available during the creation of
  45388. * a Environment helper.
  45389. *
  45390. * This can control the default ground, skybox and image processing setup of your scene.
  45391. */
  45392. export interface IEnvironmentHelperOptions {
  45393. /**
  45394. * Specifies wether or not to create a ground.
  45395. * True by default.
  45396. */
  45397. createGround: boolean;
  45398. /**
  45399. * Specifies the ground size.
  45400. * 15 by default.
  45401. */
  45402. groundSize: number;
  45403. /**
  45404. * The texture used on the ground for the main color.
  45405. * Comes from the BabylonJS CDN by default.
  45406. *
  45407. * Remarks: Can be either a texture or a url.
  45408. */
  45409. groundTexture: string | BaseTexture;
  45410. /**
  45411. * The color mixed in the ground texture by default.
  45412. * BabylonJS clearColor by default.
  45413. */
  45414. groundColor: Color3;
  45415. /**
  45416. * Specifies the ground opacity.
  45417. * 1 by default.
  45418. */
  45419. groundOpacity: number;
  45420. /**
  45421. * Enables the ground to receive shadows.
  45422. * True by default.
  45423. */
  45424. enableGroundShadow: boolean;
  45425. /**
  45426. * Helps preventing the shadow to be fully black on the ground.
  45427. * 0.5 by default.
  45428. */
  45429. groundShadowLevel: number;
  45430. /**
  45431. * Creates a mirror texture attach to the ground.
  45432. * false by default.
  45433. */
  45434. enableGroundMirror: boolean;
  45435. /**
  45436. * Specifies the ground mirror size ratio.
  45437. * 0.3 by default as the default kernel is 64.
  45438. */
  45439. groundMirrorSizeRatio: number;
  45440. /**
  45441. * Specifies the ground mirror blur kernel size.
  45442. * 64 by default.
  45443. */
  45444. groundMirrorBlurKernel: number;
  45445. /**
  45446. * Specifies the ground mirror visibility amount.
  45447. * 1 by default
  45448. */
  45449. groundMirrorAmount: number;
  45450. /**
  45451. * Specifies the ground mirror reflectance weight.
  45452. * This uses the standard weight of the background material to setup the fresnel effect
  45453. * of the mirror.
  45454. * 1 by default.
  45455. */
  45456. groundMirrorFresnelWeight: number;
  45457. /**
  45458. * Specifies the ground mirror Falloff distance.
  45459. * This can helps reducing the size of the reflection.
  45460. * 0 by Default.
  45461. */
  45462. groundMirrorFallOffDistance: number;
  45463. /**
  45464. * Specifies the ground mirror texture type.
  45465. * Unsigned Int by Default.
  45466. */
  45467. groundMirrorTextureType: number;
  45468. /**
  45469. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45470. * the shown objects.
  45471. */
  45472. groundYBias: number;
  45473. /**
  45474. * Specifies wether or not to create a skybox.
  45475. * True by default.
  45476. */
  45477. createSkybox: boolean;
  45478. /**
  45479. * Specifies the skybox size.
  45480. * 20 by default.
  45481. */
  45482. skyboxSize: number;
  45483. /**
  45484. * The texture used on the skybox for the main color.
  45485. * Comes from the BabylonJS CDN by default.
  45486. *
  45487. * Remarks: Can be either a texture or a url.
  45488. */
  45489. skyboxTexture: string | BaseTexture;
  45490. /**
  45491. * The color mixed in the skybox texture by default.
  45492. * BabylonJS clearColor by default.
  45493. */
  45494. skyboxColor: Color3;
  45495. /**
  45496. * The background rotation around the Y axis of the scene.
  45497. * This helps aligning the key lights of your scene with the background.
  45498. * 0 by default.
  45499. */
  45500. backgroundYRotation: number;
  45501. /**
  45502. * Compute automatically the size of the elements to best fit with the scene.
  45503. */
  45504. sizeAuto: boolean;
  45505. /**
  45506. * Default position of the rootMesh if autoSize is not true.
  45507. */
  45508. rootPosition: Vector3;
  45509. /**
  45510. * Sets up the image processing in the scene.
  45511. * true by default.
  45512. */
  45513. setupImageProcessing: boolean;
  45514. /**
  45515. * The texture used as your environment texture in the scene.
  45516. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45517. *
  45518. * Remarks: Can be either a texture or a url.
  45519. */
  45520. environmentTexture: string | BaseTexture;
  45521. /**
  45522. * The value of the exposure to apply to the scene.
  45523. * 0.6 by default if setupImageProcessing is true.
  45524. */
  45525. cameraExposure: number;
  45526. /**
  45527. * The value of the contrast to apply to the scene.
  45528. * 1.6 by default if setupImageProcessing is true.
  45529. */
  45530. cameraContrast: number;
  45531. /**
  45532. * Specifies wether or not tonemapping should be enabled in the scene.
  45533. * true by default if setupImageProcessing is true.
  45534. */
  45535. toneMappingEnabled: boolean;
  45536. }
  45537. /**
  45538. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45539. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45540. * It also helps with the default setup of your imageProcessing configuration.
  45541. */
  45542. export class EnvironmentHelper {
  45543. /**
  45544. * Default ground texture URL.
  45545. */
  45546. private static _groundTextureCDNUrl;
  45547. /**
  45548. * Default skybox texture URL.
  45549. */
  45550. private static _skyboxTextureCDNUrl;
  45551. /**
  45552. * Default environment texture URL.
  45553. */
  45554. private static _environmentTextureCDNUrl;
  45555. /**
  45556. * Creates the default options for the helper.
  45557. */
  45558. private static _getDefaultOptions;
  45559. private _rootMesh;
  45560. /**
  45561. * Gets the root mesh created by the helper.
  45562. */
  45563. readonly rootMesh: Mesh;
  45564. private _skybox;
  45565. /**
  45566. * Gets the skybox created by the helper.
  45567. */
  45568. readonly skybox: Nullable<Mesh>;
  45569. private _skyboxTexture;
  45570. /**
  45571. * Gets the skybox texture created by the helper.
  45572. */
  45573. readonly skyboxTexture: Nullable<BaseTexture>;
  45574. private _skyboxMaterial;
  45575. /**
  45576. * Gets the skybox material created by the helper.
  45577. */
  45578. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45579. private _ground;
  45580. /**
  45581. * Gets the ground mesh created by the helper.
  45582. */
  45583. readonly ground: Nullable<Mesh>;
  45584. private _groundTexture;
  45585. /**
  45586. * Gets the ground texture created by the helper.
  45587. */
  45588. readonly groundTexture: Nullable<BaseTexture>;
  45589. private _groundMirror;
  45590. /**
  45591. * Gets the ground mirror created by the helper.
  45592. */
  45593. readonly groundMirror: Nullable<MirrorTexture>;
  45594. /**
  45595. * Gets the ground mirror render list to helps pushing the meshes
  45596. * you wish in the ground reflection.
  45597. */
  45598. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45599. private _groundMaterial;
  45600. /**
  45601. * Gets the ground material created by the helper.
  45602. */
  45603. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45604. /**
  45605. * Stores the creation options.
  45606. */
  45607. private readonly _scene;
  45608. private _options;
  45609. /**
  45610. * This observable will be notified with any error during the creation of the environment,
  45611. * mainly texture creation errors.
  45612. */
  45613. onErrorObservable: Observable<{
  45614. message?: string;
  45615. exception?: any;
  45616. }>;
  45617. /**
  45618. * constructor
  45619. * @param options Defines the options we want to customize the helper
  45620. * @param scene The scene to add the material to
  45621. */
  45622. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45623. /**
  45624. * Updates the background according to the new options
  45625. * @param options
  45626. */
  45627. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45628. /**
  45629. * Sets the primary color of all the available elements.
  45630. * @param color the main color to affect to the ground and the background
  45631. */
  45632. setMainColor(color: Color3): void;
  45633. /**
  45634. * Setup the image processing according to the specified options.
  45635. */
  45636. private _setupImageProcessing;
  45637. /**
  45638. * Setup the environment texture according to the specified options.
  45639. */
  45640. private _setupEnvironmentTexture;
  45641. /**
  45642. * Setup the background according to the specified options.
  45643. */
  45644. private _setupBackground;
  45645. /**
  45646. * Get the scene sizes according to the setup.
  45647. */
  45648. private _getSceneSize;
  45649. /**
  45650. * Setup the ground according to the specified options.
  45651. */
  45652. private _setupGround;
  45653. /**
  45654. * Setup the ground material according to the specified options.
  45655. */
  45656. private _setupGroundMaterial;
  45657. /**
  45658. * Setup the ground diffuse texture according to the specified options.
  45659. */
  45660. private _setupGroundDiffuseTexture;
  45661. /**
  45662. * Setup the ground mirror texture according to the specified options.
  45663. */
  45664. private _setupGroundMirrorTexture;
  45665. /**
  45666. * Setup the ground to receive the mirror texture.
  45667. */
  45668. private _setupMirrorInGroundMaterial;
  45669. /**
  45670. * Setup the skybox according to the specified options.
  45671. */
  45672. private _setupSkybox;
  45673. /**
  45674. * Setup the skybox material according to the specified options.
  45675. */
  45676. private _setupSkyboxMaterial;
  45677. /**
  45678. * Setup the skybox reflection texture according to the specified options.
  45679. */
  45680. private _setupSkyboxReflectionTexture;
  45681. private _errorHandler;
  45682. /**
  45683. * Dispose all the elements created by the Helper.
  45684. */
  45685. dispose(): void;
  45686. }
  45687. }
  45688. declare module "babylonjs/Helpers/photoDome" {
  45689. import { Observable } from "babylonjs/Misc/observable";
  45690. import { Nullable } from "babylonjs/types";
  45691. import { Scene } from "babylonjs/scene";
  45692. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45693. import { Mesh } from "babylonjs/Meshes/mesh";
  45694. import { Texture } from "babylonjs/Materials/Textures/texture";
  45695. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45696. import "babylonjs/Meshes/Builders/sphereBuilder";
  45697. /**
  45698. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45699. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45700. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45701. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45702. */
  45703. export class PhotoDome extends TransformNode {
  45704. private _useDirectMapping;
  45705. /**
  45706. * The texture being displayed on the sphere
  45707. */
  45708. protected _photoTexture: Texture;
  45709. /**
  45710. * Gets or sets the texture being displayed on the sphere
  45711. */
  45712. photoTexture: Texture;
  45713. /**
  45714. * Observable raised when an error occured while loading the 360 image
  45715. */
  45716. onLoadErrorObservable: Observable<string>;
  45717. /**
  45718. * The skybox material
  45719. */
  45720. protected _material: BackgroundMaterial;
  45721. /**
  45722. * The surface used for the skybox
  45723. */
  45724. protected _mesh: Mesh;
  45725. /**
  45726. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45727. * Also see the options.resolution property.
  45728. */
  45729. fovMultiplier: number;
  45730. /**
  45731. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45732. * @param name Element's name, child elements will append suffixes for their own names.
  45733. * @param urlsOfPhoto defines the url of the photo to display
  45734. * @param options defines an object containing optional or exposed sub element properties
  45735. * @param onError defines a callback called when an error occured while loading the texture
  45736. */
  45737. constructor(name: string, urlOfPhoto: string, options: {
  45738. resolution?: number;
  45739. size?: number;
  45740. useDirectMapping?: boolean;
  45741. faceForward?: boolean;
  45742. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45743. /**
  45744. * Releases resources associated with this node.
  45745. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45746. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45747. */
  45748. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45749. }
  45750. }
  45751. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45752. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45753. /** @hidden */
  45754. export var rgbdDecodePixelShader: {
  45755. name: string;
  45756. shader: string;
  45757. };
  45758. }
  45759. declare module "babylonjs/Misc/brdfTextureTools" {
  45760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45761. import { Scene } from "babylonjs/scene";
  45762. import "babylonjs/Shaders/rgbdDecode.fragment";
  45763. /**
  45764. * Class used to host texture specific utilities
  45765. */
  45766. export class BRDFTextureTools {
  45767. /**
  45768. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45769. * @param texture the texture to expand.
  45770. */
  45771. private static _ExpandDefaultBRDFTexture;
  45772. /**
  45773. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45774. * @param scene defines the hosting scene
  45775. * @returns the environment BRDF texture
  45776. */
  45777. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45778. private static _environmentBRDFBase64Texture;
  45779. }
  45780. }
  45781. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45782. import { Nullable } from "babylonjs/types";
  45783. import { IAnimatable } from "babylonjs/Misc/tools";
  45784. import { Color3 } from "babylonjs/Maths/math";
  45785. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45786. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45787. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45788. import { Engine } from "babylonjs/Engines/engine";
  45789. import { Scene } from "babylonjs/scene";
  45790. /**
  45791. * @hidden
  45792. */
  45793. export interface IMaterialClearCoatDefines {
  45794. CLEARCOAT: boolean;
  45795. CLEARCOAT_DEFAULTIOR: boolean;
  45796. CLEARCOAT_TEXTURE: boolean;
  45797. CLEARCOAT_TEXTUREDIRECTUV: number;
  45798. CLEARCOAT_BUMP: boolean;
  45799. CLEARCOAT_BUMPDIRECTUV: number;
  45800. CLEARCOAT_TINT: boolean;
  45801. CLEARCOAT_TINT_TEXTURE: boolean;
  45802. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45803. /** @hidden */
  45804. _areTexturesDirty: boolean;
  45805. }
  45806. /**
  45807. * Define the code related to the clear coat parameters of the pbr material.
  45808. */
  45809. export class PBRClearCoatConfiguration {
  45810. /**
  45811. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45812. * The default fits with a polyurethane material.
  45813. */
  45814. private static readonly _DefaultIndiceOfRefraction;
  45815. private _isEnabled;
  45816. /**
  45817. * Defines if the clear coat is enabled in the material.
  45818. */
  45819. isEnabled: boolean;
  45820. /**
  45821. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45822. */
  45823. intensity: number;
  45824. /**
  45825. * Defines the clear coat layer roughness.
  45826. */
  45827. roughness: number;
  45828. private _indiceOfRefraction;
  45829. /**
  45830. * Defines the indice of refraction of the clear coat.
  45831. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45832. * The default fits with a polyurethane material.
  45833. * Changing the default value is more performance intensive.
  45834. */
  45835. indiceOfRefraction: number;
  45836. private _texture;
  45837. /**
  45838. * Stores the clear coat values in a texture.
  45839. */
  45840. texture: Nullable<BaseTexture>;
  45841. private _bumpTexture;
  45842. /**
  45843. * Define the clear coat specific bump texture.
  45844. */
  45845. bumpTexture: Nullable<BaseTexture>;
  45846. private _isTintEnabled;
  45847. /**
  45848. * Defines if the clear coat tint is enabled in the material.
  45849. */
  45850. isTintEnabled: boolean;
  45851. /**
  45852. * Defines the clear coat tint of the material.
  45853. * This is only use if tint is enabled
  45854. */
  45855. tintColor: Color3;
  45856. /**
  45857. * Defines the distance at which the tint color should be found in the
  45858. * clear coat media.
  45859. * This is only use if tint is enabled
  45860. */
  45861. tintColorAtDistance: number;
  45862. /**
  45863. * Defines the clear coat layer thickness.
  45864. * This is only use if tint is enabled
  45865. */
  45866. tintThickness: number;
  45867. private _tintTexture;
  45868. /**
  45869. * Stores the clear tint values in a texture.
  45870. * rgb is tint
  45871. * a is a thickness factor
  45872. */
  45873. tintTexture: Nullable<BaseTexture>;
  45874. /** @hidden */
  45875. private _internalMarkAllSubMeshesAsTexturesDirty;
  45876. /** @hidden */
  45877. _markAllSubMeshesAsTexturesDirty(): void;
  45878. /**
  45879. * Instantiate a new istance of clear coat configuration.
  45880. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45881. */
  45882. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45883. /**
  45884. * Gets wehter the submesh is ready to be used or not.
  45885. * @param defines the list of "defines" to update.
  45886. * @param scene defines the scene the material belongs to.
  45887. * @param engine defines the engine the material belongs to.
  45888. * @param disableBumpMap defines wether the material disables bump or not.
  45889. * @returns - boolean indicating that the submesh is ready or not.
  45890. */
  45891. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45892. /**
  45893. * Checks to see if a texture is used in the material.
  45894. * @param defines the list of "defines" to update.
  45895. * @param scene defines the scene to the material belongs to.
  45896. */
  45897. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45898. /**
  45899. * Binds the material data.
  45900. * @param uniformBuffer defines the Uniform buffer to fill in.
  45901. * @param scene defines the scene the material belongs to.
  45902. * @param engine defines the engine the material belongs to.
  45903. * @param disableBumpMap defines wether the material disables bump or not.
  45904. * @param isFrozen defines wether the material is frozen or not.
  45905. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45906. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45907. */
  45908. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45909. /**
  45910. * Checks to see if a texture is used in the material.
  45911. * @param texture - Base texture to use.
  45912. * @returns - Boolean specifying if a texture is used in the material.
  45913. */
  45914. hasTexture(texture: BaseTexture): boolean;
  45915. /**
  45916. * Returns an array of the actively used textures.
  45917. * @param activeTextures Array of BaseTextures
  45918. */
  45919. getActiveTextures(activeTextures: BaseTexture[]): void;
  45920. /**
  45921. * Returns the animatable textures.
  45922. * @param animatables Array of animatable textures.
  45923. */
  45924. getAnimatables(animatables: IAnimatable[]): void;
  45925. /**
  45926. * Disposes the resources of the material.
  45927. * @param forceDisposeTextures - Forces the disposal of all textures.
  45928. */
  45929. dispose(forceDisposeTextures?: boolean): void;
  45930. /**
  45931. * Get the current class name of the texture useful for serialization or dynamic coding.
  45932. * @returns "PBRClearCoatConfiguration"
  45933. */
  45934. getClassName(): string;
  45935. /**
  45936. * Add fallbacks to the effect fallbacks list.
  45937. * @param defines defines the Base texture to use.
  45938. * @param fallbacks defines the current fallback list.
  45939. * @param currentRank defines the current fallback rank.
  45940. * @returns the new fallback rank.
  45941. */
  45942. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45943. /**
  45944. * Add the required uniforms to the current list.
  45945. * @param uniforms defines the current uniform list.
  45946. */
  45947. static AddUniforms(uniforms: string[]): void;
  45948. /**
  45949. * Add the required samplers to the current list.
  45950. * @param samplers defines the current sampler list.
  45951. */
  45952. static AddSamplers(samplers: string[]): void;
  45953. /**
  45954. * Add the required uniforms to the current buffer.
  45955. * @param uniformBuffer defines the current uniform buffer.
  45956. */
  45957. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45958. /**
  45959. * Makes a duplicate of the current configuration into another one.
  45960. * @param clearCoatConfiguration define the config where to copy the info
  45961. */
  45962. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45963. /**
  45964. * Serializes this clear coat configuration.
  45965. * @returns - An object with the serialized config.
  45966. */
  45967. serialize(): any;
  45968. /**
  45969. * Parses a Clear Coat Configuration from a serialized object.
  45970. * @param source - Serialized object.
  45971. */
  45972. parse(source: any): void;
  45973. }
  45974. }
  45975. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45976. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45977. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45979. import { Vector2 } from "babylonjs/Maths/math";
  45980. import { Scene } from "babylonjs/scene";
  45981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45982. import { IAnimatable } from "babylonjs/Misc/tools";
  45983. import { Nullable } from "babylonjs/types";
  45984. /**
  45985. * @hidden
  45986. */
  45987. export interface IMaterialAnisotropicDefines {
  45988. ANISOTROPIC: boolean;
  45989. ANISOTROPIC_TEXTURE: boolean;
  45990. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45991. MAINUV1: boolean;
  45992. _areTexturesDirty: boolean;
  45993. _needUVs: boolean;
  45994. }
  45995. /**
  45996. * Define the code related to the anisotropic parameters of the pbr material.
  45997. */
  45998. export class PBRAnisotropicConfiguration {
  45999. private _isEnabled;
  46000. /**
  46001. * Defines if the anisotropy is enabled in the material.
  46002. */
  46003. isEnabled: boolean;
  46004. /**
  46005. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46006. */
  46007. intensity: number;
  46008. /**
  46009. * Defines if the effect is along the tangents, bitangents or in between.
  46010. * By default, the effect is "strectching" the highlights along the tangents.
  46011. */
  46012. direction: Vector2;
  46013. private _texture;
  46014. /**
  46015. * Stores the anisotropy values in a texture.
  46016. * rg is direction (like normal from -1 to 1)
  46017. * b is a intensity
  46018. */
  46019. texture: Nullable<BaseTexture>;
  46020. /** @hidden */
  46021. private _internalMarkAllSubMeshesAsTexturesDirty;
  46022. /** @hidden */
  46023. _markAllSubMeshesAsTexturesDirty(): void;
  46024. /**
  46025. * Instantiate a new istance of anisotropy configuration.
  46026. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46027. */
  46028. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46029. /**
  46030. * Specifies that the submesh is ready to be used.
  46031. * @param defines the list of "defines" to update.
  46032. * @param scene defines the scene the material belongs to.
  46033. * @returns - boolean indicating that the submesh is ready or not.
  46034. */
  46035. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46036. /**
  46037. * Checks to see if a texture is used in the material.
  46038. * @param defines the list of "defines" to update.
  46039. * @param mesh the mesh we are preparing the defines for.
  46040. * @param scene defines the scene the material belongs to.
  46041. */
  46042. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46043. /**
  46044. * Binds the material data.
  46045. * @param uniformBuffer defines the Uniform buffer to fill in.
  46046. * @param scene defines the scene the material belongs to.
  46047. * @param isFrozen defines wether the material is frozen or not.
  46048. */
  46049. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46050. /**
  46051. * Checks to see if a texture is used in the material.
  46052. * @param texture - Base texture to use.
  46053. * @returns - Boolean specifying if a texture is used in the material.
  46054. */
  46055. hasTexture(texture: BaseTexture): boolean;
  46056. /**
  46057. * Returns an array of the actively used textures.
  46058. * @param activeTextures Array of BaseTextures
  46059. */
  46060. getActiveTextures(activeTextures: BaseTexture[]): void;
  46061. /**
  46062. * Returns the animatable textures.
  46063. * @param animatables Array of animatable textures.
  46064. */
  46065. getAnimatables(animatables: IAnimatable[]): void;
  46066. /**
  46067. * Disposes the resources of the material.
  46068. * @param forceDisposeTextures - Forces the disposal of all textures.
  46069. */
  46070. dispose(forceDisposeTextures?: boolean): void;
  46071. /**
  46072. * Get the current class name of the texture useful for serialization or dynamic coding.
  46073. * @returns "PBRAnisotropicConfiguration"
  46074. */
  46075. getClassName(): string;
  46076. /**
  46077. * Add fallbacks to the effect fallbacks list.
  46078. * @param defines defines the Base texture to use.
  46079. * @param fallbacks defines the current fallback list.
  46080. * @param currentRank defines the current fallback rank.
  46081. * @returns the new fallback rank.
  46082. */
  46083. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46084. /**
  46085. * Add the required uniforms to the current list.
  46086. * @param uniforms defines the current uniform list.
  46087. */
  46088. static AddUniforms(uniforms: string[]): void;
  46089. /**
  46090. * Add the required uniforms to the current buffer.
  46091. * @param uniformBuffer defines the current uniform buffer.
  46092. */
  46093. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46094. /**
  46095. * Add the required samplers to the current list.
  46096. * @param samplers defines the current sampler list.
  46097. */
  46098. static AddSamplers(samplers: string[]): void;
  46099. /**
  46100. * Makes a duplicate of the current configuration into another one.
  46101. * @param anisotropicConfiguration define the config where to copy the info
  46102. */
  46103. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46104. /**
  46105. * Serializes this anisotropy configuration.
  46106. * @returns - An object with the serialized config.
  46107. */
  46108. serialize(): any;
  46109. /**
  46110. * Parses a anisotropy Configuration from a serialized object.
  46111. * @param source - Serialized object.
  46112. */
  46113. parse(source: any): void;
  46114. }
  46115. }
  46116. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46117. /**
  46118. * @hidden
  46119. */
  46120. export interface IMaterialBRDFDefines {
  46121. BRDF_V_HEIGHT_CORRELATED: boolean;
  46122. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46123. SPHERICAL_HARMONICS: boolean;
  46124. /** @hidden */
  46125. _areMiscDirty: boolean;
  46126. }
  46127. /**
  46128. * Define the code related to the BRDF parameters of the pbr material.
  46129. */
  46130. export class PBRBRDFConfiguration {
  46131. /**
  46132. * Default value used for the energy conservation.
  46133. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46134. */
  46135. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46136. /**
  46137. * Default value used for the Smith Visibility Height Correlated mode.
  46138. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46139. */
  46140. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46141. /**
  46142. * Default value used for the IBL diffuse part.
  46143. * This can help switching back to the polynomials mode globally which is a tiny bit
  46144. * less GPU intensive at the drawback of a lower quality.
  46145. */
  46146. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46147. private _useEnergyConservation;
  46148. /**
  46149. * Defines if the material uses energy conservation.
  46150. */
  46151. useEnergyConservation: boolean;
  46152. private _useSmithVisibilityHeightCorrelated;
  46153. /**
  46154. * LEGACY Mode set to false
  46155. * Defines if the material uses height smith correlated visibility term.
  46156. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46157. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46158. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46159. * Not relying on height correlated will also disable energy conservation.
  46160. */
  46161. useSmithVisibilityHeightCorrelated: boolean;
  46162. private _useSphericalHarmonics;
  46163. /**
  46164. * LEGACY Mode set to false
  46165. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46166. * diffuse part of the IBL.
  46167. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46168. * to the ground truth.
  46169. */
  46170. useSphericalHarmonics: boolean;
  46171. /** @hidden */
  46172. private _internalMarkAllSubMeshesAsMiscDirty;
  46173. /** @hidden */
  46174. _markAllSubMeshesAsMiscDirty(): void;
  46175. /**
  46176. * Instantiate a new istance of clear coat configuration.
  46177. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46178. */
  46179. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46180. /**
  46181. * Checks to see if a texture is used in the material.
  46182. * @param defines the list of "defines" to update.
  46183. */
  46184. prepareDefines(defines: IMaterialBRDFDefines): void;
  46185. /**
  46186. * Get the current class name of the texture useful for serialization or dynamic coding.
  46187. * @returns "PBRClearCoatConfiguration"
  46188. */
  46189. getClassName(): string;
  46190. /**
  46191. * Makes a duplicate of the current configuration into another one.
  46192. * @param brdfConfiguration define the config where to copy the info
  46193. */
  46194. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46195. /**
  46196. * Serializes this BRDF configuration.
  46197. * @returns - An object with the serialized config.
  46198. */
  46199. serialize(): any;
  46200. /**
  46201. * Parses a BRDF Configuration from a serialized object.
  46202. * @param source - Serialized object.
  46203. */
  46204. parse(source: any): void;
  46205. }
  46206. }
  46207. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46208. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46209. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46210. import { Color3 } from "babylonjs/Maths/math";
  46211. import { Scene } from "babylonjs/scene";
  46212. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46213. import { IAnimatable } from "babylonjs/Misc/tools";
  46214. import { Nullable } from "babylonjs/types";
  46215. /**
  46216. * @hidden
  46217. */
  46218. export interface IMaterialSheenDefines {
  46219. SHEEN: boolean;
  46220. SHEEN_TEXTURE: boolean;
  46221. SHEEN_TEXTUREDIRECTUV: number;
  46222. SHEEN_LINKWITHALBEDO: boolean;
  46223. /** @hidden */
  46224. _areTexturesDirty: boolean;
  46225. }
  46226. /**
  46227. * Define the code related to the Sheen parameters of the pbr material.
  46228. */
  46229. export class PBRSheenConfiguration {
  46230. private _isEnabled;
  46231. /**
  46232. * Defines if the material uses sheen.
  46233. */
  46234. isEnabled: boolean;
  46235. private _linkSheenWithAlbedo;
  46236. /**
  46237. * Defines if the sheen is linked to the sheen color.
  46238. */
  46239. linkSheenWithAlbedo: boolean;
  46240. /**
  46241. * Defines the sheen intensity.
  46242. */
  46243. intensity: number;
  46244. /**
  46245. * Defines the sheen color.
  46246. */
  46247. color: Color3;
  46248. private _texture;
  46249. /**
  46250. * Stores the sheen tint values in a texture.
  46251. * rgb is tint
  46252. * a is a intensity
  46253. */
  46254. texture: Nullable<BaseTexture>;
  46255. /** @hidden */
  46256. private _internalMarkAllSubMeshesAsTexturesDirty;
  46257. /** @hidden */
  46258. _markAllSubMeshesAsTexturesDirty(): void;
  46259. /**
  46260. * Instantiate a new istance of clear coat configuration.
  46261. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46262. */
  46263. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46264. /**
  46265. * Specifies that the submesh is ready to be used.
  46266. * @param defines the list of "defines" to update.
  46267. * @param scene defines the scene the material belongs to.
  46268. * @returns - boolean indicating that the submesh is ready or not.
  46269. */
  46270. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46271. /**
  46272. * Checks to see if a texture is used in the material.
  46273. * @param defines the list of "defines" to update.
  46274. * @param scene defines the scene the material belongs to.
  46275. */
  46276. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46277. /**
  46278. * Binds the material data.
  46279. * @param uniformBuffer defines the Uniform buffer to fill in.
  46280. * @param scene defines the scene the material belongs to.
  46281. * @param isFrozen defines wether the material is frozen or not.
  46282. */
  46283. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46284. /**
  46285. * Checks to see if a texture is used in the material.
  46286. * @param texture - Base texture to use.
  46287. * @returns - Boolean specifying if a texture is used in the material.
  46288. */
  46289. hasTexture(texture: BaseTexture): boolean;
  46290. /**
  46291. * Returns an array of the actively used textures.
  46292. * @param activeTextures Array of BaseTextures
  46293. */
  46294. getActiveTextures(activeTextures: BaseTexture[]): void;
  46295. /**
  46296. * Returns the animatable textures.
  46297. * @param animatables Array of animatable textures.
  46298. */
  46299. getAnimatables(animatables: IAnimatable[]): void;
  46300. /**
  46301. * Disposes the resources of the material.
  46302. * @param forceDisposeTextures - Forces the disposal of all textures.
  46303. */
  46304. dispose(forceDisposeTextures?: boolean): void;
  46305. /**
  46306. * Get the current class name of the texture useful for serialization or dynamic coding.
  46307. * @returns "PBRSheenConfiguration"
  46308. */
  46309. getClassName(): string;
  46310. /**
  46311. * Add fallbacks to the effect fallbacks list.
  46312. * @param defines defines the Base texture to use.
  46313. * @param fallbacks defines the current fallback list.
  46314. * @param currentRank defines the current fallback rank.
  46315. * @returns the new fallback rank.
  46316. */
  46317. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46318. /**
  46319. * Add the required uniforms to the current list.
  46320. * @param uniforms defines the current uniform list.
  46321. */
  46322. static AddUniforms(uniforms: string[]): void;
  46323. /**
  46324. * Add the required uniforms to the current buffer.
  46325. * @param uniformBuffer defines the current uniform buffer.
  46326. */
  46327. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46328. /**
  46329. * Add the required samplers to the current list.
  46330. * @param samplers defines the current sampler list.
  46331. */
  46332. static AddSamplers(samplers: string[]): void;
  46333. /**
  46334. * Makes a duplicate of the current configuration into another one.
  46335. * @param sheenConfiguration define the config where to copy the info
  46336. */
  46337. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46338. /**
  46339. * Serializes this BRDF configuration.
  46340. * @returns - An object with the serialized config.
  46341. */
  46342. serialize(): any;
  46343. /**
  46344. * Parses a Sheen Configuration from a serialized object.
  46345. * @param source - Serialized object.
  46346. */
  46347. parse(source: any): void;
  46348. }
  46349. }
  46350. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46351. import { Nullable } from "babylonjs/types";
  46352. import { IAnimatable } from "babylonjs/Misc/tools";
  46353. import { Color3 } from "babylonjs/Maths/math";
  46354. import { SmartArray } from "babylonjs/Misc/smartArray";
  46355. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46356. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46357. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46358. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46359. import { Engine } from "babylonjs/Engines/engine";
  46360. import { Scene } from "babylonjs/scene";
  46361. /**
  46362. * @hidden
  46363. */
  46364. export interface IMaterialSubSurfaceDefines {
  46365. SUBSURFACE: boolean;
  46366. SS_REFRACTION: boolean;
  46367. SS_TRANSLUCENCY: boolean;
  46368. SS_SCATERRING: boolean;
  46369. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46370. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46371. SS_REFRACTIONMAP_3D: boolean;
  46372. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46373. SS_LODINREFRACTIONALPHA: boolean;
  46374. SS_GAMMAREFRACTION: boolean;
  46375. SS_RGBDREFRACTION: boolean;
  46376. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46377. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46378. /** @hidden */
  46379. _areTexturesDirty: boolean;
  46380. }
  46381. /**
  46382. * Define the code related to the sub surface parameters of the pbr material.
  46383. */
  46384. export class PBRSubSurfaceConfiguration {
  46385. private _isRefractionEnabled;
  46386. /**
  46387. * Defines if the refraction is enabled in the material.
  46388. */
  46389. isRefractionEnabled: boolean;
  46390. private _isTranslucencyEnabled;
  46391. /**
  46392. * Defines if the translucency is enabled in the material.
  46393. */
  46394. isTranslucencyEnabled: boolean;
  46395. private _isScatteringEnabled;
  46396. /**
  46397. * Defines the refraction intensity of the material.
  46398. * The refraction when enabled replaces the Diffuse part of the material.
  46399. * The intensity helps transitionning between diffuse and refraction.
  46400. */
  46401. refractionIntensity: number;
  46402. /**
  46403. * Defines the translucency intensity of the material.
  46404. * When translucency has been enabled, this defines how much of the "translucency"
  46405. * is addded to the diffuse part of the material.
  46406. */
  46407. translucencyIntensity: number;
  46408. /**
  46409. * Defines the scattering intensity of the material.
  46410. * When scattering has been enabled, this defines how much of the "scattered light"
  46411. * is addded to the diffuse part of the material.
  46412. */
  46413. scatteringIntensity: number;
  46414. private _thicknessTexture;
  46415. /**
  46416. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46417. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46418. * 0 would mean minimumThickness
  46419. * 1 would mean maximumThickness
  46420. * The other channels might be use as a mask to vary the different effects intensity.
  46421. */
  46422. thicknessTexture: Nullable<BaseTexture>;
  46423. private _refractionTexture;
  46424. /**
  46425. * Defines the texture to use for refraction.
  46426. */
  46427. refractionTexture: Nullable<BaseTexture>;
  46428. private _indexOfRefraction;
  46429. /**
  46430. * Defines the indice of refraction used in the material.
  46431. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46432. */
  46433. indexOfRefraction: number;
  46434. private _invertRefractionY;
  46435. /**
  46436. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46437. */
  46438. invertRefractionY: boolean;
  46439. private _linkRefractionWithTransparency;
  46440. /**
  46441. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46442. * Materials half opaque for instance using refraction could benefit from this control.
  46443. */
  46444. linkRefractionWithTransparency: boolean;
  46445. /**
  46446. * Defines the minimum thickness stored in the thickness map.
  46447. * If no thickness map is defined, this value will be used to simulate thickness.
  46448. */
  46449. minimumThickness: number;
  46450. /**
  46451. * Defines the maximum thickness stored in the thickness map.
  46452. */
  46453. maximumThickness: number;
  46454. /**
  46455. * Defines the volume tint of the material.
  46456. * This is used for both translucency and scattering.
  46457. */
  46458. tintColor: Color3;
  46459. /**
  46460. * Defines the distance at which the tint color should be found in the media.
  46461. * This is used for refraction only.
  46462. */
  46463. tintColorAtDistance: number;
  46464. /**
  46465. * Defines how far each channel transmit through the media.
  46466. * It is defined as a color to simplify it selection.
  46467. */
  46468. diffusionDistance: Color3;
  46469. private _useMaskFromThicknessTexture;
  46470. /**
  46471. * Stores the intensity of the different subsurface effects in the thickness texture.
  46472. * * the green channel is the translucency intensity.
  46473. * * the blue channel is the scattering intensity.
  46474. * * the alpha channel is the refraction intensity.
  46475. */
  46476. useMaskFromThicknessTexture: boolean;
  46477. /** @hidden */
  46478. private _internalMarkAllSubMeshesAsTexturesDirty;
  46479. /** @hidden */
  46480. _markAllSubMeshesAsTexturesDirty(): void;
  46481. /**
  46482. * Instantiate a new istance of sub surface configuration.
  46483. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46484. */
  46485. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46486. /**
  46487. * Gets wehter the submesh is ready to be used or not.
  46488. * @param defines the list of "defines" to update.
  46489. * @param scene defines the scene the material belongs to.
  46490. * @returns - boolean indicating that the submesh is ready or not.
  46491. */
  46492. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46493. /**
  46494. * Checks to see if a texture is used in the material.
  46495. * @param defines the list of "defines" to update.
  46496. * @param scene defines the scene to the material belongs to.
  46497. */
  46498. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46499. /**
  46500. * Binds the material data.
  46501. * @param uniformBuffer defines the Uniform buffer to fill in.
  46502. * @param scene defines the scene the material belongs to.
  46503. * @param engine defines the engine the material belongs to.
  46504. * @param isFrozen defines wether the material is frozen or not.
  46505. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46506. */
  46507. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46508. /**
  46509. * Unbinds the material from the mesh.
  46510. * @param activeEffect defines the effect that should be unbound from.
  46511. * @returns true if unbound, otherwise false
  46512. */
  46513. unbind(activeEffect: Effect): boolean;
  46514. /**
  46515. * Returns the texture used for refraction or null if none is used.
  46516. * @param scene defines the scene the material belongs to.
  46517. * @returns - Refraction texture if present. If no refraction texture and refraction
  46518. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46519. */
  46520. private _getRefractionTexture;
  46521. /**
  46522. * Returns true if alpha blending should be disabled.
  46523. */
  46524. readonly disableAlphaBlending: boolean;
  46525. /**
  46526. * Fills the list of render target textures.
  46527. * @param renderTargets the list of render targets to update
  46528. */
  46529. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46530. /**
  46531. * Checks to see if a texture is used in the material.
  46532. * @param texture - Base texture to use.
  46533. * @returns - Boolean specifying if a texture is used in the material.
  46534. */
  46535. hasTexture(texture: BaseTexture): boolean;
  46536. /**
  46537. * Gets a boolean indicating that current material needs to register RTT
  46538. * @returns true if this uses a render target otherwise false.
  46539. */
  46540. hasRenderTargetTextures(): boolean;
  46541. /**
  46542. * Returns an array of the actively used textures.
  46543. * @param activeTextures Array of BaseTextures
  46544. */
  46545. getActiveTextures(activeTextures: BaseTexture[]): void;
  46546. /**
  46547. * Returns the animatable textures.
  46548. * @param animatables Array of animatable textures.
  46549. */
  46550. getAnimatables(animatables: IAnimatable[]): void;
  46551. /**
  46552. * Disposes the resources of the material.
  46553. * @param forceDisposeTextures - Forces the disposal of all textures.
  46554. */
  46555. dispose(forceDisposeTextures?: boolean): void;
  46556. /**
  46557. * Get the current class name of the texture useful for serialization or dynamic coding.
  46558. * @returns "PBRSubSurfaceConfiguration"
  46559. */
  46560. getClassName(): string;
  46561. /**
  46562. * Add fallbacks to the effect fallbacks list.
  46563. * @param defines defines the Base texture to use.
  46564. * @param fallbacks defines the current fallback list.
  46565. * @param currentRank defines the current fallback rank.
  46566. * @returns the new fallback rank.
  46567. */
  46568. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46569. /**
  46570. * Add the required uniforms to the current list.
  46571. * @param uniforms defines the current uniform list.
  46572. */
  46573. static AddUniforms(uniforms: string[]): void;
  46574. /**
  46575. * Add the required samplers to the current list.
  46576. * @param samplers defines the current sampler list.
  46577. */
  46578. static AddSamplers(samplers: string[]): void;
  46579. /**
  46580. * Add the required uniforms to the current buffer.
  46581. * @param uniformBuffer defines the current uniform buffer.
  46582. */
  46583. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46584. /**
  46585. * Makes a duplicate of the current configuration into another one.
  46586. * @param configuration define the config where to copy the info
  46587. */
  46588. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46589. /**
  46590. * Serializes this Sub Surface configuration.
  46591. * @returns - An object with the serialized config.
  46592. */
  46593. serialize(): any;
  46594. /**
  46595. * Parses a Sub Surface Configuration from a serialized object.
  46596. * @param source - Serialized object.
  46597. */
  46598. parse(source: any): void;
  46599. }
  46600. }
  46601. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46602. /** @hidden */
  46603. export var pbrFragmentDeclaration: {
  46604. name: string;
  46605. shader: string;
  46606. };
  46607. }
  46608. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46609. /** @hidden */
  46610. export var pbrUboDeclaration: {
  46611. name: string;
  46612. shader: string;
  46613. };
  46614. }
  46615. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46616. /** @hidden */
  46617. export var pbrFragmentExtraDeclaration: {
  46618. name: string;
  46619. shader: string;
  46620. };
  46621. }
  46622. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46623. /** @hidden */
  46624. export var pbrFragmentSamplersDeclaration: {
  46625. name: string;
  46626. shader: string;
  46627. };
  46628. }
  46629. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46630. /** @hidden */
  46631. export var pbrHelperFunctions: {
  46632. name: string;
  46633. shader: string;
  46634. };
  46635. }
  46636. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46637. /** @hidden */
  46638. export var harmonicsFunctions: {
  46639. name: string;
  46640. shader: string;
  46641. };
  46642. }
  46643. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46644. /** @hidden */
  46645. export var pbrDirectLightingSetupFunctions: {
  46646. name: string;
  46647. shader: string;
  46648. };
  46649. }
  46650. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46651. /** @hidden */
  46652. export var pbrDirectLightingFalloffFunctions: {
  46653. name: string;
  46654. shader: string;
  46655. };
  46656. }
  46657. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46658. /** @hidden */
  46659. export var pbrBRDFFunctions: {
  46660. name: string;
  46661. shader: string;
  46662. };
  46663. }
  46664. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46665. /** @hidden */
  46666. export var pbrDirectLightingFunctions: {
  46667. name: string;
  46668. shader: string;
  46669. };
  46670. }
  46671. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46672. /** @hidden */
  46673. export var pbrIBLFunctions: {
  46674. name: string;
  46675. shader: string;
  46676. };
  46677. }
  46678. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46679. /** @hidden */
  46680. export var pbrDebug: {
  46681. name: string;
  46682. shader: string;
  46683. };
  46684. }
  46685. declare module "babylonjs/Shaders/pbr.fragment" {
  46686. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46687. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46688. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46689. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46690. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46691. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46692. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46693. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46694. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46695. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46696. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46697. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46698. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46699. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46700. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46701. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46702. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46703. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46704. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46705. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46706. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46707. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46708. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46709. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46710. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46711. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46712. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46713. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46714. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46715. /** @hidden */
  46716. export var pbrPixelShader: {
  46717. name: string;
  46718. shader: string;
  46719. };
  46720. }
  46721. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46722. /** @hidden */
  46723. export var pbrVertexDeclaration: {
  46724. name: string;
  46725. shader: string;
  46726. };
  46727. }
  46728. declare module "babylonjs/Shaders/pbr.vertex" {
  46729. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46730. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46731. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46732. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46733. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46734. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46735. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46736. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46737. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46738. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46739. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46740. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46741. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46742. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46743. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46744. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46745. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46746. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46747. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46748. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46749. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46750. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46751. /** @hidden */
  46752. export var pbrVertexShader: {
  46753. name: string;
  46754. shader: string;
  46755. };
  46756. }
  46757. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46758. import { IAnimatable } from "babylonjs/Misc/tools";
  46759. import { Nullable } from "babylonjs/types";
  46760. import { Scene } from "babylonjs/scene";
  46761. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46762. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46764. import { Mesh } from "babylonjs/Meshes/mesh";
  46765. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46766. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46767. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46768. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46769. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46770. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46771. import { Material } from "babylonjs/Materials/material";
  46772. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46773. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46774. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46775. import "babylonjs/Shaders/pbr.fragment";
  46776. import "babylonjs/Shaders/pbr.vertex";
  46777. /**
  46778. * Manages the defines for the PBR Material.
  46779. * @hidden
  46780. */
  46781. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46782. PBR: boolean;
  46783. MAINUV1: boolean;
  46784. MAINUV2: boolean;
  46785. UV1: boolean;
  46786. UV2: boolean;
  46787. ALBEDO: boolean;
  46788. ALBEDODIRECTUV: number;
  46789. VERTEXCOLOR: boolean;
  46790. AMBIENT: boolean;
  46791. AMBIENTDIRECTUV: number;
  46792. AMBIENTINGRAYSCALE: boolean;
  46793. OPACITY: boolean;
  46794. VERTEXALPHA: boolean;
  46795. OPACITYDIRECTUV: number;
  46796. OPACITYRGB: boolean;
  46797. ALPHATEST: boolean;
  46798. DEPTHPREPASS: boolean;
  46799. ALPHABLEND: boolean;
  46800. ALPHAFROMALBEDO: boolean;
  46801. ALPHATESTVALUE: string;
  46802. SPECULAROVERALPHA: boolean;
  46803. RADIANCEOVERALPHA: boolean;
  46804. ALPHAFRESNEL: boolean;
  46805. LINEARALPHAFRESNEL: boolean;
  46806. PREMULTIPLYALPHA: boolean;
  46807. EMISSIVE: boolean;
  46808. EMISSIVEDIRECTUV: number;
  46809. REFLECTIVITY: boolean;
  46810. REFLECTIVITYDIRECTUV: number;
  46811. SPECULARTERM: boolean;
  46812. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46813. MICROSURFACEAUTOMATIC: boolean;
  46814. LODBASEDMICROSFURACE: boolean;
  46815. MICROSURFACEMAP: boolean;
  46816. MICROSURFACEMAPDIRECTUV: number;
  46817. METALLICWORKFLOW: boolean;
  46818. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46819. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46820. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46821. AOSTOREINMETALMAPRED: boolean;
  46822. ENVIRONMENTBRDF: boolean;
  46823. ENVIRONMENTBRDF_RGBD: boolean;
  46824. NORMAL: boolean;
  46825. TANGENT: boolean;
  46826. BUMP: boolean;
  46827. BUMPDIRECTUV: number;
  46828. OBJECTSPACE_NORMALMAP: boolean;
  46829. PARALLAX: boolean;
  46830. PARALLAXOCCLUSION: boolean;
  46831. NORMALXYSCALE: boolean;
  46832. LIGHTMAP: boolean;
  46833. LIGHTMAPDIRECTUV: number;
  46834. USELIGHTMAPASSHADOWMAP: boolean;
  46835. GAMMALIGHTMAP: boolean;
  46836. REFLECTION: boolean;
  46837. REFLECTIONMAP_3D: boolean;
  46838. REFLECTIONMAP_SPHERICAL: boolean;
  46839. REFLECTIONMAP_PLANAR: boolean;
  46840. REFLECTIONMAP_CUBIC: boolean;
  46841. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46842. REFLECTIONMAP_PROJECTION: boolean;
  46843. REFLECTIONMAP_SKYBOX: boolean;
  46844. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46845. REFLECTIONMAP_EXPLICIT: boolean;
  46846. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46847. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46848. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46849. INVERTCUBICMAP: boolean;
  46850. USESPHERICALFROMREFLECTIONMAP: boolean;
  46851. SPHERICAL_HARMONICS: boolean;
  46852. USESPHERICALINVERTEX: boolean;
  46853. REFLECTIONMAP_OPPOSITEZ: boolean;
  46854. LODINREFLECTIONALPHA: boolean;
  46855. GAMMAREFLECTION: boolean;
  46856. RGBDREFLECTION: boolean;
  46857. RADIANCEOCCLUSION: boolean;
  46858. HORIZONOCCLUSION: boolean;
  46859. INSTANCES: boolean;
  46860. NUM_BONE_INFLUENCERS: number;
  46861. BonesPerMesh: number;
  46862. BONETEXTURE: boolean;
  46863. NONUNIFORMSCALING: boolean;
  46864. MORPHTARGETS: boolean;
  46865. MORPHTARGETS_NORMAL: boolean;
  46866. MORPHTARGETS_TANGENT: boolean;
  46867. NUM_MORPH_INFLUENCERS: number;
  46868. IMAGEPROCESSING: boolean;
  46869. VIGNETTE: boolean;
  46870. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46871. VIGNETTEBLENDMODEOPAQUE: boolean;
  46872. TONEMAPPING: boolean;
  46873. TONEMAPPING_ACES: boolean;
  46874. CONTRAST: boolean;
  46875. COLORCURVES: boolean;
  46876. COLORGRADING: boolean;
  46877. COLORGRADING3D: boolean;
  46878. SAMPLER3DGREENDEPTH: boolean;
  46879. SAMPLER3DBGRMAP: boolean;
  46880. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46881. EXPOSURE: boolean;
  46882. MULTIVIEW: boolean;
  46883. USEPHYSICALLIGHTFALLOFF: boolean;
  46884. USEGLTFLIGHTFALLOFF: boolean;
  46885. TWOSIDEDLIGHTING: boolean;
  46886. SHADOWFLOAT: boolean;
  46887. CLIPPLANE: boolean;
  46888. CLIPPLANE2: boolean;
  46889. CLIPPLANE3: boolean;
  46890. CLIPPLANE4: boolean;
  46891. POINTSIZE: boolean;
  46892. FOG: boolean;
  46893. LOGARITHMICDEPTH: boolean;
  46894. FORCENORMALFORWARD: boolean;
  46895. SPECULARAA: boolean;
  46896. CLEARCOAT: boolean;
  46897. CLEARCOAT_DEFAULTIOR: boolean;
  46898. CLEARCOAT_TEXTURE: boolean;
  46899. CLEARCOAT_TEXTUREDIRECTUV: number;
  46900. CLEARCOAT_BUMP: boolean;
  46901. CLEARCOAT_BUMPDIRECTUV: number;
  46902. CLEARCOAT_TINT: boolean;
  46903. CLEARCOAT_TINT_TEXTURE: boolean;
  46904. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46905. ANISOTROPIC: boolean;
  46906. ANISOTROPIC_TEXTURE: boolean;
  46907. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46908. BRDF_V_HEIGHT_CORRELATED: boolean;
  46909. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46910. SHEEN: boolean;
  46911. SHEEN_TEXTURE: boolean;
  46912. SHEEN_TEXTUREDIRECTUV: number;
  46913. SHEEN_LINKWITHALBEDO: boolean;
  46914. SUBSURFACE: boolean;
  46915. SS_REFRACTION: boolean;
  46916. SS_TRANSLUCENCY: boolean;
  46917. SS_SCATERRING: boolean;
  46918. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46919. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46920. SS_REFRACTIONMAP_3D: boolean;
  46921. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46922. SS_LODINREFRACTIONALPHA: boolean;
  46923. SS_GAMMAREFRACTION: boolean;
  46924. SS_RGBDREFRACTION: boolean;
  46925. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46926. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46927. UNLIT: boolean;
  46928. DEBUGMODE: number;
  46929. /**
  46930. * Initializes the PBR Material defines.
  46931. */
  46932. constructor();
  46933. /**
  46934. * Resets the PBR Material defines.
  46935. */
  46936. reset(): void;
  46937. }
  46938. /**
  46939. * The Physically based material base class of BJS.
  46940. *
  46941. * This offers the main features of a standard PBR material.
  46942. * For more information, please refer to the documentation :
  46943. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46944. */
  46945. export abstract class PBRBaseMaterial extends PushMaterial {
  46946. /**
  46947. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46948. */
  46949. static readonly PBRMATERIAL_OPAQUE: number;
  46950. /**
  46951. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46952. */
  46953. static readonly PBRMATERIAL_ALPHATEST: number;
  46954. /**
  46955. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46956. */
  46957. static readonly PBRMATERIAL_ALPHABLEND: number;
  46958. /**
  46959. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46960. * They are also discarded below the alpha cutoff threshold to improve performances.
  46961. */
  46962. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46963. /**
  46964. * Defines the default value of how much AO map is occluding the analytical lights
  46965. * (point spot...).
  46966. */
  46967. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46968. /**
  46969. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46970. */
  46971. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46972. /**
  46973. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46974. * to enhance interoperability with other engines.
  46975. */
  46976. static readonly LIGHTFALLOFF_GLTF: number;
  46977. /**
  46978. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46979. * to enhance interoperability with other materials.
  46980. */
  46981. static readonly LIGHTFALLOFF_STANDARD: number;
  46982. /**
  46983. * Intensity of the direct lights e.g. the four lights available in your scene.
  46984. * This impacts both the direct diffuse and specular highlights.
  46985. */
  46986. protected _directIntensity: number;
  46987. /**
  46988. * Intensity of the emissive part of the material.
  46989. * This helps controlling the emissive effect without modifying the emissive color.
  46990. */
  46991. protected _emissiveIntensity: number;
  46992. /**
  46993. * Intensity of the environment e.g. how much the environment will light the object
  46994. * either through harmonics for rough material or through the refelction for shiny ones.
  46995. */
  46996. protected _environmentIntensity: number;
  46997. /**
  46998. * This is a special control allowing the reduction of the specular highlights coming from the
  46999. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47000. */
  47001. protected _specularIntensity: number;
  47002. /**
  47003. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47004. */
  47005. private _lightingInfos;
  47006. /**
  47007. * Debug Control allowing disabling the bump map on this material.
  47008. */
  47009. protected _disableBumpMap: boolean;
  47010. /**
  47011. * AKA Diffuse Texture in standard nomenclature.
  47012. */
  47013. protected _albedoTexture: Nullable<BaseTexture>;
  47014. /**
  47015. * AKA Occlusion Texture in other nomenclature.
  47016. */
  47017. protected _ambientTexture: Nullable<BaseTexture>;
  47018. /**
  47019. * AKA Occlusion Texture Intensity in other nomenclature.
  47020. */
  47021. protected _ambientTextureStrength: number;
  47022. /**
  47023. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47024. * 1 means it completely occludes it
  47025. * 0 mean it has no impact
  47026. */
  47027. protected _ambientTextureImpactOnAnalyticalLights: number;
  47028. /**
  47029. * Stores the alpha values in a texture.
  47030. */
  47031. protected _opacityTexture: Nullable<BaseTexture>;
  47032. /**
  47033. * Stores the reflection values in a texture.
  47034. */
  47035. protected _reflectionTexture: Nullable<BaseTexture>;
  47036. /**
  47037. * Stores the emissive values in a texture.
  47038. */
  47039. protected _emissiveTexture: Nullable<BaseTexture>;
  47040. /**
  47041. * AKA Specular texture in other nomenclature.
  47042. */
  47043. protected _reflectivityTexture: Nullable<BaseTexture>;
  47044. /**
  47045. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47046. */
  47047. protected _metallicTexture: Nullable<BaseTexture>;
  47048. /**
  47049. * Specifies the metallic scalar of the metallic/roughness workflow.
  47050. * Can also be used to scale the metalness values of the metallic texture.
  47051. */
  47052. protected _metallic: Nullable<number>;
  47053. /**
  47054. * Specifies the roughness scalar of the metallic/roughness workflow.
  47055. * Can also be used to scale the roughness values of the metallic texture.
  47056. */
  47057. protected _roughness: Nullable<number>;
  47058. /**
  47059. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47060. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47061. */
  47062. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47063. /**
  47064. * Stores surface normal data used to displace a mesh in a texture.
  47065. */
  47066. protected _bumpTexture: Nullable<BaseTexture>;
  47067. /**
  47068. * Stores the pre-calculated light information of a mesh in a texture.
  47069. */
  47070. protected _lightmapTexture: Nullable<BaseTexture>;
  47071. /**
  47072. * The color of a material in ambient lighting.
  47073. */
  47074. protected _ambientColor: Color3;
  47075. /**
  47076. * AKA Diffuse Color in other nomenclature.
  47077. */
  47078. protected _albedoColor: Color3;
  47079. /**
  47080. * AKA Specular Color in other nomenclature.
  47081. */
  47082. protected _reflectivityColor: Color3;
  47083. /**
  47084. * The color applied when light is reflected from a material.
  47085. */
  47086. protected _reflectionColor: Color3;
  47087. /**
  47088. * The color applied when light is emitted from a material.
  47089. */
  47090. protected _emissiveColor: Color3;
  47091. /**
  47092. * AKA Glossiness in other nomenclature.
  47093. */
  47094. protected _microSurface: number;
  47095. /**
  47096. * Specifies that the material will use the light map as a show map.
  47097. */
  47098. protected _useLightmapAsShadowmap: boolean;
  47099. /**
  47100. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47101. * makes the reflect vector face the model (under horizon).
  47102. */
  47103. protected _useHorizonOcclusion: boolean;
  47104. /**
  47105. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47106. * too much the area relying on ambient texture to define their ambient occlusion.
  47107. */
  47108. protected _useRadianceOcclusion: boolean;
  47109. /**
  47110. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47111. */
  47112. protected _useAlphaFromAlbedoTexture: boolean;
  47113. /**
  47114. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47115. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47116. */
  47117. protected _useSpecularOverAlpha: boolean;
  47118. /**
  47119. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47120. */
  47121. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47122. /**
  47123. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47124. */
  47125. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47126. /**
  47127. * Specifies if the metallic texture contains the roughness information in its green channel.
  47128. */
  47129. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47130. /**
  47131. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47132. */
  47133. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47134. /**
  47135. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47136. */
  47137. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47138. /**
  47139. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47140. */
  47141. protected _useAmbientInGrayScale: boolean;
  47142. /**
  47143. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47144. * The material will try to infer what glossiness each pixel should be.
  47145. */
  47146. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47147. /**
  47148. * Defines the falloff type used in this material.
  47149. * It by default is Physical.
  47150. */
  47151. protected _lightFalloff: number;
  47152. /**
  47153. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47154. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47155. */
  47156. protected _useRadianceOverAlpha: boolean;
  47157. /**
  47158. * Allows using an object space normal map (instead of tangent space).
  47159. */
  47160. protected _useObjectSpaceNormalMap: boolean;
  47161. /**
  47162. * Allows using the bump map in parallax mode.
  47163. */
  47164. protected _useParallax: boolean;
  47165. /**
  47166. * Allows using the bump map in parallax occlusion mode.
  47167. */
  47168. protected _useParallaxOcclusion: boolean;
  47169. /**
  47170. * Controls the scale bias of the parallax mode.
  47171. */
  47172. protected _parallaxScaleBias: number;
  47173. /**
  47174. * If sets to true, disables all the lights affecting the material.
  47175. */
  47176. protected _disableLighting: boolean;
  47177. /**
  47178. * Number of Simultaneous lights allowed on the material.
  47179. */
  47180. protected _maxSimultaneousLights: number;
  47181. /**
  47182. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47183. */
  47184. protected _invertNormalMapX: boolean;
  47185. /**
  47186. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47187. */
  47188. protected _invertNormalMapY: boolean;
  47189. /**
  47190. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47191. */
  47192. protected _twoSidedLighting: boolean;
  47193. /**
  47194. * Defines the alpha limits in alpha test mode.
  47195. */
  47196. protected _alphaCutOff: number;
  47197. /**
  47198. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47199. */
  47200. protected _forceAlphaTest: boolean;
  47201. /**
  47202. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47203. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47204. */
  47205. protected _useAlphaFresnel: boolean;
  47206. /**
  47207. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47208. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47209. */
  47210. protected _useLinearAlphaFresnel: boolean;
  47211. /**
  47212. * The transparency mode of the material.
  47213. */
  47214. protected _transparencyMode: Nullable<number>;
  47215. /**
  47216. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47217. * from cos thetav and roughness:
  47218. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47219. */
  47220. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47221. /**
  47222. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47223. */
  47224. protected _forceIrradianceInFragment: boolean;
  47225. /**
  47226. * Force normal to face away from face.
  47227. */
  47228. protected _forceNormalForward: boolean;
  47229. /**
  47230. * Enables specular anti aliasing in the PBR shader.
  47231. * It will both interacts on the Geometry for analytical and IBL lighting.
  47232. * It also prefilter the roughness map based on the bump values.
  47233. */
  47234. protected _enableSpecularAntiAliasing: boolean;
  47235. /**
  47236. * Default configuration related to image processing available in the PBR Material.
  47237. */
  47238. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47239. /**
  47240. * Keep track of the image processing observer to allow dispose and replace.
  47241. */
  47242. private _imageProcessingObserver;
  47243. /**
  47244. * Attaches a new image processing configuration to the PBR Material.
  47245. * @param configuration
  47246. */
  47247. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47248. /**
  47249. * Stores the available render targets.
  47250. */
  47251. private _renderTargets;
  47252. /**
  47253. * Sets the global ambient color for the material used in lighting calculations.
  47254. */
  47255. private _globalAmbientColor;
  47256. /**
  47257. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47258. */
  47259. private _useLogarithmicDepth;
  47260. /**
  47261. * If set to true, no lighting calculations will be applied.
  47262. */
  47263. private _unlit;
  47264. private _debugMode;
  47265. /**
  47266. * @hidden
  47267. * This is reserved for the inspector.
  47268. * Defines the material debug mode.
  47269. * It helps seeing only some components of the material while troubleshooting.
  47270. */
  47271. debugMode: number;
  47272. /**
  47273. * @hidden
  47274. * This is reserved for the inspector.
  47275. * Specify from where on screen the debug mode should start.
  47276. * The value goes from -1 (full screen) to 1 (not visible)
  47277. * It helps with side by side comparison against the final render
  47278. * This defaults to -1
  47279. */
  47280. private debugLimit;
  47281. /**
  47282. * @hidden
  47283. * This is reserved for the inspector.
  47284. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47285. * You can use the factor to better multiply the final value.
  47286. */
  47287. private debugFactor;
  47288. /**
  47289. * Defines the clear coat layer parameters for the material.
  47290. */
  47291. readonly clearCoat: PBRClearCoatConfiguration;
  47292. /**
  47293. * Defines the anisotropic parameters for the material.
  47294. */
  47295. readonly anisotropy: PBRAnisotropicConfiguration;
  47296. /**
  47297. * Defines the BRDF parameters for the material.
  47298. */
  47299. readonly brdf: PBRBRDFConfiguration;
  47300. /**
  47301. * Defines the Sheen parameters for the material.
  47302. */
  47303. readonly sheen: PBRSheenConfiguration;
  47304. /**
  47305. * Defines the SubSurface parameters for the material.
  47306. */
  47307. readonly subSurface: PBRSubSurfaceConfiguration;
  47308. /**
  47309. * Custom callback helping to override the default shader used in the material.
  47310. */
  47311. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47312. /**
  47313. * Instantiates a new PBRMaterial instance.
  47314. *
  47315. * @param name The material name
  47316. * @param scene The scene the material will be use in.
  47317. */
  47318. constructor(name: string, scene: Scene);
  47319. /**
  47320. * Gets a boolean indicating that current material needs to register RTT
  47321. */
  47322. readonly hasRenderTargetTextures: boolean;
  47323. /**
  47324. * Gets the name of the material class.
  47325. */
  47326. getClassName(): string;
  47327. /**
  47328. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47329. */
  47330. /**
  47331. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47332. */
  47333. useLogarithmicDepth: boolean;
  47334. /**
  47335. * Gets the current transparency mode.
  47336. */
  47337. /**
  47338. * Sets the transparency mode of the material.
  47339. *
  47340. * | Value | Type | Description |
  47341. * | ----- | ----------------------------------- | ----------- |
  47342. * | 0 | OPAQUE | |
  47343. * | 1 | ALPHATEST | |
  47344. * | 2 | ALPHABLEND | |
  47345. * | 3 | ALPHATESTANDBLEND | |
  47346. *
  47347. */
  47348. transparencyMode: Nullable<number>;
  47349. /**
  47350. * Returns true if alpha blending should be disabled.
  47351. */
  47352. private readonly _disableAlphaBlending;
  47353. /**
  47354. * Specifies whether or not this material should be rendered in alpha blend mode.
  47355. */
  47356. needAlphaBlending(): boolean;
  47357. /**
  47358. * Specifies if the mesh will require alpha blending.
  47359. * @param mesh - BJS mesh.
  47360. */
  47361. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47362. /**
  47363. * Specifies whether or not this material should be rendered in alpha test mode.
  47364. */
  47365. needAlphaTesting(): boolean;
  47366. /**
  47367. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47368. */
  47369. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47370. /**
  47371. * Gets the texture used for the alpha test.
  47372. */
  47373. getAlphaTestTexture(): Nullable<BaseTexture>;
  47374. /**
  47375. * Specifies that the submesh is ready to be used.
  47376. * @param mesh - BJS mesh.
  47377. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47378. * @param useInstances - Specifies that instances should be used.
  47379. * @returns - boolean indicating that the submesh is ready or not.
  47380. */
  47381. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47382. /**
  47383. * Specifies if the material uses metallic roughness workflow.
  47384. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47385. */
  47386. isMetallicWorkflow(): boolean;
  47387. private _prepareEffect;
  47388. private _prepareDefines;
  47389. /**
  47390. * Force shader compilation
  47391. */
  47392. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47393. clipPlane: boolean;
  47394. }>): void;
  47395. /**
  47396. * Initializes the uniform buffer layout for the shader.
  47397. */
  47398. buildUniformLayout(): void;
  47399. /**
  47400. * Unbinds the material from the mesh
  47401. */
  47402. unbind(): void;
  47403. /**
  47404. * Binds the submesh data.
  47405. * @param world - The world matrix.
  47406. * @param mesh - The BJS mesh.
  47407. * @param subMesh - A submesh of the BJS mesh.
  47408. */
  47409. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47410. /**
  47411. * Returns the animatable textures.
  47412. * @returns - Array of animatable textures.
  47413. */
  47414. getAnimatables(): IAnimatable[];
  47415. /**
  47416. * Returns the texture used for reflections.
  47417. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47418. */
  47419. private _getReflectionTexture;
  47420. /**
  47421. * Returns an array of the actively used textures.
  47422. * @returns - Array of BaseTextures
  47423. */
  47424. getActiveTextures(): BaseTexture[];
  47425. /**
  47426. * Checks to see if a texture is used in the material.
  47427. * @param texture - Base texture to use.
  47428. * @returns - Boolean specifying if a texture is used in the material.
  47429. */
  47430. hasTexture(texture: BaseTexture): boolean;
  47431. /**
  47432. * Disposes the resources of the material.
  47433. * @param forceDisposeEffect - Forces the disposal of effects.
  47434. * @param forceDisposeTextures - Forces the disposal of all textures.
  47435. */
  47436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47437. }
  47438. }
  47439. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47440. import { Nullable } from "babylonjs/types";
  47441. import { Scene } from "babylonjs/scene";
  47442. import { Color3 } from "babylonjs/Maths/math";
  47443. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47444. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47446. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47447. /**
  47448. * The Physically based material of BJS.
  47449. *
  47450. * This offers the main features of a standard PBR material.
  47451. * For more information, please refer to the documentation :
  47452. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47453. */
  47454. export class PBRMaterial extends PBRBaseMaterial {
  47455. /**
  47456. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47457. */
  47458. static readonly PBRMATERIAL_OPAQUE: number;
  47459. /**
  47460. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47461. */
  47462. static readonly PBRMATERIAL_ALPHATEST: number;
  47463. /**
  47464. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47465. */
  47466. static readonly PBRMATERIAL_ALPHABLEND: number;
  47467. /**
  47468. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47469. * They are also discarded below the alpha cutoff threshold to improve performances.
  47470. */
  47471. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47472. /**
  47473. * Defines the default value of how much AO map is occluding the analytical lights
  47474. * (point spot...).
  47475. */
  47476. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47477. /**
  47478. * Intensity of the direct lights e.g. the four lights available in your scene.
  47479. * This impacts both the direct diffuse and specular highlights.
  47480. */
  47481. directIntensity: number;
  47482. /**
  47483. * Intensity of the emissive part of the material.
  47484. * This helps controlling the emissive effect without modifying the emissive color.
  47485. */
  47486. emissiveIntensity: number;
  47487. /**
  47488. * Intensity of the environment e.g. how much the environment will light the object
  47489. * either through harmonics for rough material or through the refelction for shiny ones.
  47490. */
  47491. environmentIntensity: number;
  47492. /**
  47493. * This is a special control allowing the reduction of the specular highlights coming from the
  47494. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47495. */
  47496. specularIntensity: number;
  47497. /**
  47498. * Debug Control allowing disabling the bump map on this material.
  47499. */
  47500. disableBumpMap: boolean;
  47501. /**
  47502. * AKA Diffuse Texture in standard nomenclature.
  47503. */
  47504. albedoTexture: BaseTexture;
  47505. /**
  47506. * AKA Occlusion Texture in other nomenclature.
  47507. */
  47508. ambientTexture: BaseTexture;
  47509. /**
  47510. * AKA Occlusion Texture Intensity in other nomenclature.
  47511. */
  47512. ambientTextureStrength: number;
  47513. /**
  47514. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47515. * 1 means it completely occludes it
  47516. * 0 mean it has no impact
  47517. */
  47518. ambientTextureImpactOnAnalyticalLights: number;
  47519. /**
  47520. * Stores the alpha values in a texture.
  47521. */
  47522. opacityTexture: BaseTexture;
  47523. /**
  47524. * Stores the reflection values in a texture.
  47525. */
  47526. reflectionTexture: Nullable<BaseTexture>;
  47527. /**
  47528. * Stores the emissive values in a texture.
  47529. */
  47530. emissiveTexture: BaseTexture;
  47531. /**
  47532. * AKA Specular texture in other nomenclature.
  47533. */
  47534. reflectivityTexture: BaseTexture;
  47535. /**
  47536. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47537. */
  47538. metallicTexture: BaseTexture;
  47539. /**
  47540. * Specifies the metallic scalar of the metallic/roughness workflow.
  47541. * Can also be used to scale the metalness values of the metallic texture.
  47542. */
  47543. metallic: Nullable<number>;
  47544. /**
  47545. * Specifies the roughness scalar of the metallic/roughness workflow.
  47546. * Can also be used to scale the roughness values of the metallic texture.
  47547. */
  47548. roughness: Nullable<number>;
  47549. /**
  47550. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47551. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47552. */
  47553. microSurfaceTexture: BaseTexture;
  47554. /**
  47555. * Stores surface normal data used to displace a mesh in a texture.
  47556. */
  47557. bumpTexture: BaseTexture;
  47558. /**
  47559. * Stores the pre-calculated light information of a mesh in a texture.
  47560. */
  47561. lightmapTexture: BaseTexture;
  47562. /**
  47563. * Stores the refracted light information in a texture.
  47564. */
  47565. refractionTexture: Nullable<BaseTexture>;
  47566. /**
  47567. * The color of a material in ambient lighting.
  47568. */
  47569. ambientColor: Color3;
  47570. /**
  47571. * AKA Diffuse Color in other nomenclature.
  47572. */
  47573. albedoColor: Color3;
  47574. /**
  47575. * AKA Specular Color in other nomenclature.
  47576. */
  47577. reflectivityColor: Color3;
  47578. /**
  47579. * The color reflected from the material.
  47580. */
  47581. reflectionColor: Color3;
  47582. /**
  47583. * The color emitted from the material.
  47584. */
  47585. emissiveColor: Color3;
  47586. /**
  47587. * AKA Glossiness in other nomenclature.
  47588. */
  47589. microSurface: number;
  47590. /**
  47591. * source material index of refraction (IOR)' / 'destination material IOR.
  47592. */
  47593. indexOfRefraction: number;
  47594. /**
  47595. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47596. */
  47597. invertRefractionY: boolean;
  47598. /**
  47599. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47600. * Materials half opaque for instance using refraction could benefit from this control.
  47601. */
  47602. linkRefractionWithTransparency: boolean;
  47603. /**
  47604. * If true, the light map contains occlusion information instead of lighting info.
  47605. */
  47606. useLightmapAsShadowmap: boolean;
  47607. /**
  47608. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47609. */
  47610. useAlphaFromAlbedoTexture: boolean;
  47611. /**
  47612. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47613. */
  47614. forceAlphaTest: boolean;
  47615. /**
  47616. * Defines the alpha limits in alpha test mode.
  47617. */
  47618. alphaCutOff: number;
  47619. /**
  47620. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47621. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47622. */
  47623. useSpecularOverAlpha: boolean;
  47624. /**
  47625. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47626. */
  47627. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47628. /**
  47629. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47630. */
  47631. useRoughnessFromMetallicTextureAlpha: boolean;
  47632. /**
  47633. * Specifies if the metallic texture contains the roughness information in its green channel.
  47634. */
  47635. useRoughnessFromMetallicTextureGreen: boolean;
  47636. /**
  47637. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47638. */
  47639. useMetallnessFromMetallicTextureBlue: boolean;
  47640. /**
  47641. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47642. */
  47643. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47644. /**
  47645. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47646. */
  47647. useAmbientInGrayScale: boolean;
  47648. /**
  47649. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47650. * The material will try to infer what glossiness each pixel should be.
  47651. */
  47652. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47653. /**
  47654. * BJS is using an harcoded light falloff based on a manually sets up range.
  47655. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47656. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47657. */
  47658. /**
  47659. * BJS is using an harcoded light falloff based on a manually sets up range.
  47660. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47661. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47662. */
  47663. usePhysicalLightFalloff: boolean;
  47664. /**
  47665. * In order to support the falloff compatibility with gltf, a special mode has been added
  47666. * to reproduce the gltf light falloff.
  47667. */
  47668. /**
  47669. * In order to support the falloff compatibility with gltf, a special mode has been added
  47670. * to reproduce the gltf light falloff.
  47671. */
  47672. useGLTFLightFalloff: boolean;
  47673. /**
  47674. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47675. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47676. */
  47677. useRadianceOverAlpha: boolean;
  47678. /**
  47679. * Allows using an object space normal map (instead of tangent space).
  47680. */
  47681. useObjectSpaceNormalMap: boolean;
  47682. /**
  47683. * Allows using the bump map in parallax mode.
  47684. */
  47685. useParallax: boolean;
  47686. /**
  47687. * Allows using the bump map in parallax occlusion mode.
  47688. */
  47689. useParallaxOcclusion: boolean;
  47690. /**
  47691. * Controls the scale bias of the parallax mode.
  47692. */
  47693. parallaxScaleBias: number;
  47694. /**
  47695. * If sets to true, disables all the lights affecting the material.
  47696. */
  47697. disableLighting: boolean;
  47698. /**
  47699. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47700. */
  47701. forceIrradianceInFragment: boolean;
  47702. /**
  47703. * Number of Simultaneous lights allowed on the material.
  47704. */
  47705. maxSimultaneousLights: number;
  47706. /**
  47707. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47708. */
  47709. invertNormalMapX: boolean;
  47710. /**
  47711. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47712. */
  47713. invertNormalMapY: boolean;
  47714. /**
  47715. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47716. */
  47717. twoSidedLighting: boolean;
  47718. /**
  47719. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47720. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47721. */
  47722. useAlphaFresnel: boolean;
  47723. /**
  47724. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47725. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47726. */
  47727. useLinearAlphaFresnel: boolean;
  47728. /**
  47729. * Let user defines the brdf lookup texture used for IBL.
  47730. * A default 8bit version is embedded but you could point at :
  47731. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47732. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47733. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47734. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47735. */
  47736. environmentBRDFTexture: Nullable<BaseTexture>;
  47737. /**
  47738. * Force normal to face away from face.
  47739. */
  47740. forceNormalForward: boolean;
  47741. /**
  47742. * Enables specular anti aliasing in the PBR shader.
  47743. * It will both interacts on the Geometry for analytical and IBL lighting.
  47744. * It also prefilter the roughness map based on the bump values.
  47745. */
  47746. enableSpecularAntiAliasing: boolean;
  47747. /**
  47748. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47749. * makes the reflect vector face the model (under horizon).
  47750. */
  47751. useHorizonOcclusion: boolean;
  47752. /**
  47753. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47754. * too much the area relying on ambient texture to define their ambient occlusion.
  47755. */
  47756. useRadianceOcclusion: boolean;
  47757. /**
  47758. * If set to true, no lighting calculations will be applied.
  47759. */
  47760. unlit: boolean;
  47761. /**
  47762. * Gets the image processing configuration used either in this material.
  47763. */
  47764. /**
  47765. * Sets the Default image processing configuration used either in the this material.
  47766. *
  47767. * If sets to null, the scene one is in use.
  47768. */
  47769. imageProcessingConfiguration: ImageProcessingConfiguration;
  47770. /**
  47771. * Gets wether the color curves effect is enabled.
  47772. */
  47773. /**
  47774. * Sets wether the color curves effect is enabled.
  47775. */
  47776. cameraColorCurvesEnabled: boolean;
  47777. /**
  47778. * Gets wether the color grading effect is enabled.
  47779. */
  47780. /**
  47781. * Gets wether the color grading effect is enabled.
  47782. */
  47783. cameraColorGradingEnabled: boolean;
  47784. /**
  47785. * Gets wether tonemapping is enabled or not.
  47786. */
  47787. /**
  47788. * Sets wether tonemapping is enabled or not
  47789. */
  47790. cameraToneMappingEnabled: boolean;
  47791. /**
  47792. * The camera exposure used on this material.
  47793. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47794. * This corresponds to a photographic exposure.
  47795. */
  47796. /**
  47797. * The camera exposure used on this material.
  47798. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47799. * This corresponds to a photographic exposure.
  47800. */
  47801. cameraExposure: number;
  47802. /**
  47803. * Gets The camera contrast used on this material.
  47804. */
  47805. /**
  47806. * Sets The camera contrast used on this material.
  47807. */
  47808. cameraContrast: number;
  47809. /**
  47810. * Gets the Color Grading 2D Lookup Texture.
  47811. */
  47812. /**
  47813. * Sets the Color Grading 2D Lookup Texture.
  47814. */
  47815. cameraColorGradingTexture: Nullable<BaseTexture>;
  47816. /**
  47817. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47818. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47819. * 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;
  47820. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47821. */
  47822. /**
  47823. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47824. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47825. * 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;
  47826. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47827. */
  47828. cameraColorCurves: Nullable<ColorCurves>;
  47829. /**
  47830. * Instantiates a new PBRMaterial instance.
  47831. *
  47832. * @param name The material name
  47833. * @param scene The scene the material will be use in.
  47834. */
  47835. constructor(name: string, scene: Scene);
  47836. /**
  47837. * Returns the name of this material class.
  47838. */
  47839. getClassName(): string;
  47840. /**
  47841. * Makes a duplicate of the current material.
  47842. * @param name - name to use for the new material.
  47843. */
  47844. clone(name: string): PBRMaterial;
  47845. /**
  47846. * Serializes this PBR Material.
  47847. * @returns - An object with the serialized material.
  47848. */
  47849. serialize(): any;
  47850. /**
  47851. * Parses a PBR Material from a serialized object.
  47852. * @param source - Serialized object.
  47853. * @param scene - BJS scene instance.
  47854. * @param rootUrl - url for the scene object
  47855. * @returns - PBRMaterial
  47856. */
  47857. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47858. }
  47859. }
  47860. declare module "babylonjs/Misc/dds" {
  47861. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47862. import { Engine } from "babylonjs/Engines/engine";
  47863. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47864. import { Nullable } from "babylonjs/types";
  47865. import { Scene } from "babylonjs/scene";
  47866. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47867. /**
  47868. * Direct draw surface info
  47869. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47870. */
  47871. export interface DDSInfo {
  47872. /**
  47873. * Width of the texture
  47874. */
  47875. width: number;
  47876. /**
  47877. * Width of the texture
  47878. */
  47879. height: number;
  47880. /**
  47881. * Number of Mipmaps for the texture
  47882. * @see https://en.wikipedia.org/wiki/Mipmap
  47883. */
  47884. mipmapCount: number;
  47885. /**
  47886. * If the textures format is a known fourCC format
  47887. * @see https://www.fourcc.org/
  47888. */
  47889. isFourCC: boolean;
  47890. /**
  47891. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47892. */
  47893. isRGB: boolean;
  47894. /**
  47895. * If the texture is a lumincance format
  47896. */
  47897. isLuminance: boolean;
  47898. /**
  47899. * If this is a cube texture
  47900. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47901. */
  47902. isCube: boolean;
  47903. /**
  47904. * If the texture is a compressed format eg. FOURCC_DXT1
  47905. */
  47906. isCompressed: boolean;
  47907. /**
  47908. * The dxgiFormat of the texture
  47909. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47910. */
  47911. dxgiFormat: number;
  47912. /**
  47913. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47914. */
  47915. textureType: number;
  47916. /**
  47917. * Sphericle polynomial created for the dds texture
  47918. */
  47919. sphericalPolynomial?: SphericalPolynomial;
  47920. }
  47921. /**
  47922. * Class used to provide DDS decompression tools
  47923. */
  47924. export class DDSTools {
  47925. /**
  47926. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47927. */
  47928. static StoreLODInAlphaChannel: boolean;
  47929. /**
  47930. * Gets DDS information from an array buffer
  47931. * @param arrayBuffer defines the array buffer to read data from
  47932. * @returns the DDS information
  47933. */
  47934. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47935. private static _FloatView;
  47936. private static _Int32View;
  47937. private static _ToHalfFloat;
  47938. private static _FromHalfFloat;
  47939. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47940. private static _GetHalfFloatRGBAArrayBuffer;
  47941. private static _GetFloatRGBAArrayBuffer;
  47942. private static _GetFloatAsUIntRGBAArrayBuffer;
  47943. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47944. private static _GetRGBAArrayBuffer;
  47945. private static _ExtractLongWordOrder;
  47946. private static _GetRGBArrayBuffer;
  47947. private static _GetLuminanceArrayBuffer;
  47948. /**
  47949. * Uploads DDS Levels to a Babylon Texture
  47950. * @hidden
  47951. */
  47952. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47953. }
  47954. module "babylonjs/Engines/engine" {
  47955. interface Engine {
  47956. /**
  47957. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47958. * @param rootUrl defines the url where the file to load is located
  47959. * @param scene defines the current scene
  47960. * @param lodScale defines scale to apply to the mip map selection
  47961. * @param lodOffset defines offset to apply to the mip map selection
  47962. * @param onLoad defines an optional callback raised when the texture is loaded
  47963. * @param onError defines an optional callback raised if there is an issue to load the texture
  47964. * @param format defines the format of the data
  47965. * @param forcedExtension defines the extension to use to pick the right loader
  47966. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47967. * @returns the cube texture as an InternalTexture
  47968. */
  47969. 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;
  47970. }
  47971. }
  47972. }
  47973. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47974. import { Nullable } from "babylonjs/types";
  47975. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47976. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47977. /**
  47978. * Implementation of the DDS Texture Loader.
  47979. * @hidden
  47980. */
  47981. export class _DDSTextureLoader implements IInternalTextureLoader {
  47982. /**
  47983. * Defines wether the loader supports cascade loading the different faces.
  47984. */
  47985. readonly supportCascades: boolean;
  47986. /**
  47987. * This returns if the loader support the current file information.
  47988. * @param extension defines the file extension of the file being loaded
  47989. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47990. * @param fallback defines the fallback internal texture if any
  47991. * @param isBase64 defines whether the texture is encoded as a base64
  47992. * @param isBuffer defines whether the texture data are stored as a buffer
  47993. * @returns true if the loader can load the specified file
  47994. */
  47995. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47996. /**
  47997. * Transform the url before loading if required.
  47998. * @param rootUrl the url of the texture
  47999. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48000. * @returns the transformed texture
  48001. */
  48002. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48003. /**
  48004. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48005. * @param rootUrl the url of the texture
  48006. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48007. * @returns the fallback texture
  48008. */
  48009. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48010. /**
  48011. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48012. * @param data contains the texture data
  48013. * @param texture defines the BabylonJS internal texture
  48014. * @param createPolynomials will be true if polynomials have been requested
  48015. * @param onLoad defines the callback to trigger once the texture is ready
  48016. * @param onError defines the callback to trigger in case of error
  48017. */
  48018. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48019. /**
  48020. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48021. * @param data contains the texture data
  48022. * @param texture defines the BabylonJS internal texture
  48023. * @param callback defines the method to call once ready to upload
  48024. */
  48025. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48026. }
  48027. }
  48028. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48029. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48030. /** @hidden */
  48031. export var rgbdEncodePixelShader: {
  48032. name: string;
  48033. shader: string;
  48034. };
  48035. }
  48036. declare module "babylonjs/Misc/environmentTextureTools" {
  48037. import { Nullable } from "babylonjs/types";
  48038. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48039. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48040. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48041. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48042. import "babylonjs/Shaders/rgbdEncode.fragment";
  48043. import "babylonjs/Shaders/rgbdDecode.fragment";
  48044. /**
  48045. * Raw texture data and descriptor sufficient for WebGL texture upload
  48046. */
  48047. export interface EnvironmentTextureInfo {
  48048. /**
  48049. * Version of the environment map
  48050. */
  48051. version: number;
  48052. /**
  48053. * Width of image
  48054. */
  48055. width: number;
  48056. /**
  48057. * Irradiance information stored in the file.
  48058. */
  48059. irradiance: any;
  48060. /**
  48061. * Specular information stored in the file.
  48062. */
  48063. specular: any;
  48064. }
  48065. /**
  48066. * Sets of helpers addressing the serialization and deserialization of environment texture
  48067. * stored in a BabylonJS env file.
  48068. * Those files are usually stored as .env files.
  48069. */
  48070. export class EnvironmentTextureTools {
  48071. /**
  48072. * Magic number identifying the env file.
  48073. */
  48074. private static _MagicBytes;
  48075. /**
  48076. * Gets the environment info from an env file.
  48077. * @param data The array buffer containing the .env bytes.
  48078. * @returns the environment file info (the json header) if successfully parsed.
  48079. */
  48080. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48081. /**
  48082. * Creates an environment texture from a loaded cube texture.
  48083. * @param texture defines the cube texture to convert in env file
  48084. * @return a promise containing the environment data if succesfull.
  48085. */
  48086. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48087. /**
  48088. * Creates a JSON representation of the spherical data.
  48089. * @param texture defines the texture containing the polynomials
  48090. * @return the JSON representation of the spherical info
  48091. */
  48092. private static _CreateEnvTextureIrradiance;
  48093. /**
  48094. * Uploads the texture info contained in the env file to the GPU.
  48095. * @param texture defines the internal texture to upload to
  48096. * @param arrayBuffer defines the buffer cotaining the data to load
  48097. * @param info defines the texture info retrieved through the GetEnvInfo method
  48098. * @returns a promise
  48099. */
  48100. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48101. /**
  48102. * Uploads the levels of image data to the GPU.
  48103. * @param texture defines the internal texture to upload to
  48104. * @param imageData defines the array buffer views of image data [mipmap][face]
  48105. * @returns a promise
  48106. */
  48107. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48108. /**
  48109. * Uploads spherical polynomials information to the texture.
  48110. * @param texture defines the texture we are trying to upload the information to
  48111. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48112. */
  48113. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48114. /** @hidden */
  48115. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48116. }
  48117. }
  48118. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48119. import { Nullable } from "babylonjs/types";
  48120. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48121. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48122. /**
  48123. * Implementation of the ENV Texture Loader.
  48124. * @hidden
  48125. */
  48126. export class _ENVTextureLoader implements IInternalTextureLoader {
  48127. /**
  48128. * Defines wether the loader supports cascade loading the different faces.
  48129. */
  48130. readonly supportCascades: boolean;
  48131. /**
  48132. * This returns if the loader support the current file information.
  48133. * @param extension defines the file extension of the file being loaded
  48134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48135. * @param fallback defines the fallback internal texture if any
  48136. * @param isBase64 defines whether the texture is encoded as a base64
  48137. * @param isBuffer defines whether the texture data are stored as a buffer
  48138. * @returns true if the loader can load the specified file
  48139. */
  48140. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48141. /**
  48142. * Transform the url before loading if required.
  48143. * @param rootUrl the url of the texture
  48144. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48145. * @returns the transformed texture
  48146. */
  48147. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48148. /**
  48149. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48150. * @param rootUrl the url of the texture
  48151. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48152. * @returns the fallback texture
  48153. */
  48154. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48155. /**
  48156. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48157. * @param data contains the texture data
  48158. * @param texture defines the BabylonJS internal texture
  48159. * @param createPolynomials will be true if polynomials have been requested
  48160. * @param onLoad defines the callback to trigger once the texture is ready
  48161. * @param onError defines the callback to trigger in case of error
  48162. */
  48163. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48164. /**
  48165. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48166. * @param data contains the texture data
  48167. * @param texture defines the BabylonJS internal texture
  48168. * @param callback defines the method to call once ready to upload
  48169. */
  48170. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48171. }
  48172. }
  48173. declare module "babylonjs/Misc/khronosTextureContainer" {
  48174. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48175. /**
  48176. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48177. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48178. */
  48179. export class KhronosTextureContainer {
  48180. /** contents of the KTX container file */
  48181. arrayBuffer: any;
  48182. private static HEADER_LEN;
  48183. private static COMPRESSED_2D;
  48184. private static COMPRESSED_3D;
  48185. private static TEX_2D;
  48186. private static TEX_3D;
  48187. /**
  48188. * Gets the openGL type
  48189. */
  48190. glType: number;
  48191. /**
  48192. * Gets the openGL type size
  48193. */
  48194. glTypeSize: number;
  48195. /**
  48196. * Gets the openGL format
  48197. */
  48198. glFormat: number;
  48199. /**
  48200. * Gets the openGL internal format
  48201. */
  48202. glInternalFormat: number;
  48203. /**
  48204. * Gets the base internal format
  48205. */
  48206. glBaseInternalFormat: number;
  48207. /**
  48208. * Gets image width in pixel
  48209. */
  48210. pixelWidth: number;
  48211. /**
  48212. * Gets image height in pixel
  48213. */
  48214. pixelHeight: number;
  48215. /**
  48216. * Gets image depth in pixels
  48217. */
  48218. pixelDepth: number;
  48219. /**
  48220. * Gets the number of array elements
  48221. */
  48222. numberOfArrayElements: number;
  48223. /**
  48224. * Gets the number of faces
  48225. */
  48226. numberOfFaces: number;
  48227. /**
  48228. * Gets the number of mipmap levels
  48229. */
  48230. numberOfMipmapLevels: number;
  48231. /**
  48232. * Gets the bytes of key value data
  48233. */
  48234. bytesOfKeyValueData: number;
  48235. /**
  48236. * Gets the load type
  48237. */
  48238. loadType: number;
  48239. /**
  48240. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48241. */
  48242. isInvalid: boolean;
  48243. /**
  48244. * Creates a new KhronosTextureContainer
  48245. * @param arrayBuffer contents of the KTX container file
  48246. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48247. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48248. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48249. */
  48250. constructor(
  48251. /** contents of the KTX container file */
  48252. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48253. /**
  48254. * Uploads KTX content to a Babylon Texture.
  48255. * It is assumed that the texture has already been created & is currently bound
  48256. * @hidden
  48257. */
  48258. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48259. private _upload2DCompressedLevels;
  48260. }
  48261. }
  48262. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48263. import { Nullable } from "babylonjs/types";
  48264. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48265. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48266. /**
  48267. * Implementation of the KTX Texture Loader.
  48268. * @hidden
  48269. */
  48270. export class _KTXTextureLoader implements IInternalTextureLoader {
  48271. /**
  48272. * Defines wether the loader supports cascade loading the different faces.
  48273. */
  48274. readonly supportCascades: boolean;
  48275. /**
  48276. * This returns if the loader support the current file information.
  48277. * @param extension defines the file extension of the file being loaded
  48278. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48279. * @param fallback defines the fallback internal texture if any
  48280. * @param isBase64 defines whether the texture is encoded as a base64
  48281. * @param isBuffer defines whether the texture data are stored as a buffer
  48282. * @returns true if the loader can load the specified file
  48283. */
  48284. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48285. /**
  48286. * Transform the url before loading if required.
  48287. * @param rootUrl the url of the texture
  48288. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48289. * @returns the transformed texture
  48290. */
  48291. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48292. /**
  48293. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48294. * @param rootUrl the url of the texture
  48295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48296. * @returns the fallback texture
  48297. */
  48298. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48299. /**
  48300. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48301. * @param data contains the texture data
  48302. * @param texture defines the BabylonJS internal texture
  48303. * @param createPolynomials will be true if polynomials have been requested
  48304. * @param onLoad defines the callback to trigger once the texture is ready
  48305. * @param onError defines the callback to trigger in case of error
  48306. */
  48307. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48308. /**
  48309. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48310. * @param data contains the texture data
  48311. * @param texture defines the BabylonJS internal texture
  48312. * @param callback defines the method to call once ready to upload
  48313. */
  48314. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48315. }
  48316. }
  48317. declare module "babylonjs/Helpers/sceneHelpers" {
  48318. import { Nullable } from "babylonjs/types";
  48319. import { Mesh } from "babylonjs/Meshes/mesh";
  48320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48321. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48322. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48323. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48324. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48325. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48326. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48327. import "babylonjs/Meshes/Builders/boxBuilder";
  48328. /** @hidden */
  48329. export var _forceSceneHelpersToBundle: boolean;
  48330. module "babylonjs/scene" {
  48331. interface Scene {
  48332. /**
  48333. * Creates a default light for the scene.
  48334. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48335. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48336. */
  48337. createDefaultLight(replace?: boolean): void;
  48338. /**
  48339. * Creates a default camera for the scene.
  48340. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48341. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48342. * @param replace has default false, when true replaces the active camera in the scene
  48343. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48344. */
  48345. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48346. /**
  48347. * Creates a default camera and a default light.
  48348. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48349. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48350. * @param replace has the default false, when true replaces the active camera/light in the scene
  48351. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48352. */
  48353. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48354. /**
  48355. * Creates a new sky box
  48356. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48357. * @param environmentTexture defines the texture to use as environment texture
  48358. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48359. * @param scale defines the overall scale of the skybox
  48360. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48361. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48362. * @returns a new mesh holding the sky box
  48363. */
  48364. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48365. /**
  48366. * Creates a new environment
  48367. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48368. * @param options defines the options you can use to configure the environment
  48369. * @returns the new EnvironmentHelper
  48370. */
  48371. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48372. /**
  48373. * Creates a new VREXperienceHelper
  48374. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48375. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48376. * @returns a new VREXperienceHelper
  48377. */
  48378. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48379. /**
  48380. * Creates a new XREXperienceHelper
  48381. * @see http://doc.babylonjs.com/how_to/webxr
  48382. * @returns a promise for a new XREXperienceHelper
  48383. */
  48384. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48385. }
  48386. }
  48387. }
  48388. declare module "babylonjs/Helpers/videoDome" {
  48389. import { Scene } from "babylonjs/scene";
  48390. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48391. import { Mesh } from "babylonjs/Meshes/mesh";
  48392. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48393. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48394. import "babylonjs/Meshes/Builders/sphereBuilder";
  48395. /**
  48396. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48397. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48398. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48399. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48400. */
  48401. export class VideoDome extends TransformNode {
  48402. /**
  48403. * Define the video source as a Monoscopic panoramic 360 video.
  48404. */
  48405. static readonly MODE_MONOSCOPIC: number;
  48406. /**
  48407. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48408. */
  48409. static readonly MODE_TOPBOTTOM: number;
  48410. /**
  48411. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48412. */
  48413. static readonly MODE_SIDEBYSIDE: number;
  48414. private _useDirectMapping;
  48415. /**
  48416. * The video texture being displayed on the sphere
  48417. */
  48418. protected _videoTexture: VideoTexture;
  48419. /**
  48420. * Gets the video texture being displayed on the sphere
  48421. */
  48422. readonly videoTexture: VideoTexture;
  48423. /**
  48424. * The skybox material
  48425. */
  48426. protected _material: BackgroundMaterial;
  48427. /**
  48428. * The surface used for the skybox
  48429. */
  48430. protected _mesh: Mesh;
  48431. /**
  48432. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48433. * Also see the options.resolution property.
  48434. */
  48435. fovMultiplier: number;
  48436. private _videoMode;
  48437. /**
  48438. * Gets or set the current video mode for the video. It can be:
  48439. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48440. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48441. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48442. */
  48443. videoMode: number;
  48444. /**
  48445. * Oberserver used in Stereoscopic VR Mode.
  48446. */
  48447. private _onBeforeCameraRenderObserver;
  48448. /**
  48449. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48450. * @param name Element's name, child elements will append suffixes for their own names.
  48451. * @param urlsOrVideo defines the url(s) or the video element to use
  48452. * @param options An object containing optional or exposed sub element properties
  48453. */
  48454. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48455. resolution?: number;
  48456. clickToPlay?: boolean;
  48457. autoPlay?: boolean;
  48458. loop?: boolean;
  48459. size?: number;
  48460. poster?: string;
  48461. faceForward?: boolean;
  48462. useDirectMapping?: boolean;
  48463. }, scene: Scene);
  48464. private _changeVideoMode;
  48465. /**
  48466. * Releases resources associated with this node.
  48467. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48468. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48469. */
  48470. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48471. }
  48472. }
  48473. declare module "babylonjs/Helpers/index" {
  48474. export * from "babylonjs/Helpers/environmentHelper";
  48475. export * from "babylonjs/Helpers/photoDome";
  48476. export * from "babylonjs/Helpers/sceneHelpers";
  48477. export * from "babylonjs/Helpers/videoDome";
  48478. }
  48479. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48480. import { PerfCounter } from "babylonjs/Misc/tools";
  48481. import { IDisposable } from "babylonjs/scene";
  48482. import { Engine } from "babylonjs/Engines/engine";
  48483. /**
  48484. * This class can be used to get instrumentation data from a Babylon engine
  48485. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48486. */
  48487. export class EngineInstrumentation implements IDisposable {
  48488. /**
  48489. * Define the instrumented engine.
  48490. */
  48491. engine: Engine;
  48492. private _captureGPUFrameTime;
  48493. private _gpuFrameTimeToken;
  48494. private _gpuFrameTime;
  48495. private _captureShaderCompilationTime;
  48496. private _shaderCompilationTime;
  48497. private _onBeginFrameObserver;
  48498. private _onEndFrameObserver;
  48499. private _onBeforeShaderCompilationObserver;
  48500. private _onAfterShaderCompilationObserver;
  48501. /**
  48502. * Gets the perf counter used for GPU frame time
  48503. */
  48504. readonly gpuFrameTimeCounter: PerfCounter;
  48505. /**
  48506. * Gets the GPU frame time capture status
  48507. */
  48508. /**
  48509. * Enable or disable the GPU frame time capture
  48510. */
  48511. captureGPUFrameTime: boolean;
  48512. /**
  48513. * Gets the perf counter used for shader compilation time
  48514. */
  48515. readonly shaderCompilationTimeCounter: PerfCounter;
  48516. /**
  48517. * Gets the shader compilation time capture status
  48518. */
  48519. /**
  48520. * Enable or disable the shader compilation time capture
  48521. */
  48522. captureShaderCompilationTime: boolean;
  48523. /**
  48524. * Instantiates a new engine instrumentation.
  48525. * This class can be used to get instrumentation data from a Babylon engine
  48526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48527. * @param engine Defines the engine to instrument
  48528. */
  48529. constructor(
  48530. /**
  48531. * Define the instrumented engine.
  48532. */
  48533. engine: Engine);
  48534. /**
  48535. * Dispose and release associated resources.
  48536. */
  48537. dispose(): void;
  48538. }
  48539. }
  48540. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48541. import { PerfCounter } from "babylonjs/Misc/tools";
  48542. import { Scene, IDisposable } from "babylonjs/scene";
  48543. /**
  48544. * This class can be used to get instrumentation data from a Babylon engine
  48545. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48546. */
  48547. export class SceneInstrumentation implements IDisposable {
  48548. /**
  48549. * Defines the scene to instrument
  48550. */
  48551. scene: Scene;
  48552. private _captureActiveMeshesEvaluationTime;
  48553. private _activeMeshesEvaluationTime;
  48554. private _captureRenderTargetsRenderTime;
  48555. private _renderTargetsRenderTime;
  48556. private _captureFrameTime;
  48557. private _frameTime;
  48558. private _captureRenderTime;
  48559. private _renderTime;
  48560. private _captureInterFrameTime;
  48561. private _interFrameTime;
  48562. private _captureParticlesRenderTime;
  48563. private _particlesRenderTime;
  48564. private _captureSpritesRenderTime;
  48565. private _spritesRenderTime;
  48566. private _capturePhysicsTime;
  48567. private _physicsTime;
  48568. private _captureAnimationsTime;
  48569. private _animationsTime;
  48570. private _captureCameraRenderTime;
  48571. private _cameraRenderTime;
  48572. private _onBeforeActiveMeshesEvaluationObserver;
  48573. private _onAfterActiveMeshesEvaluationObserver;
  48574. private _onBeforeRenderTargetsRenderObserver;
  48575. private _onAfterRenderTargetsRenderObserver;
  48576. private _onAfterRenderObserver;
  48577. private _onBeforeDrawPhaseObserver;
  48578. private _onAfterDrawPhaseObserver;
  48579. private _onBeforeAnimationsObserver;
  48580. private _onBeforeParticlesRenderingObserver;
  48581. private _onAfterParticlesRenderingObserver;
  48582. private _onBeforeSpritesRenderingObserver;
  48583. private _onAfterSpritesRenderingObserver;
  48584. private _onBeforePhysicsObserver;
  48585. private _onAfterPhysicsObserver;
  48586. private _onAfterAnimationsObserver;
  48587. private _onBeforeCameraRenderObserver;
  48588. private _onAfterCameraRenderObserver;
  48589. /**
  48590. * Gets the perf counter used for active meshes evaluation time
  48591. */
  48592. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48593. /**
  48594. * Gets the active meshes evaluation time capture status
  48595. */
  48596. /**
  48597. * Enable or disable the active meshes evaluation time capture
  48598. */
  48599. captureActiveMeshesEvaluationTime: boolean;
  48600. /**
  48601. * Gets the perf counter used for render targets render time
  48602. */
  48603. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48604. /**
  48605. * Gets the render targets render time capture status
  48606. */
  48607. /**
  48608. * Enable or disable the render targets render time capture
  48609. */
  48610. captureRenderTargetsRenderTime: boolean;
  48611. /**
  48612. * Gets the perf counter used for particles render time
  48613. */
  48614. readonly particlesRenderTimeCounter: PerfCounter;
  48615. /**
  48616. * Gets the particles render time capture status
  48617. */
  48618. /**
  48619. * Enable or disable the particles render time capture
  48620. */
  48621. captureParticlesRenderTime: boolean;
  48622. /**
  48623. * Gets the perf counter used for sprites render time
  48624. */
  48625. readonly spritesRenderTimeCounter: PerfCounter;
  48626. /**
  48627. * Gets the sprites render time capture status
  48628. */
  48629. /**
  48630. * Enable or disable the sprites render time capture
  48631. */
  48632. captureSpritesRenderTime: boolean;
  48633. /**
  48634. * Gets the perf counter used for physics time
  48635. */
  48636. readonly physicsTimeCounter: PerfCounter;
  48637. /**
  48638. * Gets the physics time capture status
  48639. */
  48640. /**
  48641. * Enable or disable the physics time capture
  48642. */
  48643. capturePhysicsTime: boolean;
  48644. /**
  48645. * Gets the perf counter used for animations time
  48646. */
  48647. readonly animationsTimeCounter: PerfCounter;
  48648. /**
  48649. * Gets the animations time capture status
  48650. */
  48651. /**
  48652. * Enable or disable the animations time capture
  48653. */
  48654. captureAnimationsTime: boolean;
  48655. /**
  48656. * Gets the perf counter used for frame time capture
  48657. */
  48658. readonly frameTimeCounter: PerfCounter;
  48659. /**
  48660. * Gets the frame time capture status
  48661. */
  48662. /**
  48663. * Enable or disable the frame time capture
  48664. */
  48665. captureFrameTime: boolean;
  48666. /**
  48667. * Gets the perf counter used for inter-frames time capture
  48668. */
  48669. readonly interFrameTimeCounter: PerfCounter;
  48670. /**
  48671. * Gets the inter-frames time capture status
  48672. */
  48673. /**
  48674. * Enable or disable the inter-frames time capture
  48675. */
  48676. captureInterFrameTime: boolean;
  48677. /**
  48678. * Gets the perf counter used for render time capture
  48679. */
  48680. readonly renderTimeCounter: PerfCounter;
  48681. /**
  48682. * Gets the render time capture status
  48683. */
  48684. /**
  48685. * Enable or disable the render time capture
  48686. */
  48687. captureRenderTime: boolean;
  48688. /**
  48689. * Gets the perf counter used for camera render time capture
  48690. */
  48691. readonly cameraRenderTimeCounter: PerfCounter;
  48692. /**
  48693. * Gets the camera render time capture status
  48694. */
  48695. /**
  48696. * Enable or disable the camera render time capture
  48697. */
  48698. captureCameraRenderTime: boolean;
  48699. /**
  48700. * Gets the perf counter used for draw calls
  48701. */
  48702. readonly drawCallsCounter: PerfCounter;
  48703. /**
  48704. * Instantiates a new scene instrumentation.
  48705. * This class can be used to get instrumentation data from a Babylon engine
  48706. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48707. * @param scene Defines the scene to instrument
  48708. */
  48709. constructor(
  48710. /**
  48711. * Defines the scene to instrument
  48712. */
  48713. scene: Scene);
  48714. /**
  48715. * Dispose and release associated resources.
  48716. */
  48717. dispose(): void;
  48718. }
  48719. }
  48720. declare module "babylonjs/Instrumentation/index" {
  48721. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48722. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48723. export * from "babylonjs/Instrumentation/timeToken";
  48724. }
  48725. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48726. /** @hidden */
  48727. export var glowMapGenerationPixelShader: {
  48728. name: string;
  48729. shader: string;
  48730. };
  48731. }
  48732. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48733. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48734. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48735. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48736. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48737. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48738. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48739. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48740. /** @hidden */
  48741. export var glowMapGenerationVertexShader: {
  48742. name: string;
  48743. shader: string;
  48744. };
  48745. }
  48746. declare module "babylonjs/Layers/effectLayer" {
  48747. import { Observable } from "babylonjs/Misc/observable";
  48748. import { Nullable } from "babylonjs/types";
  48749. import { Camera } from "babylonjs/Cameras/camera";
  48750. import { Scene } from "babylonjs/scene";
  48751. import { Color4, ISize } from "babylonjs/Maths/math";
  48752. import { Engine } from "babylonjs/Engines/engine";
  48753. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48755. import { Mesh } from "babylonjs/Meshes/mesh";
  48756. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48758. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48759. import { Effect } from "babylonjs/Materials/effect";
  48760. import { Material } from "babylonjs/Materials/material";
  48761. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48762. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48763. /**
  48764. * Effect layer options. This helps customizing the behaviour
  48765. * of the effect layer.
  48766. */
  48767. export interface IEffectLayerOptions {
  48768. /**
  48769. * Multiplication factor apply to the canvas size to compute the render target size
  48770. * used to generated the objects (the smaller the faster).
  48771. */
  48772. mainTextureRatio: number;
  48773. /**
  48774. * Enforces a fixed size texture to ensure effect stability across devices.
  48775. */
  48776. mainTextureFixedSize?: number;
  48777. /**
  48778. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48779. */
  48780. alphaBlendingMode: number;
  48781. /**
  48782. * The camera attached to the layer.
  48783. */
  48784. camera: Nullable<Camera>;
  48785. /**
  48786. * The rendering group to draw the layer in.
  48787. */
  48788. renderingGroupId: number;
  48789. }
  48790. /**
  48791. * The effect layer Helps adding post process effect blended with the main pass.
  48792. *
  48793. * This can be for instance use to generate glow or higlight effects on the scene.
  48794. *
  48795. * The effect layer class can not be used directly and is intented to inherited from to be
  48796. * customized per effects.
  48797. */
  48798. export abstract class EffectLayer {
  48799. private _vertexBuffers;
  48800. private _indexBuffer;
  48801. private _cachedDefines;
  48802. private _effectLayerMapGenerationEffect;
  48803. private _effectLayerOptions;
  48804. private _mergeEffect;
  48805. protected _scene: Scene;
  48806. protected _engine: Engine;
  48807. protected _maxSize: number;
  48808. protected _mainTextureDesiredSize: ISize;
  48809. protected _mainTexture: RenderTargetTexture;
  48810. protected _shouldRender: boolean;
  48811. protected _postProcesses: PostProcess[];
  48812. protected _textures: BaseTexture[];
  48813. protected _emissiveTextureAndColor: {
  48814. texture: Nullable<BaseTexture>;
  48815. color: Color4;
  48816. };
  48817. /**
  48818. * The name of the layer
  48819. */
  48820. name: string;
  48821. /**
  48822. * The clear color of the texture used to generate the glow map.
  48823. */
  48824. neutralColor: Color4;
  48825. /**
  48826. * Specifies wether the highlight layer is enabled or not.
  48827. */
  48828. isEnabled: boolean;
  48829. /**
  48830. * Gets the camera attached to the layer.
  48831. */
  48832. readonly camera: Nullable<Camera>;
  48833. /**
  48834. * Gets the rendering group id the layer should render in.
  48835. */
  48836. readonly renderingGroupId: number;
  48837. /**
  48838. * An event triggered when the effect layer has been disposed.
  48839. */
  48840. onDisposeObservable: Observable<EffectLayer>;
  48841. /**
  48842. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48843. */
  48844. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48845. /**
  48846. * An event triggered when the generated texture is being merged in the scene.
  48847. */
  48848. onBeforeComposeObservable: Observable<EffectLayer>;
  48849. /**
  48850. * An event triggered when the generated texture has been merged in the scene.
  48851. */
  48852. onAfterComposeObservable: Observable<EffectLayer>;
  48853. /**
  48854. * An event triggered when the efffect layer changes its size.
  48855. */
  48856. onSizeChangedObservable: Observable<EffectLayer>;
  48857. /** @hidden */
  48858. static _SceneComponentInitialization: (scene: Scene) => void;
  48859. /**
  48860. * Instantiates a new effect Layer and references it in the scene.
  48861. * @param name The name of the layer
  48862. * @param scene The scene to use the layer in
  48863. */
  48864. constructor(
  48865. /** The Friendly of the effect in the scene */
  48866. name: string, scene: Scene);
  48867. /**
  48868. * Get the effect name of the layer.
  48869. * @return The effect name
  48870. */
  48871. abstract getEffectName(): string;
  48872. /**
  48873. * Checks for the readiness of the element composing the layer.
  48874. * @param subMesh the mesh to check for
  48875. * @param useInstances specify wether or not to use instances to render the mesh
  48876. * @return true if ready otherwise, false
  48877. */
  48878. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48879. /**
  48880. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48881. * @returns true if the effect requires stencil during the main canvas render pass.
  48882. */
  48883. abstract needStencil(): boolean;
  48884. /**
  48885. * Create the merge effect. This is the shader use to blit the information back
  48886. * to the main canvas at the end of the scene rendering.
  48887. * @returns The effect containing the shader used to merge the effect on the main canvas
  48888. */
  48889. protected abstract _createMergeEffect(): Effect;
  48890. /**
  48891. * Creates the render target textures and post processes used in the effect layer.
  48892. */
  48893. protected abstract _createTextureAndPostProcesses(): void;
  48894. /**
  48895. * Implementation specific of rendering the generating effect on the main canvas.
  48896. * @param effect The effect used to render through
  48897. */
  48898. protected abstract _internalRender(effect: Effect): void;
  48899. /**
  48900. * Sets the required values for both the emissive texture and and the main color.
  48901. */
  48902. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48903. /**
  48904. * Free any resources and references associated to a mesh.
  48905. * Internal use
  48906. * @param mesh The mesh to free.
  48907. */
  48908. abstract _disposeMesh(mesh: Mesh): void;
  48909. /**
  48910. * Serializes this layer (Glow or Highlight for example)
  48911. * @returns a serialized layer object
  48912. */
  48913. abstract serialize?(): any;
  48914. /**
  48915. * Initializes the effect layer with the required options.
  48916. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48917. */
  48918. protected _init(options: Partial<IEffectLayerOptions>): void;
  48919. /**
  48920. * Generates the index buffer of the full screen quad blending to the main canvas.
  48921. */
  48922. private _generateIndexBuffer;
  48923. /**
  48924. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48925. */
  48926. private _generateVertexBuffer;
  48927. /**
  48928. * Sets the main texture desired size which is the closest power of two
  48929. * of the engine canvas size.
  48930. */
  48931. private _setMainTextureSize;
  48932. /**
  48933. * Creates the main texture for the effect layer.
  48934. */
  48935. protected _createMainTexture(): void;
  48936. /**
  48937. * Adds specific effects defines.
  48938. * @param defines The defines to add specifics to.
  48939. */
  48940. protected _addCustomEffectDefines(defines: string[]): void;
  48941. /**
  48942. * Checks for the readiness of the element composing the layer.
  48943. * @param subMesh the mesh to check for
  48944. * @param useInstances specify wether or not to use instances to render the mesh
  48945. * @param emissiveTexture the associated emissive texture used to generate the glow
  48946. * @return true if ready otherwise, false
  48947. */
  48948. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48949. /**
  48950. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48951. */
  48952. render(): void;
  48953. /**
  48954. * Determine if a given mesh will be used in the current effect.
  48955. * @param mesh mesh to test
  48956. * @returns true if the mesh will be used
  48957. */
  48958. hasMesh(mesh: AbstractMesh): boolean;
  48959. /**
  48960. * Returns true if the layer contains information to display, otherwise false.
  48961. * @returns true if the glow layer should be rendered
  48962. */
  48963. shouldRender(): boolean;
  48964. /**
  48965. * Returns true if the mesh should render, otherwise false.
  48966. * @param mesh The mesh to render
  48967. * @returns true if it should render otherwise false
  48968. */
  48969. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48970. /**
  48971. * Returns true if the mesh can be rendered, otherwise false.
  48972. * @param mesh The mesh to render
  48973. * @param material The material used on the mesh
  48974. * @returns true if it can be rendered otherwise false
  48975. */
  48976. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48977. /**
  48978. * Returns true if the mesh should render, otherwise false.
  48979. * @param mesh The mesh to render
  48980. * @returns true if it should render otherwise false
  48981. */
  48982. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48983. /**
  48984. * Renders the submesh passed in parameter to the generation map.
  48985. */
  48986. protected _renderSubMesh(subMesh: SubMesh): void;
  48987. /**
  48988. * Rebuild the required buffers.
  48989. * @hidden Internal use only.
  48990. */
  48991. _rebuild(): void;
  48992. /**
  48993. * Dispose only the render target textures and post process.
  48994. */
  48995. private _disposeTextureAndPostProcesses;
  48996. /**
  48997. * Dispose the highlight layer and free resources.
  48998. */
  48999. dispose(): void;
  49000. /**
  49001. * Gets the class name of the effect layer
  49002. * @returns the string with the class name of the effect layer
  49003. */
  49004. getClassName(): string;
  49005. /**
  49006. * Creates an effect layer from parsed effect layer data
  49007. * @param parsedEffectLayer defines effect layer data
  49008. * @param scene defines the current scene
  49009. * @param rootUrl defines the root URL containing the effect layer information
  49010. * @returns a parsed effect Layer
  49011. */
  49012. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49013. }
  49014. }
  49015. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49016. import { Scene } from "babylonjs/scene";
  49017. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49018. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49019. import { AbstractScene } from "babylonjs/abstractScene";
  49020. module "babylonjs/abstractScene" {
  49021. interface AbstractScene {
  49022. /**
  49023. * The list of effect layers (highlights/glow) added to the scene
  49024. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49025. * @see http://doc.babylonjs.com/how_to/glow_layer
  49026. */
  49027. effectLayers: Array<EffectLayer>;
  49028. /**
  49029. * Removes the given effect layer from this scene.
  49030. * @param toRemove defines the effect layer to remove
  49031. * @returns the index of the removed effect layer
  49032. */
  49033. removeEffectLayer(toRemove: EffectLayer): number;
  49034. /**
  49035. * Adds the given effect layer to this scene
  49036. * @param newEffectLayer defines the effect layer to add
  49037. */
  49038. addEffectLayer(newEffectLayer: EffectLayer): void;
  49039. }
  49040. }
  49041. /**
  49042. * Defines the layer scene component responsible to manage any effect layers
  49043. * in a given scene.
  49044. */
  49045. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49046. /**
  49047. * The component name helpfull to identify the component in the list of scene components.
  49048. */
  49049. readonly name: string;
  49050. /**
  49051. * The scene the component belongs to.
  49052. */
  49053. scene: Scene;
  49054. private _engine;
  49055. private _renderEffects;
  49056. private _needStencil;
  49057. private _previousStencilState;
  49058. /**
  49059. * Creates a new instance of the component for the given scene
  49060. * @param scene Defines the scene to register the component in
  49061. */
  49062. constructor(scene: Scene);
  49063. /**
  49064. * Registers the component in a given scene
  49065. */
  49066. register(): void;
  49067. /**
  49068. * Rebuilds the elements related to this component in case of
  49069. * context lost for instance.
  49070. */
  49071. rebuild(): void;
  49072. /**
  49073. * Serializes the component data to the specified json object
  49074. * @param serializationObject The object to serialize to
  49075. */
  49076. serialize(serializationObject: any): void;
  49077. /**
  49078. * Adds all the element from the container to the scene
  49079. * @param container the container holding the elements
  49080. */
  49081. addFromContainer(container: AbstractScene): void;
  49082. /**
  49083. * Removes all the elements in the container from the scene
  49084. * @param container contains the elements to remove
  49085. * @param dispose if the removed element should be disposed (default: false)
  49086. */
  49087. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49088. /**
  49089. * Disposes the component and the associated ressources.
  49090. */
  49091. dispose(): void;
  49092. private _isReadyForMesh;
  49093. private _renderMainTexture;
  49094. private _setStencil;
  49095. private _setStencilBack;
  49096. private _draw;
  49097. private _drawCamera;
  49098. private _drawRenderingGroup;
  49099. }
  49100. }
  49101. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49102. /** @hidden */
  49103. export var glowMapMergePixelShader: {
  49104. name: string;
  49105. shader: string;
  49106. };
  49107. }
  49108. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49109. /** @hidden */
  49110. export var glowMapMergeVertexShader: {
  49111. name: string;
  49112. shader: string;
  49113. };
  49114. }
  49115. declare module "babylonjs/Layers/glowLayer" {
  49116. import { Nullable } from "babylonjs/types";
  49117. import { Camera } from "babylonjs/Cameras/camera";
  49118. import { Scene } from "babylonjs/scene";
  49119. import { Color4 } from "babylonjs/Maths/math";
  49120. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49122. import { Mesh } from "babylonjs/Meshes/mesh";
  49123. import { Texture } from "babylonjs/Materials/Textures/texture";
  49124. import { Effect } from "babylonjs/Materials/effect";
  49125. import { Material } from "babylonjs/Materials/material";
  49126. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49127. import "babylonjs/Shaders/glowMapMerge.fragment";
  49128. import "babylonjs/Shaders/glowMapMerge.vertex";
  49129. import "babylonjs/Layers/effectLayerSceneComponent";
  49130. module "babylonjs/abstractScene" {
  49131. interface AbstractScene {
  49132. /**
  49133. * Return a the first highlight layer of the scene with a given name.
  49134. * @param name The name of the highlight layer to look for.
  49135. * @return The highlight layer if found otherwise null.
  49136. */
  49137. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49138. }
  49139. }
  49140. /**
  49141. * Glow layer options. This helps customizing the behaviour
  49142. * of the glow layer.
  49143. */
  49144. export interface IGlowLayerOptions {
  49145. /**
  49146. * Multiplication factor apply to the canvas size to compute the render target size
  49147. * used to generated the glowing objects (the smaller the faster).
  49148. */
  49149. mainTextureRatio: number;
  49150. /**
  49151. * Enforces a fixed size texture to ensure resize independant blur.
  49152. */
  49153. mainTextureFixedSize?: number;
  49154. /**
  49155. * How big is the kernel of the blur texture.
  49156. */
  49157. blurKernelSize: number;
  49158. /**
  49159. * The camera attached to the layer.
  49160. */
  49161. camera: Nullable<Camera>;
  49162. /**
  49163. * Enable MSAA by chosing the number of samples.
  49164. */
  49165. mainTextureSamples?: number;
  49166. /**
  49167. * The rendering group to draw the layer in.
  49168. */
  49169. renderingGroupId: number;
  49170. }
  49171. /**
  49172. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49173. *
  49174. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49175. * glowy meshes to your scene.
  49176. *
  49177. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49178. */
  49179. export class GlowLayer extends EffectLayer {
  49180. /**
  49181. * Effect Name of the layer.
  49182. */
  49183. static readonly EffectName: string;
  49184. /**
  49185. * The default blur kernel size used for the glow.
  49186. */
  49187. static DefaultBlurKernelSize: number;
  49188. /**
  49189. * The default texture size ratio used for the glow.
  49190. */
  49191. static DefaultTextureRatio: number;
  49192. /**
  49193. * Sets the kernel size of the blur.
  49194. */
  49195. /**
  49196. * Gets the kernel size of the blur.
  49197. */
  49198. blurKernelSize: number;
  49199. /**
  49200. * Sets the glow intensity.
  49201. */
  49202. /**
  49203. * Gets the glow intensity.
  49204. */
  49205. intensity: number;
  49206. private _options;
  49207. private _intensity;
  49208. private _horizontalBlurPostprocess1;
  49209. private _verticalBlurPostprocess1;
  49210. private _horizontalBlurPostprocess2;
  49211. private _verticalBlurPostprocess2;
  49212. private _blurTexture1;
  49213. private _blurTexture2;
  49214. private _postProcesses1;
  49215. private _postProcesses2;
  49216. private _includedOnlyMeshes;
  49217. private _excludedMeshes;
  49218. /**
  49219. * Callback used to let the user override the color selection on a per mesh basis
  49220. */
  49221. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49222. /**
  49223. * Callback used to let the user override the texture selection on a per mesh basis
  49224. */
  49225. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49226. /**
  49227. * Instantiates a new glow Layer and references it to the scene.
  49228. * @param name The name of the layer
  49229. * @param scene The scene to use the layer in
  49230. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49231. */
  49232. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49233. /**
  49234. * Get the effect name of the layer.
  49235. * @return The effect name
  49236. */
  49237. getEffectName(): string;
  49238. /**
  49239. * Create the merge effect. This is the shader use to blit the information back
  49240. * to the main canvas at the end of the scene rendering.
  49241. */
  49242. protected _createMergeEffect(): Effect;
  49243. /**
  49244. * Creates the render target textures and post processes used in the glow layer.
  49245. */
  49246. protected _createTextureAndPostProcesses(): void;
  49247. /**
  49248. * Checks for the readiness of the element composing the layer.
  49249. * @param subMesh the mesh to check for
  49250. * @param useInstances specify wether or not to use instances to render the mesh
  49251. * @param emissiveTexture the associated emissive texture used to generate the glow
  49252. * @return true if ready otherwise, false
  49253. */
  49254. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49255. /**
  49256. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49257. */
  49258. needStencil(): boolean;
  49259. /**
  49260. * Returns true if the mesh can be rendered, otherwise false.
  49261. * @param mesh The mesh to render
  49262. * @param material The material used on the mesh
  49263. * @returns true if it can be rendered otherwise false
  49264. */
  49265. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49266. /**
  49267. * Implementation specific of rendering the generating effect on the main canvas.
  49268. * @param effect The effect used to render through
  49269. */
  49270. protected _internalRender(effect: Effect): void;
  49271. /**
  49272. * Sets the required values for both the emissive texture and and the main color.
  49273. */
  49274. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49275. /**
  49276. * Returns true if the mesh should render, otherwise false.
  49277. * @param mesh The mesh to render
  49278. * @returns true if it should render otherwise false
  49279. */
  49280. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49281. /**
  49282. * Adds specific effects defines.
  49283. * @param defines The defines to add specifics to.
  49284. */
  49285. protected _addCustomEffectDefines(defines: string[]): void;
  49286. /**
  49287. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49288. * @param mesh The mesh to exclude from the glow layer
  49289. */
  49290. addExcludedMesh(mesh: Mesh): void;
  49291. /**
  49292. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49293. * @param mesh The mesh to remove
  49294. */
  49295. removeExcludedMesh(mesh: Mesh): void;
  49296. /**
  49297. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49298. * @param mesh The mesh to include in the glow layer
  49299. */
  49300. addIncludedOnlyMesh(mesh: Mesh): void;
  49301. /**
  49302. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49303. * @param mesh The mesh to remove
  49304. */
  49305. removeIncludedOnlyMesh(mesh: Mesh): void;
  49306. /**
  49307. * Determine if a given mesh will be used in the glow layer
  49308. * @param mesh The mesh to test
  49309. * @returns true if the mesh will be highlighted by the current glow layer
  49310. */
  49311. hasMesh(mesh: AbstractMesh): boolean;
  49312. /**
  49313. * Free any resources and references associated to a mesh.
  49314. * Internal use
  49315. * @param mesh The mesh to free.
  49316. * @hidden
  49317. */
  49318. _disposeMesh(mesh: Mesh): void;
  49319. /**
  49320. * Gets the class name of the effect layer
  49321. * @returns the string with the class name of the effect layer
  49322. */
  49323. getClassName(): string;
  49324. /**
  49325. * Serializes this glow layer
  49326. * @returns a serialized glow layer object
  49327. */
  49328. serialize(): any;
  49329. /**
  49330. * Creates a Glow Layer from parsed glow layer data
  49331. * @param parsedGlowLayer defines glow layer data
  49332. * @param scene defines the current scene
  49333. * @param rootUrl defines the root URL containing the glow layer information
  49334. * @returns a parsed Glow Layer
  49335. */
  49336. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49337. }
  49338. }
  49339. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49340. /** @hidden */
  49341. export var glowBlurPostProcessPixelShader: {
  49342. name: string;
  49343. shader: string;
  49344. };
  49345. }
  49346. declare module "babylonjs/Layers/highlightLayer" {
  49347. import { Observable } from "babylonjs/Misc/observable";
  49348. import { Nullable } from "babylonjs/types";
  49349. import { Camera } from "babylonjs/Cameras/camera";
  49350. import { Scene } from "babylonjs/scene";
  49351. import { Color3, Color4 } from "babylonjs/Maths/math";
  49352. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49354. import { Mesh } from "babylonjs/Meshes/mesh";
  49355. import { Effect } from "babylonjs/Materials/effect";
  49356. import { Material } from "babylonjs/Materials/material";
  49357. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49358. import "babylonjs/Shaders/glowMapMerge.fragment";
  49359. import "babylonjs/Shaders/glowMapMerge.vertex";
  49360. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49361. module "babylonjs/abstractScene" {
  49362. interface AbstractScene {
  49363. /**
  49364. * Return a the first highlight layer of the scene with a given name.
  49365. * @param name The name of the highlight layer to look for.
  49366. * @return The highlight layer if found otherwise null.
  49367. */
  49368. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49369. }
  49370. }
  49371. /**
  49372. * Highlight layer options. This helps customizing the behaviour
  49373. * of the highlight layer.
  49374. */
  49375. export interface IHighlightLayerOptions {
  49376. /**
  49377. * Multiplication factor apply to the canvas size to compute the render target size
  49378. * used to generated the glowing objects (the smaller the faster).
  49379. */
  49380. mainTextureRatio: number;
  49381. /**
  49382. * Enforces a fixed size texture to ensure resize independant blur.
  49383. */
  49384. mainTextureFixedSize?: number;
  49385. /**
  49386. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49387. * of the picture to blur (the smaller the faster).
  49388. */
  49389. blurTextureSizeRatio: number;
  49390. /**
  49391. * How big in texel of the blur texture is the vertical blur.
  49392. */
  49393. blurVerticalSize: number;
  49394. /**
  49395. * How big in texel of the blur texture is the horizontal blur.
  49396. */
  49397. blurHorizontalSize: number;
  49398. /**
  49399. * Alpha blending mode used to apply the blur. Default is combine.
  49400. */
  49401. alphaBlendingMode: number;
  49402. /**
  49403. * The camera attached to the layer.
  49404. */
  49405. camera: Nullable<Camera>;
  49406. /**
  49407. * Should we display highlight as a solid stroke?
  49408. */
  49409. isStroke?: boolean;
  49410. /**
  49411. * The rendering group to draw the layer in.
  49412. */
  49413. renderingGroupId: number;
  49414. }
  49415. /**
  49416. * The highlight layer Helps adding a glow effect around a mesh.
  49417. *
  49418. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49419. * glowy meshes to your scene.
  49420. *
  49421. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49422. */
  49423. export class HighlightLayer extends EffectLayer {
  49424. name: string;
  49425. /**
  49426. * Effect Name of the highlight layer.
  49427. */
  49428. static readonly EffectName: string;
  49429. /**
  49430. * The neutral color used during the preparation of the glow effect.
  49431. * This is black by default as the blend operation is a blend operation.
  49432. */
  49433. static NeutralColor: Color4;
  49434. /**
  49435. * Stencil value used for glowing meshes.
  49436. */
  49437. static GlowingMeshStencilReference: number;
  49438. /**
  49439. * Stencil value used for the other meshes in the scene.
  49440. */
  49441. static NormalMeshStencilReference: number;
  49442. /**
  49443. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49444. */
  49445. innerGlow: boolean;
  49446. /**
  49447. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49448. */
  49449. outerGlow: boolean;
  49450. /**
  49451. * Specifies the horizontal size of the blur.
  49452. */
  49453. /**
  49454. * Gets the horizontal size of the blur.
  49455. */
  49456. blurHorizontalSize: number;
  49457. /**
  49458. * Specifies the vertical size of the blur.
  49459. */
  49460. /**
  49461. * Gets the vertical size of the blur.
  49462. */
  49463. blurVerticalSize: number;
  49464. /**
  49465. * An event triggered when the highlight layer is being blurred.
  49466. */
  49467. onBeforeBlurObservable: Observable<HighlightLayer>;
  49468. /**
  49469. * An event triggered when the highlight layer has been blurred.
  49470. */
  49471. onAfterBlurObservable: Observable<HighlightLayer>;
  49472. private _instanceGlowingMeshStencilReference;
  49473. private _options;
  49474. private _downSamplePostprocess;
  49475. private _horizontalBlurPostprocess;
  49476. private _verticalBlurPostprocess;
  49477. private _blurTexture;
  49478. private _meshes;
  49479. private _excludedMeshes;
  49480. /**
  49481. * Instantiates a new highlight Layer and references it to the scene..
  49482. * @param name The name of the layer
  49483. * @param scene The scene to use the layer in
  49484. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49485. */
  49486. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49487. /**
  49488. * Get the effect name of the layer.
  49489. * @return The effect name
  49490. */
  49491. getEffectName(): string;
  49492. /**
  49493. * Create the merge effect. This is the shader use to blit the information back
  49494. * to the main canvas at the end of the scene rendering.
  49495. */
  49496. protected _createMergeEffect(): Effect;
  49497. /**
  49498. * Creates the render target textures and post processes used in the highlight layer.
  49499. */
  49500. protected _createTextureAndPostProcesses(): void;
  49501. /**
  49502. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49503. */
  49504. needStencil(): boolean;
  49505. /**
  49506. * Checks for the readiness of the element composing the layer.
  49507. * @param subMesh the mesh to check for
  49508. * @param useInstances specify wether or not to use instances to render the mesh
  49509. * @param emissiveTexture the associated emissive texture used to generate the glow
  49510. * @return true if ready otherwise, false
  49511. */
  49512. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49513. /**
  49514. * Implementation specific of rendering the generating effect on the main canvas.
  49515. * @param effect The effect used to render through
  49516. */
  49517. protected _internalRender(effect: Effect): void;
  49518. /**
  49519. * Returns true if the layer contains information to display, otherwise false.
  49520. */
  49521. shouldRender(): boolean;
  49522. /**
  49523. * Returns true if the mesh should render, otherwise false.
  49524. * @param mesh The mesh to render
  49525. * @returns true if it should render otherwise false
  49526. */
  49527. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49528. /**
  49529. * Sets the required values for both the emissive texture and and the main color.
  49530. */
  49531. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49532. /**
  49533. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49534. * @param mesh The mesh to exclude from the highlight layer
  49535. */
  49536. addExcludedMesh(mesh: Mesh): void;
  49537. /**
  49538. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49539. * @param mesh The mesh to highlight
  49540. */
  49541. removeExcludedMesh(mesh: Mesh): void;
  49542. /**
  49543. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49544. * @param mesh mesh to test
  49545. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49546. */
  49547. hasMesh(mesh: AbstractMesh): boolean;
  49548. /**
  49549. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49550. * @param mesh The mesh to highlight
  49551. * @param color The color of the highlight
  49552. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49553. */
  49554. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49555. /**
  49556. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49557. * @param mesh The mesh to highlight
  49558. */
  49559. removeMesh(mesh: Mesh): void;
  49560. /**
  49561. * Force the stencil to the normal expected value for none glowing parts
  49562. */
  49563. private _defaultStencilReference;
  49564. /**
  49565. * Free any resources and references associated to a mesh.
  49566. * Internal use
  49567. * @param mesh The mesh to free.
  49568. * @hidden
  49569. */
  49570. _disposeMesh(mesh: Mesh): void;
  49571. /**
  49572. * Dispose the highlight layer and free resources.
  49573. */
  49574. dispose(): void;
  49575. /**
  49576. * Gets the class name of the effect layer
  49577. * @returns the string with the class name of the effect layer
  49578. */
  49579. getClassName(): string;
  49580. /**
  49581. * Serializes this Highlight layer
  49582. * @returns a serialized Highlight layer object
  49583. */
  49584. serialize(): any;
  49585. /**
  49586. * Creates a Highlight layer from parsed Highlight layer data
  49587. * @param parsedHightlightLayer defines the Highlight layer data
  49588. * @param scene defines the current scene
  49589. * @param rootUrl defines the root URL containing the Highlight layer information
  49590. * @returns a parsed Highlight layer
  49591. */
  49592. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49593. }
  49594. }
  49595. declare module "babylonjs/Layers/index" {
  49596. export * from "babylonjs/Layers/effectLayer";
  49597. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49598. export * from "babylonjs/Layers/glowLayer";
  49599. export * from "babylonjs/Layers/highlightLayer";
  49600. export * from "babylonjs/Layers/layer";
  49601. export * from "babylonjs/Layers/layerSceneComponent";
  49602. }
  49603. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49604. /** @hidden */
  49605. export var lensFlarePixelShader: {
  49606. name: string;
  49607. shader: string;
  49608. };
  49609. }
  49610. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49611. /** @hidden */
  49612. export var lensFlareVertexShader: {
  49613. name: string;
  49614. shader: string;
  49615. };
  49616. }
  49617. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49618. import { Scene } from "babylonjs/scene";
  49619. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49621. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49622. import "babylonjs/Shaders/lensFlare.fragment";
  49623. import "babylonjs/Shaders/lensFlare.vertex";
  49624. /**
  49625. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49626. * It is usually composed of several `lensFlare`.
  49627. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49628. */
  49629. export class LensFlareSystem {
  49630. /**
  49631. * Define the name of the lens flare system
  49632. */
  49633. name: string;
  49634. /**
  49635. * List of lens flares used in this system.
  49636. */
  49637. lensFlares: LensFlare[];
  49638. /**
  49639. * Define a limit from the border the lens flare can be visible.
  49640. */
  49641. borderLimit: number;
  49642. /**
  49643. * Define a viewport border we do not want to see the lens flare in.
  49644. */
  49645. viewportBorder: number;
  49646. /**
  49647. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49648. */
  49649. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49650. /**
  49651. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49652. */
  49653. layerMask: number;
  49654. /**
  49655. * Define the id of the lens flare system in the scene.
  49656. * (equal to name by default)
  49657. */
  49658. id: string;
  49659. private _scene;
  49660. private _emitter;
  49661. private _vertexBuffers;
  49662. private _indexBuffer;
  49663. private _effect;
  49664. private _positionX;
  49665. private _positionY;
  49666. private _isEnabled;
  49667. /** @hidden */
  49668. static _SceneComponentInitialization: (scene: Scene) => void;
  49669. /**
  49670. * Instantiates a lens flare system.
  49671. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49672. * It is usually composed of several `lensFlare`.
  49673. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49674. * @param name Define the name of the lens flare system in the scene
  49675. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49676. * @param scene Define the scene the lens flare system belongs to
  49677. */
  49678. constructor(
  49679. /**
  49680. * Define the name of the lens flare system
  49681. */
  49682. name: string, emitter: any, scene: Scene);
  49683. /**
  49684. * Define if the lens flare system is enabled.
  49685. */
  49686. isEnabled: boolean;
  49687. /**
  49688. * Get the scene the effects belongs to.
  49689. * @returns the scene holding the lens flare system
  49690. */
  49691. getScene(): Scene;
  49692. /**
  49693. * Get the emitter of the lens flare system.
  49694. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49695. * @returns the emitter of the lens flare system
  49696. */
  49697. getEmitter(): any;
  49698. /**
  49699. * Set the emitter of the lens flare system.
  49700. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49701. * @param newEmitter Define the new emitter of the system
  49702. */
  49703. setEmitter(newEmitter: any): void;
  49704. /**
  49705. * Get the lens flare system emitter position.
  49706. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49707. * @returns the position
  49708. */
  49709. getEmitterPosition(): Vector3;
  49710. /**
  49711. * @hidden
  49712. */
  49713. computeEffectivePosition(globalViewport: Viewport): boolean;
  49714. /** @hidden */
  49715. _isVisible(): boolean;
  49716. /**
  49717. * @hidden
  49718. */
  49719. render(): boolean;
  49720. /**
  49721. * Dispose and release the lens flare with its associated resources.
  49722. */
  49723. dispose(): void;
  49724. /**
  49725. * Parse a lens flare system from a JSON repressentation
  49726. * @param parsedLensFlareSystem Define the JSON to parse
  49727. * @param scene Define the scene the parsed system should be instantiated in
  49728. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49729. * @returns the parsed system
  49730. */
  49731. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49732. /**
  49733. * Serialize the current Lens Flare System into a JSON representation.
  49734. * @returns the serialized JSON
  49735. */
  49736. serialize(): any;
  49737. }
  49738. }
  49739. declare module "babylonjs/LensFlares/lensFlare" {
  49740. import { Nullable } from "babylonjs/types";
  49741. import { Color3 } from "babylonjs/Maths/math";
  49742. import { Texture } from "babylonjs/Materials/Textures/texture";
  49743. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49744. /**
  49745. * This represents one of the lens effect in a `lensFlareSystem`.
  49746. * It controls one of the indiviual texture used in the effect.
  49747. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49748. */
  49749. export class LensFlare {
  49750. /**
  49751. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49752. */
  49753. size: number;
  49754. /**
  49755. * 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.
  49756. */
  49757. position: number;
  49758. /**
  49759. * Define the lens color.
  49760. */
  49761. color: Color3;
  49762. /**
  49763. * Define the lens texture.
  49764. */
  49765. texture: Nullable<Texture>;
  49766. /**
  49767. * Define the alpha mode to render this particular lens.
  49768. */
  49769. alphaMode: number;
  49770. private _system;
  49771. /**
  49772. * Creates a new Lens Flare.
  49773. * This represents one of the lens effect in a `lensFlareSystem`.
  49774. * It controls one of the indiviual texture used in the effect.
  49775. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49776. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49777. * @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.
  49778. * @param color Define the lens color
  49779. * @param imgUrl Define the lens texture url
  49780. * @param system Define the `lensFlareSystem` this flare is part of
  49781. * @returns The newly created Lens Flare
  49782. */
  49783. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49784. /**
  49785. * Instantiates a new Lens Flare.
  49786. * This represents one of the lens effect in a `lensFlareSystem`.
  49787. * It controls one of the indiviual texture used in the effect.
  49788. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49789. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49790. * @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.
  49791. * @param color Define the lens color
  49792. * @param imgUrl Define the lens texture url
  49793. * @param system Define the `lensFlareSystem` this flare is part of
  49794. */
  49795. constructor(
  49796. /**
  49797. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49798. */
  49799. size: number,
  49800. /**
  49801. * 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.
  49802. */
  49803. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49804. /**
  49805. * Dispose and release the lens flare with its associated resources.
  49806. */
  49807. dispose(): void;
  49808. }
  49809. }
  49810. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49811. import { Nullable } from "babylonjs/types";
  49812. import { Scene } from "babylonjs/scene";
  49813. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49814. import { AbstractScene } from "babylonjs/abstractScene";
  49815. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49816. module "babylonjs/abstractScene" {
  49817. interface AbstractScene {
  49818. /**
  49819. * The list of lens flare system added to the scene
  49820. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49821. */
  49822. lensFlareSystems: Array<LensFlareSystem>;
  49823. /**
  49824. * Removes the given lens flare system from this scene.
  49825. * @param toRemove The lens flare system to remove
  49826. * @returns The index of the removed lens flare system
  49827. */
  49828. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49829. /**
  49830. * Adds the given lens flare system to this scene
  49831. * @param newLensFlareSystem The lens flare system to add
  49832. */
  49833. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49834. /**
  49835. * Gets a lens flare system using its name
  49836. * @param name defines the name to look for
  49837. * @returns the lens flare system or null if not found
  49838. */
  49839. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49840. /**
  49841. * Gets a lens flare system using its id
  49842. * @param id defines the id to look for
  49843. * @returns the lens flare system or null if not found
  49844. */
  49845. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49846. }
  49847. }
  49848. /**
  49849. * Defines the lens flare scene component responsible to manage any lens flares
  49850. * in a given scene.
  49851. */
  49852. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49853. /**
  49854. * The component name helpfull to identify the component in the list of scene components.
  49855. */
  49856. readonly name: string;
  49857. /**
  49858. * The scene the component belongs to.
  49859. */
  49860. scene: Scene;
  49861. /**
  49862. * Creates a new instance of the component for the given scene
  49863. * @param scene Defines the scene to register the component in
  49864. */
  49865. constructor(scene: Scene);
  49866. /**
  49867. * Registers the component in a given scene
  49868. */
  49869. register(): void;
  49870. /**
  49871. * Rebuilds the elements related to this component in case of
  49872. * context lost for instance.
  49873. */
  49874. rebuild(): void;
  49875. /**
  49876. * Adds all the element from the container to the scene
  49877. * @param container the container holding the elements
  49878. */
  49879. addFromContainer(container: AbstractScene): void;
  49880. /**
  49881. * Removes all the elements in the container from the scene
  49882. * @param container contains the elements to remove
  49883. * @param dispose if the removed element should be disposed (default: false)
  49884. */
  49885. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49886. /**
  49887. * Serializes the component data to the specified json object
  49888. * @param serializationObject The object to serialize to
  49889. */
  49890. serialize(serializationObject: any): void;
  49891. /**
  49892. * Disposes the component and the associated ressources.
  49893. */
  49894. dispose(): void;
  49895. private _draw;
  49896. }
  49897. }
  49898. declare module "babylonjs/LensFlares/index" {
  49899. export * from "babylonjs/LensFlares/lensFlare";
  49900. export * from "babylonjs/LensFlares/lensFlareSystem";
  49901. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49902. }
  49903. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49904. import { Scene } from "babylonjs/scene";
  49905. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49906. import { AbstractScene } from "babylonjs/abstractScene";
  49907. /**
  49908. * Defines the shadow generator component responsible to manage any shadow generators
  49909. * in a given scene.
  49910. */
  49911. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49912. /**
  49913. * The component name helpfull to identify the component in the list of scene components.
  49914. */
  49915. readonly name: string;
  49916. /**
  49917. * The scene the component belongs to.
  49918. */
  49919. scene: Scene;
  49920. /**
  49921. * Creates a new instance of the component for the given scene
  49922. * @param scene Defines the scene to register the component in
  49923. */
  49924. constructor(scene: Scene);
  49925. /**
  49926. * Registers the component in a given scene
  49927. */
  49928. register(): void;
  49929. /**
  49930. * Rebuilds the elements related to this component in case of
  49931. * context lost for instance.
  49932. */
  49933. rebuild(): void;
  49934. /**
  49935. * Serializes the component data to the specified json object
  49936. * @param serializationObject The object to serialize to
  49937. */
  49938. serialize(serializationObject: any): void;
  49939. /**
  49940. * Adds all the element from the container to the scene
  49941. * @param container the container holding the elements
  49942. */
  49943. addFromContainer(container: AbstractScene): void;
  49944. /**
  49945. * Removes all the elements in the container from the scene
  49946. * @param container contains the elements to remove
  49947. * @param dispose if the removed element should be disposed (default: false)
  49948. */
  49949. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49950. /**
  49951. * Rebuilds the elements related to this component in case of
  49952. * context lost for instance.
  49953. */
  49954. dispose(): void;
  49955. private _gatherRenderTargets;
  49956. }
  49957. }
  49958. declare module "babylonjs/Lights/Shadows/index" {
  49959. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49960. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49961. }
  49962. declare module "babylonjs/Lights/pointLight" {
  49963. import { Scene } from "babylonjs/scene";
  49964. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49966. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49967. import { Effect } from "babylonjs/Materials/effect";
  49968. /**
  49969. * A point light is a light defined by an unique point in world space.
  49970. * The light is emitted in every direction from this point.
  49971. * A good example of a point light is a standard light bulb.
  49972. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49973. */
  49974. export class PointLight extends ShadowLight {
  49975. private _shadowAngle;
  49976. /**
  49977. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49978. * This specifies what angle the shadow will use to be created.
  49979. *
  49980. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49981. */
  49982. /**
  49983. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49984. * This specifies what angle the shadow will use to be created.
  49985. *
  49986. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49987. */
  49988. shadowAngle: number;
  49989. /**
  49990. * Gets the direction if it has been set.
  49991. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49992. */
  49993. /**
  49994. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49995. */
  49996. direction: Vector3;
  49997. /**
  49998. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49999. * A PointLight emits the light in every direction.
  50000. * It can cast shadows.
  50001. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50002. * ```javascript
  50003. * var pointLight = new PointLight("pl", camera.position, scene);
  50004. * ```
  50005. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50006. * @param name The light friendly name
  50007. * @param position The position of the point light in the scene
  50008. * @param scene The scene the lights belongs to
  50009. */
  50010. constructor(name: string, position: Vector3, scene: Scene);
  50011. /**
  50012. * Returns the string "PointLight"
  50013. * @returns the class name
  50014. */
  50015. getClassName(): string;
  50016. /**
  50017. * Returns the integer 0.
  50018. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50019. */
  50020. getTypeID(): number;
  50021. /**
  50022. * Specifies wether or not the shadowmap should be a cube texture.
  50023. * @returns true if the shadowmap needs to be a cube texture.
  50024. */
  50025. needCube(): boolean;
  50026. /**
  50027. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50028. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50029. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50030. */
  50031. getShadowDirection(faceIndex?: number): Vector3;
  50032. /**
  50033. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50034. * - fov = PI / 2
  50035. * - aspect ratio : 1.0
  50036. * - z-near and far equal to the active camera minZ and maxZ.
  50037. * Returns the PointLight.
  50038. */
  50039. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50040. protected _buildUniformLayout(): void;
  50041. /**
  50042. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50043. * @param effect The effect to update
  50044. * @param lightIndex The index of the light in the effect to update
  50045. * @returns The point light
  50046. */
  50047. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50048. /**
  50049. * Prepares the list of defines specific to the light type.
  50050. * @param defines the list of defines
  50051. * @param lightIndex defines the index of the light for the effect
  50052. */
  50053. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50054. }
  50055. }
  50056. declare module "babylonjs/Lights/index" {
  50057. export * from "babylonjs/Lights/light";
  50058. export * from "babylonjs/Lights/shadowLight";
  50059. export * from "babylonjs/Lights/Shadows/index";
  50060. export * from "babylonjs/Lights/directionalLight";
  50061. export * from "babylonjs/Lights/hemisphericLight";
  50062. export * from "babylonjs/Lights/pointLight";
  50063. export * from "babylonjs/Lights/spotLight";
  50064. }
  50065. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50066. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50067. /**
  50068. * Header information of HDR texture files.
  50069. */
  50070. export interface HDRInfo {
  50071. /**
  50072. * The height of the texture in pixels.
  50073. */
  50074. height: number;
  50075. /**
  50076. * The width of the texture in pixels.
  50077. */
  50078. width: number;
  50079. /**
  50080. * The index of the beginning of the data in the binary file.
  50081. */
  50082. dataPosition: number;
  50083. }
  50084. /**
  50085. * This groups tools to convert HDR texture to native colors array.
  50086. */
  50087. export class HDRTools {
  50088. private static Ldexp;
  50089. private static Rgbe2float;
  50090. private static readStringLine;
  50091. /**
  50092. * Reads header information from an RGBE texture stored in a native array.
  50093. * More information on this format are available here:
  50094. * https://en.wikipedia.org/wiki/RGBE_image_format
  50095. *
  50096. * @param uint8array The binary file stored in native array.
  50097. * @return The header information.
  50098. */
  50099. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50100. /**
  50101. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50102. * This RGBE texture needs to store the information as a panorama.
  50103. *
  50104. * More information on this format are available here:
  50105. * https://en.wikipedia.org/wiki/RGBE_image_format
  50106. *
  50107. * @param buffer The binary file stored in an array buffer.
  50108. * @param size The expected size of the extracted cubemap.
  50109. * @return The Cube Map information.
  50110. */
  50111. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50112. /**
  50113. * Returns the pixels data extracted from an RGBE texture.
  50114. * This pixels will be stored left to right up to down in the R G B order in one array.
  50115. *
  50116. * More information on this format are available here:
  50117. * https://en.wikipedia.org/wiki/RGBE_image_format
  50118. *
  50119. * @param uint8array The binary file stored in an array buffer.
  50120. * @param hdrInfo The header information of the file.
  50121. * @return The pixels data in RGB right to left up to down order.
  50122. */
  50123. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50124. private static RGBE_ReadPixels_RLE;
  50125. }
  50126. }
  50127. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50128. import { Nullable } from "babylonjs/types";
  50129. import { Scene } from "babylonjs/scene";
  50130. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50132. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50133. /**
  50134. * This represents a texture coming from an HDR input.
  50135. *
  50136. * The only supported format is currently panorama picture stored in RGBE format.
  50137. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50138. */
  50139. export class HDRCubeTexture extends BaseTexture {
  50140. private static _facesMapping;
  50141. private _generateHarmonics;
  50142. private _noMipmap;
  50143. private _textureMatrix;
  50144. private _size;
  50145. private _onLoad;
  50146. private _onError;
  50147. /**
  50148. * The texture URL.
  50149. */
  50150. url: string;
  50151. /**
  50152. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50153. */
  50154. coordinatesMode: number;
  50155. protected _isBlocking: boolean;
  50156. /**
  50157. * Sets wether or not the texture is blocking during loading.
  50158. */
  50159. /**
  50160. * Gets wether or not the texture is blocking during loading.
  50161. */
  50162. isBlocking: boolean;
  50163. protected _rotationY: number;
  50164. /**
  50165. * Sets texture matrix rotation angle around Y axis in radians.
  50166. */
  50167. /**
  50168. * Gets texture matrix rotation angle around Y axis radians.
  50169. */
  50170. rotationY: number;
  50171. /**
  50172. * Gets or sets the center of the bounding box associated with the cube texture
  50173. * It must define where the camera used to render the texture was set
  50174. */
  50175. boundingBoxPosition: Vector3;
  50176. private _boundingBoxSize;
  50177. /**
  50178. * Gets or sets the size of the bounding box associated with the cube texture
  50179. * When defined, the cubemap will switch to local mode
  50180. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50181. * @example https://www.babylonjs-playground.com/#RNASML
  50182. */
  50183. boundingBoxSize: Vector3;
  50184. /**
  50185. * Instantiates an HDRTexture from the following parameters.
  50186. *
  50187. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50188. * @param scene The scene the texture will be used in
  50189. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50190. * @param noMipmap Forces to not generate the mipmap if true
  50191. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50192. * @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)
  50193. * @param reserved Reserved flag for internal use.
  50194. */
  50195. 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>);
  50196. /**
  50197. * Get the current class name of the texture useful for serialization or dynamic coding.
  50198. * @returns "HDRCubeTexture"
  50199. */
  50200. getClassName(): string;
  50201. /**
  50202. * Occurs when the file is raw .hdr file.
  50203. */
  50204. private loadTexture;
  50205. clone(): HDRCubeTexture;
  50206. delayLoad(): void;
  50207. /**
  50208. * Get the texture reflection matrix used to rotate/transform the reflection.
  50209. * @returns the reflection matrix
  50210. */
  50211. getReflectionTextureMatrix(): Matrix;
  50212. /**
  50213. * Set the texture reflection matrix used to rotate/transform the reflection.
  50214. * @param value Define the reflection matrix to set
  50215. */
  50216. setReflectionTextureMatrix(value: Matrix): void;
  50217. /**
  50218. * Parses a JSON representation of an HDR Texture in order to create the texture
  50219. * @param parsedTexture Define the JSON representation
  50220. * @param scene Define the scene the texture should be created in
  50221. * @param rootUrl Define the root url in case we need to load relative dependencies
  50222. * @returns the newly created texture after parsing
  50223. */
  50224. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50225. serialize(): any;
  50226. }
  50227. }
  50228. declare module "babylonjs/Physics/physicsEngine" {
  50229. import { Nullable } from "babylonjs/types";
  50230. import { Vector3 } from "babylonjs/Maths/math";
  50231. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50232. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50233. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50234. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50235. /**
  50236. * Class used to control physics engine
  50237. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50238. */
  50239. export class PhysicsEngine implements IPhysicsEngine {
  50240. private _physicsPlugin;
  50241. /**
  50242. * Global value used to control the smallest number supported by the simulation
  50243. */
  50244. static Epsilon: number;
  50245. private _impostors;
  50246. private _joints;
  50247. /**
  50248. * Gets the gravity vector used by the simulation
  50249. */
  50250. gravity: Vector3;
  50251. /**
  50252. * Factory used to create the default physics plugin.
  50253. * @returns The default physics plugin
  50254. */
  50255. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50256. /**
  50257. * Creates a new Physics Engine
  50258. * @param gravity defines the gravity vector used by the simulation
  50259. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50260. */
  50261. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50262. /**
  50263. * Sets the gravity vector used by the simulation
  50264. * @param gravity defines the gravity vector to use
  50265. */
  50266. setGravity(gravity: Vector3): void;
  50267. /**
  50268. * Set the time step of the physics engine.
  50269. * Default is 1/60.
  50270. * To slow it down, enter 1/600 for example.
  50271. * To speed it up, 1/30
  50272. * @param newTimeStep defines the new timestep to apply to this world.
  50273. */
  50274. setTimeStep(newTimeStep?: number): void;
  50275. /**
  50276. * Get the time step of the physics engine.
  50277. * @returns the current time step
  50278. */
  50279. getTimeStep(): number;
  50280. /**
  50281. * Release all resources
  50282. */
  50283. dispose(): void;
  50284. /**
  50285. * Gets the name of the current physics plugin
  50286. * @returns the name of the plugin
  50287. */
  50288. getPhysicsPluginName(): string;
  50289. /**
  50290. * Adding a new impostor for the impostor tracking.
  50291. * This will be done by the impostor itself.
  50292. * @param impostor the impostor to add
  50293. */
  50294. addImpostor(impostor: PhysicsImpostor): void;
  50295. /**
  50296. * Remove an impostor from the engine.
  50297. * This impostor and its mesh will not longer be updated by the physics engine.
  50298. * @param impostor the impostor to remove
  50299. */
  50300. removeImpostor(impostor: PhysicsImpostor): void;
  50301. /**
  50302. * Add a joint to the physics engine
  50303. * @param mainImpostor defines the main impostor to which the joint is added.
  50304. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50305. * @param joint defines the joint that will connect both impostors.
  50306. */
  50307. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50308. /**
  50309. * Removes a joint from the simulation
  50310. * @param mainImpostor defines the impostor used with the joint
  50311. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50312. * @param joint defines the joint to remove
  50313. */
  50314. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50315. /**
  50316. * Called by the scene. No need to call it.
  50317. * @param delta defines the timespam between frames
  50318. */
  50319. _step(delta: number): void;
  50320. /**
  50321. * Gets the current plugin used to run the simulation
  50322. * @returns current plugin
  50323. */
  50324. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50325. /**
  50326. * Gets the list of physic impostors
  50327. * @returns an array of PhysicsImpostor
  50328. */
  50329. getImpostors(): Array<PhysicsImpostor>;
  50330. /**
  50331. * Gets the impostor for a physics enabled object
  50332. * @param object defines the object impersonated by the impostor
  50333. * @returns the PhysicsImpostor or null if not found
  50334. */
  50335. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50336. /**
  50337. * Gets the impostor for a physics body object
  50338. * @param body defines physics body used by the impostor
  50339. * @returns the PhysicsImpostor or null if not found
  50340. */
  50341. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50342. /**
  50343. * Does a raycast in the physics world
  50344. * @param from when should the ray start?
  50345. * @param to when should the ray end?
  50346. * @returns PhysicsRaycastResult
  50347. */
  50348. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50349. }
  50350. }
  50351. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50352. import { Nullable } from "babylonjs/types";
  50353. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50355. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50356. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50357. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50358. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50359. /** @hidden */
  50360. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50361. private _useDeltaForWorldStep;
  50362. world: any;
  50363. name: string;
  50364. private _physicsMaterials;
  50365. private _fixedTimeStep;
  50366. private _cannonRaycastResult;
  50367. private _raycastResult;
  50368. private _removeAfterStep;
  50369. BJSCANNON: any;
  50370. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50371. setGravity(gravity: Vector3): void;
  50372. setTimeStep(timeStep: number): void;
  50373. getTimeStep(): number;
  50374. executeStep(delta: number): void;
  50375. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50376. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50377. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50378. private _processChildMeshes;
  50379. removePhysicsBody(impostor: PhysicsImpostor): void;
  50380. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50381. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50382. private _addMaterial;
  50383. private _checkWithEpsilon;
  50384. private _createShape;
  50385. private _createHeightmap;
  50386. private _minus90X;
  50387. private _plus90X;
  50388. private _tmpPosition;
  50389. private _tmpDeltaPosition;
  50390. private _tmpUnityRotation;
  50391. private _updatePhysicsBodyTransformation;
  50392. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50393. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50394. isSupported(): boolean;
  50395. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50396. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50397. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50398. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50399. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50400. getBodyMass(impostor: PhysicsImpostor): number;
  50401. getBodyFriction(impostor: PhysicsImpostor): number;
  50402. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50403. getBodyRestitution(impostor: PhysicsImpostor): number;
  50404. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50405. sleepBody(impostor: PhysicsImpostor): void;
  50406. wakeUpBody(impostor: PhysicsImpostor): void;
  50407. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50408. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50409. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50410. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50411. getRadius(impostor: PhysicsImpostor): number;
  50412. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50413. dispose(): void;
  50414. private _extendNamespace;
  50415. /**
  50416. * Does a raycast in the physics world
  50417. * @param from when should the ray start?
  50418. * @param to when should the ray end?
  50419. * @returns PhysicsRaycastResult
  50420. */
  50421. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50422. }
  50423. }
  50424. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50425. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50426. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50427. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50429. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50430. import { Nullable } from "babylonjs/types";
  50431. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50432. /** @hidden */
  50433. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50434. world: any;
  50435. name: string;
  50436. BJSOIMO: any;
  50437. private _raycastResult;
  50438. constructor(iterations?: number, oimoInjection?: any);
  50439. setGravity(gravity: Vector3): void;
  50440. setTimeStep(timeStep: number): void;
  50441. getTimeStep(): number;
  50442. private _tmpImpostorsArray;
  50443. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50444. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50445. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50446. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50447. private _tmpPositionVector;
  50448. removePhysicsBody(impostor: PhysicsImpostor): void;
  50449. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50450. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50451. isSupported(): boolean;
  50452. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50453. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50454. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50455. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50456. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50457. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50458. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50459. getBodyMass(impostor: PhysicsImpostor): number;
  50460. getBodyFriction(impostor: PhysicsImpostor): number;
  50461. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50462. getBodyRestitution(impostor: PhysicsImpostor): number;
  50463. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50464. sleepBody(impostor: PhysicsImpostor): void;
  50465. wakeUpBody(impostor: PhysicsImpostor): void;
  50466. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50467. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50468. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50469. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50470. getRadius(impostor: PhysicsImpostor): number;
  50471. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50472. dispose(): void;
  50473. /**
  50474. * Does a raycast in the physics world
  50475. * @param from when should the ray start?
  50476. * @param to when should the ray end?
  50477. * @returns PhysicsRaycastResult
  50478. */
  50479. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50480. }
  50481. }
  50482. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50483. import { Nullable } from "babylonjs/types";
  50484. import { Scene } from "babylonjs/scene";
  50485. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50486. import { Mesh } from "babylonjs/Meshes/mesh";
  50487. /**
  50488. * Class containing static functions to help procedurally build meshes
  50489. */
  50490. export class RibbonBuilder {
  50491. /**
  50492. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50493. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50494. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50495. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50496. * * 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
  50497. * * 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
  50498. * * 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
  50499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50502. * * The 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
  50503. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50504. * * 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
  50505. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50507. * @param name defines the name of the mesh
  50508. * @param options defines the options used to create the mesh
  50509. * @param scene defines the hosting scene
  50510. * @returns the ribbon mesh
  50511. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50512. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50513. */
  50514. static CreateRibbon(name: string, options: {
  50515. pathArray: Vector3[][];
  50516. closeArray?: boolean;
  50517. closePath?: boolean;
  50518. offset?: number;
  50519. updatable?: boolean;
  50520. sideOrientation?: number;
  50521. frontUVs?: Vector4;
  50522. backUVs?: Vector4;
  50523. instance?: Mesh;
  50524. invertUV?: boolean;
  50525. uvs?: Vector2[];
  50526. colors?: Color4[];
  50527. }, scene?: Nullable<Scene>): Mesh;
  50528. }
  50529. }
  50530. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50531. import { Nullable } from "babylonjs/types";
  50532. import { Scene } from "babylonjs/scene";
  50533. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50534. import { Mesh } from "babylonjs/Meshes/mesh";
  50535. /**
  50536. * Class containing static functions to help procedurally build meshes
  50537. */
  50538. export class ShapeBuilder {
  50539. /**
  50540. * 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.
  50541. * * 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.
  50542. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50543. * * 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.
  50544. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50545. * * 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
  50546. * * 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
  50547. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50550. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50552. * @param name defines the name of the mesh
  50553. * @param options defines the options used to create the mesh
  50554. * @param scene defines the hosting scene
  50555. * @returns the extruded shape mesh
  50556. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50558. */
  50559. static ExtrudeShape(name: string, options: {
  50560. shape: Vector3[];
  50561. path: Vector3[];
  50562. scale?: number;
  50563. rotation?: number;
  50564. cap?: number;
  50565. updatable?: boolean;
  50566. sideOrientation?: number;
  50567. frontUVs?: Vector4;
  50568. backUVs?: Vector4;
  50569. instance?: Mesh;
  50570. invertUV?: boolean;
  50571. }, scene?: Nullable<Scene>): Mesh;
  50572. /**
  50573. * Creates an custom extruded shape mesh.
  50574. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50575. * * 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.
  50576. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50577. * * 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
  50578. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50579. * * 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
  50580. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50581. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50582. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50583. * * 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
  50584. * * 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
  50585. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50588. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50590. * @param name defines the name of the mesh
  50591. * @param options defines the options used to create the mesh
  50592. * @param scene defines the hosting scene
  50593. * @returns the custom extruded shape mesh
  50594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50595. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50597. */
  50598. static ExtrudeShapeCustom(name: string, options: {
  50599. shape: Vector3[];
  50600. path: Vector3[];
  50601. scaleFunction?: any;
  50602. rotationFunction?: any;
  50603. ribbonCloseArray?: boolean;
  50604. ribbonClosePath?: boolean;
  50605. cap?: number;
  50606. updatable?: boolean;
  50607. sideOrientation?: number;
  50608. frontUVs?: Vector4;
  50609. backUVs?: Vector4;
  50610. instance?: Mesh;
  50611. invertUV?: boolean;
  50612. }, scene?: Nullable<Scene>): Mesh;
  50613. private static _ExtrudeShapeGeneric;
  50614. }
  50615. }
  50616. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50617. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50618. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50619. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50620. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50621. import { Nullable } from "babylonjs/types";
  50622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50623. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50624. /**
  50625. * AmmoJS Physics plugin
  50626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50627. * @see https://github.com/kripken/ammo.js/
  50628. */
  50629. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50630. private _useDeltaForWorldStep;
  50631. /**
  50632. * Reference to the Ammo library
  50633. */
  50634. bjsAMMO: any;
  50635. /**
  50636. * Created ammoJS world which physics bodies are added to
  50637. */
  50638. world: any;
  50639. /**
  50640. * Name of the plugin
  50641. */
  50642. name: string;
  50643. private _timeStep;
  50644. private _fixedTimeStep;
  50645. private _maxSteps;
  50646. private _tmpQuaternion;
  50647. private _tmpAmmoTransform;
  50648. private _tmpAmmoQuaternion;
  50649. private _tmpAmmoConcreteContactResultCallback;
  50650. private _collisionConfiguration;
  50651. private _dispatcher;
  50652. private _overlappingPairCache;
  50653. private _solver;
  50654. private _softBodySolver;
  50655. private _tmpAmmoVectorA;
  50656. private _tmpAmmoVectorB;
  50657. private _tmpAmmoVectorC;
  50658. private _tmpAmmoVectorD;
  50659. private _tmpContactCallbackResult;
  50660. private _tmpAmmoVectorRCA;
  50661. private _tmpAmmoVectorRCB;
  50662. private _raycastResult;
  50663. private static readonly DISABLE_COLLISION_FLAG;
  50664. private static readonly KINEMATIC_FLAG;
  50665. private static readonly DISABLE_DEACTIVATION_FLAG;
  50666. /**
  50667. * Initializes the ammoJS plugin
  50668. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50669. * @param ammoInjection can be used to inject your own ammo reference
  50670. */
  50671. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50672. /**
  50673. * Sets the gravity of the physics world (m/(s^2))
  50674. * @param gravity Gravity to set
  50675. */
  50676. setGravity(gravity: Vector3): void;
  50677. /**
  50678. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50679. * @param timeStep timestep to use in seconds
  50680. */
  50681. setTimeStep(timeStep: number): void;
  50682. /**
  50683. * 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)
  50684. * @param fixedTimeStep fixedTimeStep to use in seconds
  50685. */
  50686. setFixedTimeStep(fixedTimeStep: number): void;
  50687. /**
  50688. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50689. * @param maxSteps the maximum number of steps by the physics engine per frame
  50690. */
  50691. setMaxSteps(maxSteps: number): void;
  50692. /**
  50693. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50694. * @returns the current timestep in seconds
  50695. */
  50696. getTimeStep(): number;
  50697. private _isImpostorInContact;
  50698. private _isImpostorPairInContact;
  50699. private _stepSimulation;
  50700. /**
  50701. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50702. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50703. * After the step the babylon meshes are set to the position of the physics imposters
  50704. * @param delta amount of time to step forward
  50705. * @param impostors array of imposters to update before/after the step
  50706. */
  50707. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50708. /**
  50709. * Update babylon mesh to match physics world object
  50710. * @param impostor imposter to match
  50711. */
  50712. private _afterSoftStep;
  50713. /**
  50714. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50715. * @param impostor imposter to match
  50716. */
  50717. private _ropeStep;
  50718. /**
  50719. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50720. * @param impostor imposter to match
  50721. */
  50722. private _softbodyOrClothStep;
  50723. private _tmpVector;
  50724. private _tmpMatrix;
  50725. /**
  50726. * Applies an impulse on the imposter
  50727. * @param impostor imposter to apply impulse to
  50728. * @param force amount of force to be applied to the imposter
  50729. * @param contactPoint the location to apply the impulse on the imposter
  50730. */
  50731. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50732. /**
  50733. * Applies a force on the imposter
  50734. * @param impostor imposter to apply force
  50735. * @param force amount of force to be applied to the imposter
  50736. * @param contactPoint the location to apply the force on the imposter
  50737. */
  50738. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50739. /**
  50740. * Creates a physics body using the plugin
  50741. * @param impostor the imposter to create the physics body on
  50742. */
  50743. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50744. /**
  50745. * Removes the physics body from the imposter and disposes of the body's memory
  50746. * @param impostor imposter to remove the physics body from
  50747. */
  50748. removePhysicsBody(impostor: PhysicsImpostor): void;
  50749. /**
  50750. * Generates a joint
  50751. * @param impostorJoint the imposter joint to create the joint with
  50752. */
  50753. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50754. /**
  50755. * Removes a joint
  50756. * @param impostorJoint the imposter joint to remove the joint from
  50757. */
  50758. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50759. private _addMeshVerts;
  50760. /**
  50761. * Initialise the soft body vertices to match its object's (mesh) vertices
  50762. * Softbody vertices (nodes) are in world space and to match this
  50763. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50764. * @param impostor to create the softbody for
  50765. */
  50766. private _softVertexData;
  50767. /**
  50768. * Create an impostor's soft body
  50769. * @param impostor to create the softbody for
  50770. */
  50771. private _createSoftbody;
  50772. /**
  50773. * Create cloth for an impostor
  50774. * @param impostor to create the softbody for
  50775. */
  50776. private _createCloth;
  50777. /**
  50778. * Create rope for an impostor
  50779. * @param impostor to create the softbody for
  50780. */
  50781. private _createRope;
  50782. private _addHullVerts;
  50783. private _createShape;
  50784. /**
  50785. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50786. * @param impostor imposter containing the physics body and babylon object
  50787. */
  50788. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50789. /**
  50790. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50791. * @param impostor imposter containing the physics body and babylon object
  50792. * @param newPosition new position
  50793. * @param newRotation new rotation
  50794. */
  50795. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50796. /**
  50797. * If this plugin is supported
  50798. * @returns true if its supported
  50799. */
  50800. isSupported(): boolean;
  50801. /**
  50802. * Sets the linear velocity of the physics body
  50803. * @param impostor imposter to set the velocity on
  50804. * @param velocity velocity to set
  50805. */
  50806. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50807. /**
  50808. * Sets the angular velocity of the physics body
  50809. * @param impostor imposter to set the velocity on
  50810. * @param velocity velocity to set
  50811. */
  50812. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50813. /**
  50814. * gets the linear velocity
  50815. * @param impostor imposter to get linear velocity from
  50816. * @returns linear velocity
  50817. */
  50818. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50819. /**
  50820. * gets the angular velocity
  50821. * @param impostor imposter to get angular velocity from
  50822. * @returns angular velocity
  50823. */
  50824. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50825. /**
  50826. * Sets the mass of physics body
  50827. * @param impostor imposter to set the mass on
  50828. * @param mass mass to set
  50829. */
  50830. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50831. /**
  50832. * Gets the mass of the physics body
  50833. * @param impostor imposter to get the mass from
  50834. * @returns mass
  50835. */
  50836. getBodyMass(impostor: PhysicsImpostor): number;
  50837. /**
  50838. * Gets friction of the impostor
  50839. * @param impostor impostor to get friction from
  50840. * @returns friction value
  50841. */
  50842. getBodyFriction(impostor: PhysicsImpostor): number;
  50843. /**
  50844. * Sets friction of the impostor
  50845. * @param impostor impostor to set friction on
  50846. * @param friction friction value
  50847. */
  50848. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50849. /**
  50850. * Gets restitution of the impostor
  50851. * @param impostor impostor to get restitution from
  50852. * @returns restitution value
  50853. */
  50854. getBodyRestitution(impostor: PhysicsImpostor): number;
  50855. /**
  50856. * Sets resitution of the impostor
  50857. * @param impostor impostor to set resitution on
  50858. * @param restitution resitution value
  50859. */
  50860. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50861. /**
  50862. * Gets pressure inside the impostor
  50863. * @param impostor impostor to get pressure from
  50864. * @returns pressure value
  50865. */
  50866. getBodyPressure(impostor: PhysicsImpostor): number;
  50867. /**
  50868. * Sets pressure inside a soft body impostor
  50869. * Cloth and rope must remain 0 pressure
  50870. * @param impostor impostor to set pressure on
  50871. * @param pressure pressure value
  50872. */
  50873. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50874. /**
  50875. * Gets stiffness of the impostor
  50876. * @param impostor impostor to get stiffness from
  50877. * @returns pressure value
  50878. */
  50879. getBodyStiffness(impostor: PhysicsImpostor): number;
  50880. /**
  50881. * Sets stiffness of the impostor
  50882. * @param impostor impostor to set stiffness on
  50883. * @param stiffness stiffness value from 0 to 1
  50884. */
  50885. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50886. /**
  50887. * Gets velocityIterations of the impostor
  50888. * @param impostor impostor to get velocity iterations from
  50889. * @returns velocityIterations value
  50890. */
  50891. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50892. /**
  50893. * Sets velocityIterations of the impostor
  50894. * @param impostor impostor to set velocity iterations on
  50895. * @param velocityIterations velocityIterations value
  50896. */
  50897. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50898. /**
  50899. * Gets positionIterations of the impostor
  50900. * @param impostor impostor to get position iterations from
  50901. * @returns positionIterations value
  50902. */
  50903. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50904. /**
  50905. * Sets positionIterations of the impostor
  50906. * @param impostor impostor to set position on
  50907. * @param positionIterations positionIterations value
  50908. */
  50909. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50910. /**
  50911. * Append an anchor to a cloth object
  50912. * @param impostor is the cloth impostor to add anchor to
  50913. * @param otherImpostor is the rigid impostor to anchor to
  50914. * @param width ratio across width from 0 to 1
  50915. * @param height ratio up height from 0 to 1
  50916. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50917. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50918. */
  50919. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50920. /**
  50921. * Append an hook to a rope object
  50922. * @param impostor is the rope impostor to add hook to
  50923. * @param otherImpostor is the rigid impostor to hook to
  50924. * @param length ratio along the rope from 0 to 1
  50925. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50926. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50927. */
  50928. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50929. /**
  50930. * Sleeps the physics body and stops it from being active
  50931. * @param impostor impostor to sleep
  50932. */
  50933. sleepBody(impostor: PhysicsImpostor): void;
  50934. /**
  50935. * Activates the physics body
  50936. * @param impostor impostor to activate
  50937. */
  50938. wakeUpBody(impostor: PhysicsImpostor): void;
  50939. /**
  50940. * Updates the distance parameters of the joint
  50941. * @param joint joint to update
  50942. * @param maxDistance maximum distance of the joint
  50943. * @param minDistance minimum distance of the joint
  50944. */
  50945. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50946. /**
  50947. * Sets a motor on the joint
  50948. * @param joint joint to set motor on
  50949. * @param speed speed of the motor
  50950. * @param maxForce maximum force of the motor
  50951. * @param motorIndex index of the motor
  50952. */
  50953. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50954. /**
  50955. * Sets the motors limit
  50956. * @param joint joint to set limit on
  50957. * @param upperLimit upper limit
  50958. * @param lowerLimit lower limit
  50959. */
  50960. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50961. /**
  50962. * Syncs the position and rotation of a mesh with the impostor
  50963. * @param mesh mesh to sync
  50964. * @param impostor impostor to update the mesh with
  50965. */
  50966. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50967. /**
  50968. * Gets the radius of the impostor
  50969. * @param impostor impostor to get radius from
  50970. * @returns the radius
  50971. */
  50972. getRadius(impostor: PhysicsImpostor): number;
  50973. /**
  50974. * Gets the box size of the impostor
  50975. * @param impostor impostor to get box size from
  50976. * @param result the resulting box size
  50977. */
  50978. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50979. /**
  50980. * Disposes of the impostor
  50981. */
  50982. dispose(): void;
  50983. /**
  50984. * Does a raycast in the physics world
  50985. * @param from when should the ray start?
  50986. * @param to when should the ray end?
  50987. * @returns PhysicsRaycastResult
  50988. */
  50989. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50990. }
  50991. }
  50992. declare module "babylonjs/Probes/reflectionProbe" {
  50993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50994. import { Vector3 } from "babylonjs/Maths/math";
  50995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50996. import { Nullable } from "babylonjs/types";
  50997. import { Scene } from "babylonjs/scene";
  50998. module "babylonjs/abstractScene" {
  50999. interface AbstractScene {
  51000. /**
  51001. * The list of reflection probes added to the scene
  51002. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51003. */
  51004. reflectionProbes: Array<ReflectionProbe>;
  51005. /**
  51006. * Removes the given reflection probe from this scene.
  51007. * @param toRemove The reflection probe to remove
  51008. * @returns The index of the removed reflection probe
  51009. */
  51010. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51011. /**
  51012. * Adds the given reflection probe to this scene.
  51013. * @param newReflectionProbe The reflection probe to add
  51014. */
  51015. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51016. }
  51017. }
  51018. /**
  51019. * Class used to generate realtime reflection / refraction cube textures
  51020. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51021. */
  51022. export class ReflectionProbe {
  51023. /** defines the name of the probe */
  51024. name: string;
  51025. private _scene;
  51026. private _renderTargetTexture;
  51027. private _projectionMatrix;
  51028. private _viewMatrix;
  51029. private _target;
  51030. private _add;
  51031. private _attachedMesh;
  51032. private _invertYAxis;
  51033. /** Gets or sets probe position (center of the cube map) */
  51034. position: Vector3;
  51035. /**
  51036. * Creates a new reflection probe
  51037. * @param name defines the name of the probe
  51038. * @param size defines the texture resolution (for each face)
  51039. * @param scene defines the hosting scene
  51040. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51041. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51042. */
  51043. constructor(
  51044. /** defines the name of the probe */
  51045. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51046. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51047. samples: number;
  51048. /** Gets or sets the refresh rate to use (on every frame by default) */
  51049. refreshRate: number;
  51050. /**
  51051. * Gets the hosting scene
  51052. * @returns a Scene
  51053. */
  51054. getScene(): Scene;
  51055. /** Gets the internal CubeTexture used to render to */
  51056. readonly cubeTexture: RenderTargetTexture;
  51057. /** Gets the list of meshes to render */
  51058. readonly renderList: Nullable<AbstractMesh[]>;
  51059. /**
  51060. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51061. * @param mesh defines the mesh to attach to
  51062. */
  51063. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51064. /**
  51065. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51066. * @param renderingGroupId The rendering group id corresponding to its index
  51067. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51068. */
  51069. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51070. /**
  51071. * Clean all associated resources
  51072. */
  51073. dispose(): void;
  51074. /**
  51075. * Converts the reflection probe information to a readable string for debug purpose.
  51076. * @param fullDetails Supports for multiple levels of logging within scene loading
  51077. * @returns the human readable reflection probe info
  51078. */
  51079. toString(fullDetails?: boolean): string;
  51080. /**
  51081. * Get the class name of the relfection probe.
  51082. * @returns "ReflectionProbe"
  51083. */
  51084. getClassName(): string;
  51085. /**
  51086. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51087. * @returns The JSON representation of the texture
  51088. */
  51089. serialize(): any;
  51090. /**
  51091. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51092. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51093. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51094. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51095. * @returns The parsed reflection probe if successful
  51096. */
  51097. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51098. }
  51099. }
  51100. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51101. /** @hidden */
  51102. export var _BabylonLoaderRegistered: boolean;
  51103. }
  51104. declare module "babylonjs/Loading/Plugins/index" {
  51105. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51106. }
  51107. declare module "babylonjs/Loading/index" {
  51108. export * from "babylonjs/Loading/loadingScreen";
  51109. export * from "babylonjs/Loading/Plugins/index";
  51110. export * from "babylonjs/Loading/sceneLoader";
  51111. export * from "babylonjs/Loading/sceneLoaderFlags";
  51112. }
  51113. declare module "babylonjs/Materials/Background/index" {
  51114. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51115. }
  51116. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51117. import { Scene } from "babylonjs/scene";
  51118. import { Color3 } from "babylonjs/Maths/math";
  51119. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51120. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51121. /**
  51122. * The Physically based simple base material of BJS.
  51123. *
  51124. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51125. * It is used as the base class for both the specGloss and metalRough conventions.
  51126. */
  51127. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51128. /**
  51129. * Number of Simultaneous lights allowed on the material.
  51130. */
  51131. maxSimultaneousLights: number;
  51132. /**
  51133. * If sets to true, disables all the lights affecting the material.
  51134. */
  51135. disableLighting: boolean;
  51136. /**
  51137. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51138. */
  51139. environmentTexture: BaseTexture;
  51140. /**
  51141. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51142. */
  51143. invertNormalMapX: boolean;
  51144. /**
  51145. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51146. */
  51147. invertNormalMapY: boolean;
  51148. /**
  51149. * Normal map used in the model.
  51150. */
  51151. normalTexture: BaseTexture;
  51152. /**
  51153. * Emissivie color used to self-illuminate the model.
  51154. */
  51155. emissiveColor: Color3;
  51156. /**
  51157. * Emissivie texture used to self-illuminate the model.
  51158. */
  51159. emissiveTexture: BaseTexture;
  51160. /**
  51161. * Occlusion Channel Strenght.
  51162. */
  51163. occlusionStrength: number;
  51164. /**
  51165. * Occlusion Texture of the material (adding extra occlusion effects).
  51166. */
  51167. occlusionTexture: BaseTexture;
  51168. /**
  51169. * Defines the alpha limits in alpha test mode.
  51170. */
  51171. alphaCutOff: number;
  51172. /**
  51173. * Gets the current double sided mode.
  51174. */
  51175. /**
  51176. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51177. */
  51178. doubleSided: boolean;
  51179. /**
  51180. * Stores the pre-calculated light information of a mesh in a texture.
  51181. */
  51182. lightmapTexture: BaseTexture;
  51183. /**
  51184. * If true, the light map contains occlusion information instead of lighting info.
  51185. */
  51186. useLightmapAsShadowmap: boolean;
  51187. /**
  51188. * Instantiates a new PBRMaterial instance.
  51189. *
  51190. * @param name The material name
  51191. * @param scene The scene the material will be use in.
  51192. */
  51193. constructor(name: string, scene: Scene);
  51194. getClassName(): string;
  51195. }
  51196. }
  51197. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51198. import { Scene } from "babylonjs/scene";
  51199. import { Color3 } from "babylonjs/Maths/math";
  51200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51201. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51202. /**
  51203. * The PBR material of BJS following the metal roughness convention.
  51204. *
  51205. * This fits to the PBR convention in the GLTF definition:
  51206. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51207. */
  51208. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51209. /**
  51210. * The base color has two different interpretations depending on the value of metalness.
  51211. * When the material is a metal, the base color is the specific measured reflectance value
  51212. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51213. * of the material.
  51214. */
  51215. baseColor: Color3;
  51216. /**
  51217. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51218. * well as opacity information in the alpha channel.
  51219. */
  51220. baseTexture: BaseTexture;
  51221. /**
  51222. * Specifies the metallic scalar value of the material.
  51223. * Can also be used to scale the metalness values of the metallic texture.
  51224. */
  51225. metallic: number;
  51226. /**
  51227. * Specifies the roughness scalar value of the material.
  51228. * Can also be used to scale the roughness values of the metallic texture.
  51229. */
  51230. roughness: number;
  51231. /**
  51232. * Texture containing both the metallic value in the B channel and the
  51233. * roughness value in the G channel to keep better precision.
  51234. */
  51235. metallicRoughnessTexture: BaseTexture;
  51236. /**
  51237. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51238. *
  51239. * @param name The material name
  51240. * @param scene The scene the material will be use in.
  51241. */
  51242. constructor(name: string, scene: Scene);
  51243. /**
  51244. * Return the currrent class name of the material.
  51245. */
  51246. getClassName(): string;
  51247. /**
  51248. * Makes a duplicate of the current material.
  51249. * @param name - name to use for the new material.
  51250. */
  51251. clone(name: string): PBRMetallicRoughnessMaterial;
  51252. /**
  51253. * Serialize the material to a parsable JSON object.
  51254. */
  51255. serialize(): any;
  51256. /**
  51257. * Parses a JSON object correponding to the serialize function.
  51258. */
  51259. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51260. }
  51261. }
  51262. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51263. import { Scene } from "babylonjs/scene";
  51264. import { Color3 } from "babylonjs/Maths/math";
  51265. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51266. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51267. /**
  51268. * The PBR material of BJS following the specular glossiness convention.
  51269. *
  51270. * This fits to the PBR convention in the GLTF definition:
  51271. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51272. */
  51273. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51274. /**
  51275. * Specifies the diffuse color of the material.
  51276. */
  51277. diffuseColor: Color3;
  51278. /**
  51279. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51280. * channel.
  51281. */
  51282. diffuseTexture: BaseTexture;
  51283. /**
  51284. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51285. */
  51286. specularColor: Color3;
  51287. /**
  51288. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51289. */
  51290. glossiness: number;
  51291. /**
  51292. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51293. */
  51294. specularGlossinessTexture: BaseTexture;
  51295. /**
  51296. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51297. *
  51298. * @param name The material name
  51299. * @param scene The scene the material will be use in.
  51300. */
  51301. constructor(name: string, scene: Scene);
  51302. /**
  51303. * Return the currrent class name of the material.
  51304. */
  51305. getClassName(): string;
  51306. /**
  51307. * Makes a duplicate of the current material.
  51308. * @param name - name to use for the new material.
  51309. */
  51310. clone(name: string): PBRSpecularGlossinessMaterial;
  51311. /**
  51312. * Serialize the material to a parsable JSON object.
  51313. */
  51314. serialize(): any;
  51315. /**
  51316. * Parses a JSON object correponding to the serialize function.
  51317. */
  51318. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51319. }
  51320. }
  51321. declare module "babylonjs/Materials/PBR/index" {
  51322. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51323. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51324. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51325. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51326. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51327. }
  51328. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51329. import { Nullable } from "babylonjs/types";
  51330. import { Scene } from "babylonjs/scene";
  51331. import { Matrix } from "babylonjs/Maths/math";
  51332. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51333. /**
  51334. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51335. * It can help converting any input color in a desired output one. This can then be used to create effects
  51336. * from sepia, black and white to sixties or futuristic rendering...
  51337. *
  51338. * The only supported format is currently 3dl.
  51339. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51340. */
  51341. export class ColorGradingTexture extends BaseTexture {
  51342. /**
  51343. * The current texture matrix. (will always be identity in color grading texture)
  51344. */
  51345. private _textureMatrix;
  51346. /**
  51347. * The texture URL.
  51348. */
  51349. url: string;
  51350. /**
  51351. * Empty line regex stored for GC.
  51352. */
  51353. private static _noneEmptyLineRegex;
  51354. private _engine;
  51355. /**
  51356. * Instantiates a ColorGradingTexture from the following parameters.
  51357. *
  51358. * @param url The location of the color gradind data (currently only supporting 3dl)
  51359. * @param scene The scene the texture will be used in
  51360. */
  51361. constructor(url: string, scene: Scene);
  51362. /**
  51363. * Returns the texture matrix used in most of the material.
  51364. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51365. */
  51366. getTextureMatrix(): Matrix;
  51367. /**
  51368. * Occurs when the file being loaded is a .3dl LUT file.
  51369. */
  51370. private load3dlTexture;
  51371. /**
  51372. * Starts the loading process of the texture.
  51373. */
  51374. private loadTexture;
  51375. /**
  51376. * Clones the color gradind texture.
  51377. */
  51378. clone(): ColorGradingTexture;
  51379. /**
  51380. * Called during delayed load for textures.
  51381. */
  51382. delayLoad(): void;
  51383. /**
  51384. * Parses a color grading texture serialized by Babylon.
  51385. * @param parsedTexture The texture information being parsedTexture
  51386. * @param scene The scene to load the texture in
  51387. * @param rootUrl The root url of the data assets to load
  51388. * @return A color gradind texture
  51389. */
  51390. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51391. /**
  51392. * Serializes the LUT texture to json format.
  51393. */
  51394. serialize(): any;
  51395. }
  51396. }
  51397. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51399. import { Scene } from "babylonjs/scene";
  51400. import { Nullable } from "babylonjs/types";
  51401. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51402. /**
  51403. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51404. */
  51405. export class EquiRectangularCubeTexture extends BaseTexture {
  51406. /** The six faces of the cube. */
  51407. private static _FacesMapping;
  51408. private _noMipmap;
  51409. private _onLoad;
  51410. private _onError;
  51411. /** The size of the cubemap. */
  51412. private _size;
  51413. /** The buffer of the image. */
  51414. private _buffer;
  51415. /** The width of the input image. */
  51416. private _width;
  51417. /** The height of the input image. */
  51418. private _height;
  51419. /** The URL to the image. */
  51420. url: string;
  51421. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51422. coordinatesMode: number;
  51423. /**
  51424. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51425. * @param url The location of the image
  51426. * @param scene The scene the texture will be used in
  51427. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51428. * @param noMipmap Forces to not generate the mipmap if true
  51429. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51430. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51431. * @param onLoad — defines a callback called when texture is loaded
  51432. * @param onError — defines a callback called if there is an error
  51433. */
  51434. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51435. /**
  51436. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51437. */
  51438. private loadImage;
  51439. /**
  51440. * Convert the image buffer into a cubemap and create a CubeTexture.
  51441. */
  51442. private loadTexture;
  51443. /**
  51444. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51445. * @param buffer The ArrayBuffer that should be converted.
  51446. * @returns The buffer as Float32Array.
  51447. */
  51448. private getFloat32ArrayFromArrayBuffer;
  51449. /**
  51450. * Get the current class name of the texture useful for serialization or dynamic coding.
  51451. * @returns "EquiRectangularCubeTexture"
  51452. */
  51453. getClassName(): string;
  51454. /**
  51455. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51456. * @returns A clone of the current EquiRectangularCubeTexture.
  51457. */
  51458. clone(): EquiRectangularCubeTexture;
  51459. }
  51460. }
  51461. declare module "babylonjs/Misc/tga" {
  51462. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51463. /**
  51464. * Based on jsTGALoader - Javascript loader for TGA file
  51465. * By Vincent Thibault
  51466. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51467. */
  51468. export class TGATools {
  51469. private static _TYPE_INDEXED;
  51470. private static _TYPE_RGB;
  51471. private static _TYPE_GREY;
  51472. private static _TYPE_RLE_INDEXED;
  51473. private static _TYPE_RLE_RGB;
  51474. private static _TYPE_RLE_GREY;
  51475. private static _ORIGIN_MASK;
  51476. private static _ORIGIN_SHIFT;
  51477. private static _ORIGIN_BL;
  51478. private static _ORIGIN_BR;
  51479. private static _ORIGIN_UL;
  51480. private static _ORIGIN_UR;
  51481. /**
  51482. * Gets the header of a TGA file
  51483. * @param data defines the TGA data
  51484. * @returns the header
  51485. */
  51486. static GetTGAHeader(data: Uint8Array): any;
  51487. /**
  51488. * Uploads TGA content to a Babylon Texture
  51489. * @hidden
  51490. */
  51491. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51492. /** @hidden */
  51493. 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;
  51494. /** @hidden */
  51495. 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;
  51496. /** @hidden */
  51497. 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;
  51498. /** @hidden */
  51499. 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;
  51500. /** @hidden */
  51501. 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;
  51502. /** @hidden */
  51503. 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;
  51504. }
  51505. }
  51506. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51507. import { Nullable } from "babylonjs/types";
  51508. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51509. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51510. /**
  51511. * Implementation of the TGA Texture Loader.
  51512. * @hidden
  51513. */
  51514. export class _TGATextureLoader implements IInternalTextureLoader {
  51515. /**
  51516. * Defines wether the loader supports cascade loading the different faces.
  51517. */
  51518. readonly supportCascades: boolean;
  51519. /**
  51520. * This returns if the loader support the current file information.
  51521. * @param extension defines the file extension of the file being loaded
  51522. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51523. * @param fallback defines the fallback internal texture if any
  51524. * @param isBase64 defines whether the texture is encoded as a base64
  51525. * @param isBuffer defines whether the texture data are stored as a buffer
  51526. * @returns true if the loader can load the specified file
  51527. */
  51528. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51529. /**
  51530. * Transform the url before loading if required.
  51531. * @param rootUrl the url of the texture
  51532. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51533. * @returns the transformed texture
  51534. */
  51535. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51536. /**
  51537. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51538. * @param rootUrl the url of the texture
  51539. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51540. * @returns the fallback texture
  51541. */
  51542. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51543. /**
  51544. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51545. * @param data contains the texture data
  51546. * @param texture defines the BabylonJS internal texture
  51547. * @param createPolynomials will be true if polynomials have been requested
  51548. * @param onLoad defines the callback to trigger once the texture is ready
  51549. * @param onError defines the callback to trigger in case of error
  51550. */
  51551. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51552. /**
  51553. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51554. * @param data contains the texture data
  51555. * @param texture defines the BabylonJS internal texture
  51556. * @param callback defines the method to call once ready to upload
  51557. */
  51558. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51559. }
  51560. }
  51561. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51562. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51563. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51564. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51565. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51566. }
  51567. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51568. import { Scene } from "babylonjs/scene";
  51569. import { Texture } from "babylonjs/Materials/Textures/texture";
  51570. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51571. /**
  51572. * 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.
  51573. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51574. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51575. */
  51576. export class CustomProceduralTexture extends ProceduralTexture {
  51577. private _animate;
  51578. private _time;
  51579. private _config;
  51580. private _texturePath;
  51581. /**
  51582. * Instantiates a new Custom Procedural Texture.
  51583. * 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.
  51584. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51585. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51586. * @param name Define the name of the texture
  51587. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51588. * @param size Define the size of the texture to create
  51589. * @param scene Define the scene the texture belongs to
  51590. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51591. * @param generateMipMaps Define if the texture should creates mip maps or not
  51592. */
  51593. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51594. private _loadJson;
  51595. /**
  51596. * Is the texture ready to be used ? (rendered at least once)
  51597. * @returns true if ready, otherwise, false.
  51598. */
  51599. isReady(): boolean;
  51600. /**
  51601. * Render the texture to its associated render target.
  51602. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51603. */
  51604. render(useCameraPostProcess?: boolean): void;
  51605. /**
  51606. * Update the list of dependant textures samplers in the shader.
  51607. */
  51608. updateTextures(): void;
  51609. /**
  51610. * Update the uniform values of the procedural texture in the shader.
  51611. */
  51612. updateShaderUniforms(): void;
  51613. /**
  51614. * Define if the texture animates or not.
  51615. */
  51616. animate: boolean;
  51617. }
  51618. }
  51619. declare module "babylonjs/Shaders/noise.fragment" {
  51620. /** @hidden */
  51621. export var noisePixelShader: {
  51622. name: string;
  51623. shader: string;
  51624. };
  51625. }
  51626. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51627. import { Nullable } from "babylonjs/types";
  51628. import { Scene } from "babylonjs/scene";
  51629. import { Texture } from "babylonjs/Materials/Textures/texture";
  51630. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51631. import "babylonjs/Shaders/noise.fragment";
  51632. /**
  51633. * Class used to generate noise procedural textures
  51634. */
  51635. export class NoiseProceduralTexture extends ProceduralTexture {
  51636. private _time;
  51637. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51638. brightness: number;
  51639. /** Defines the number of octaves to process */
  51640. octaves: number;
  51641. /** Defines the level of persistence (0.8 by default) */
  51642. persistence: number;
  51643. /** Gets or sets animation speed factor (default is 1) */
  51644. animationSpeedFactor: number;
  51645. /**
  51646. * Creates a new NoiseProceduralTexture
  51647. * @param name defines the name fo the texture
  51648. * @param size defines the size of the texture (default is 256)
  51649. * @param scene defines the hosting scene
  51650. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51651. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51652. */
  51653. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51654. private _updateShaderUniforms;
  51655. protected _getDefines(): string;
  51656. /** Generate the current state of the procedural texture */
  51657. render(useCameraPostProcess?: boolean): void;
  51658. /**
  51659. * Serializes this noise procedural texture
  51660. * @returns a serialized noise procedural texture object
  51661. */
  51662. serialize(): any;
  51663. /**
  51664. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51665. * @param parsedTexture defines parsed texture data
  51666. * @param scene defines the current scene
  51667. * @param rootUrl defines the root URL containing noise procedural texture information
  51668. * @returns a parsed NoiseProceduralTexture
  51669. */
  51670. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51671. }
  51672. }
  51673. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51674. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51675. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51676. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51677. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51678. }
  51679. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51680. import { Nullable } from "babylonjs/types";
  51681. import { Scene } from "babylonjs/scene";
  51682. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51683. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51684. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51685. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51686. /**
  51687. * Raw cube texture where the raw buffers are passed in
  51688. */
  51689. export class RawCubeTexture extends CubeTexture {
  51690. /**
  51691. * Creates a cube texture where the raw buffers are passed in.
  51692. * @param scene defines the scene the texture is attached to
  51693. * @param data defines the array of data to use to create each face
  51694. * @param size defines the size of the textures
  51695. * @param format defines the format of the data
  51696. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51697. * @param generateMipMaps defines if the engine should generate the mip levels
  51698. * @param invertY defines if data must be stored with Y axis inverted
  51699. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51700. * @param compression defines the compression used (null by default)
  51701. */
  51702. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51703. /**
  51704. * Updates the raw cube texture.
  51705. * @param data defines the data to store
  51706. * @param format defines the data format
  51707. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51708. * @param invertY defines if data must be stored with Y axis inverted
  51709. * @param compression defines the compression used (null by default)
  51710. * @param level defines which level of the texture to update
  51711. */
  51712. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51713. /**
  51714. * Updates a raw cube texture with RGBD encoded data.
  51715. * @param data defines the array of data [mipmap][face] to use to create each face
  51716. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51717. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51718. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51719. * @returns a promsie that resolves when the operation is complete
  51720. */
  51721. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51722. /**
  51723. * Clones the raw cube texture.
  51724. * @return a new cube texture
  51725. */
  51726. clone(): CubeTexture;
  51727. /** @hidden */
  51728. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51729. }
  51730. }
  51731. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51732. import { Scene } from "babylonjs/scene";
  51733. import { Texture } from "babylonjs/Materials/Textures/texture";
  51734. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51735. /**
  51736. * Class used to store 3D textures containing user data
  51737. */
  51738. export class RawTexture3D extends Texture {
  51739. /** Gets or sets the texture format to use */
  51740. format: number;
  51741. private _engine;
  51742. /**
  51743. * Create a new RawTexture3D
  51744. * @param data defines the data of the texture
  51745. * @param width defines the width of the texture
  51746. * @param height defines the height of the texture
  51747. * @param depth defines the depth of the texture
  51748. * @param format defines the texture format to use
  51749. * @param scene defines the hosting scene
  51750. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51751. * @param invertY defines if texture must be stored with Y axis inverted
  51752. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51753. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51754. */
  51755. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51756. /** Gets or sets the texture format to use */
  51757. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51758. /**
  51759. * Update the texture with new data
  51760. * @param data defines the data to store in the texture
  51761. */
  51762. update(data: ArrayBufferView): void;
  51763. }
  51764. }
  51765. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51766. import { Scene } from "babylonjs/scene";
  51767. import { Plane } from "babylonjs/Maths/math";
  51768. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51769. /**
  51770. * Creates a refraction texture used by refraction channel of the standard material.
  51771. * It is like a mirror but to see through a material.
  51772. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51773. */
  51774. export class RefractionTexture extends RenderTargetTexture {
  51775. /**
  51776. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51777. * 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.
  51778. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51779. */
  51780. refractionPlane: Plane;
  51781. /**
  51782. * Define how deep under the surface we should see.
  51783. */
  51784. depth: number;
  51785. /**
  51786. * Creates a refraction texture used by refraction channel of the standard material.
  51787. * It is like a mirror but to see through a material.
  51788. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51789. * @param name Define the texture name
  51790. * @param size Define the size of the underlying texture
  51791. * @param scene Define the scene the refraction belongs to
  51792. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51793. */
  51794. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51795. /**
  51796. * Clone the refraction texture.
  51797. * @returns the cloned texture
  51798. */
  51799. clone(): RefractionTexture;
  51800. /**
  51801. * Serialize the texture to a JSON representation you could use in Parse later on
  51802. * @returns the serialized JSON representation
  51803. */
  51804. serialize(): any;
  51805. }
  51806. }
  51807. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51808. import { Nullable } from "babylonjs/types";
  51809. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51810. import { Matrix } from "babylonjs/Maths/math";
  51811. import { Engine } from "babylonjs/Engines/engine";
  51812. import { Scene } from "babylonjs/scene";
  51813. /**
  51814. * Defines the options related to the creation of an HtmlElementTexture
  51815. */
  51816. export interface IHtmlElementTextureOptions {
  51817. /**
  51818. * Defines wether mip maps should be created or not.
  51819. */
  51820. generateMipMaps?: boolean;
  51821. /**
  51822. * Defines the sampling mode of the texture.
  51823. */
  51824. samplingMode?: number;
  51825. /**
  51826. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51827. */
  51828. engine: Nullable<Engine>;
  51829. /**
  51830. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51831. */
  51832. scene: Nullable<Scene>;
  51833. }
  51834. /**
  51835. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51836. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51837. * is automatically managed.
  51838. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51839. * in your application.
  51840. *
  51841. * As the update is not automatic, you need to call them manually.
  51842. */
  51843. export class HtmlElementTexture extends BaseTexture {
  51844. /**
  51845. * The texture URL.
  51846. */
  51847. element: HTMLVideoElement | HTMLCanvasElement;
  51848. private static readonly DefaultOptions;
  51849. private _textureMatrix;
  51850. private _engine;
  51851. private _isVideo;
  51852. private _generateMipMaps;
  51853. private _samplingMode;
  51854. /**
  51855. * Instantiates a HtmlElementTexture from the following parameters.
  51856. *
  51857. * @param name Defines the name of the texture
  51858. * @param element Defines the video or canvas the texture is filled with
  51859. * @param options Defines the other none mandatory texture creation options
  51860. */
  51861. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51862. private _createInternalTexture;
  51863. /**
  51864. * Returns the texture matrix used in most of the material.
  51865. */
  51866. getTextureMatrix(): Matrix;
  51867. /**
  51868. * Updates the content of the texture.
  51869. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51870. */
  51871. update(invertY?: Nullable<boolean>): void;
  51872. }
  51873. }
  51874. declare module "babylonjs/Materials/Textures/index" {
  51875. export * from "babylonjs/Materials/Textures/baseTexture";
  51876. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51877. export * from "babylonjs/Materials/Textures/cubeTexture";
  51878. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51879. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51880. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51881. export * from "babylonjs/Materials/Textures/internalTexture";
  51882. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51883. export * from "babylonjs/Materials/Textures/Loaders/index";
  51884. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51885. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51886. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51887. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51888. export * from "babylonjs/Materials/Textures/rawTexture";
  51889. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51890. export * from "babylonjs/Materials/Textures/refractionTexture";
  51891. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51892. export * from "babylonjs/Materials/Textures/texture";
  51893. export * from "babylonjs/Materials/Textures/videoTexture";
  51894. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51895. }
  51896. declare module "babylonjs/Materials/index" {
  51897. export * from "babylonjs/Materials/Background/index";
  51898. export * from "babylonjs/Materials/colorCurves";
  51899. export * from "babylonjs/Materials/effect";
  51900. export * from "babylonjs/Materials/fresnelParameters";
  51901. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51902. export * from "babylonjs/Materials/material";
  51903. export * from "babylonjs/Materials/materialDefines";
  51904. export * from "babylonjs/Materials/materialHelper";
  51905. export * from "babylonjs/Materials/multiMaterial";
  51906. export * from "babylonjs/Materials/PBR/index";
  51907. export * from "babylonjs/Materials/pushMaterial";
  51908. export * from "babylonjs/Materials/shaderMaterial";
  51909. export * from "babylonjs/Materials/standardMaterial";
  51910. export * from "babylonjs/Materials/Textures/index";
  51911. export * from "babylonjs/Materials/uniformBuffer";
  51912. export * from "babylonjs/Materials/materialFlags";
  51913. }
  51914. declare module "babylonjs/Maths/index" {
  51915. export * from "babylonjs/Maths/math.scalar";
  51916. export * from "babylonjs/Maths/math";
  51917. export * from "babylonjs/Maths/sphericalPolynomial";
  51918. }
  51919. declare module "babylonjs/Misc/workerPool" {
  51920. import { IDisposable } from "babylonjs/scene";
  51921. /**
  51922. * Helper class to push actions to a pool of workers.
  51923. */
  51924. export class WorkerPool implements IDisposable {
  51925. private _workerInfos;
  51926. private _pendingActions;
  51927. /**
  51928. * Constructor
  51929. * @param workers Array of workers to use for actions
  51930. */
  51931. constructor(workers: Array<Worker>);
  51932. /**
  51933. * Terminates all workers and clears any pending actions.
  51934. */
  51935. dispose(): void;
  51936. /**
  51937. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51938. * pended until a worker has completed its action.
  51939. * @param action The action to perform. Call onComplete when the action is complete.
  51940. */
  51941. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51942. private _execute;
  51943. }
  51944. }
  51945. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51946. import { IDisposable } from "babylonjs/scene";
  51947. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51948. /**
  51949. * Configuration for Draco compression
  51950. */
  51951. export interface IDracoCompressionConfiguration {
  51952. /**
  51953. * Configuration for the decoder.
  51954. */
  51955. decoder?: {
  51956. /**
  51957. * The url to the WebAssembly module.
  51958. */
  51959. wasmUrl?: string;
  51960. /**
  51961. * The url to the WebAssembly binary.
  51962. */
  51963. wasmBinaryUrl?: string;
  51964. /**
  51965. * The url to the fallback JavaScript module.
  51966. */
  51967. fallbackUrl?: string;
  51968. };
  51969. }
  51970. /**
  51971. * Draco compression (https://google.github.io/draco/)
  51972. *
  51973. * This class wraps the Draco module.
  51974. *
  51975. * **Encoder**
  51976. *
  51977. * The encoder is not currently implemented.
  51978. *
  51979. * **Decoder**
  51980. *
  51981. * 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.
  51982. *
  51983. * To update the configuration, use the following code:
  51984. * ```javascript
  51985. * DracoCompression.Configuration = {
  51986. * decoder: {
  51987. * wasmUrl: "<url to the WebAssembly library>",
  51988. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51989. * fallbackUrl: "<url to the fallback JavaScript library>",
  51990. * }
  51991. * };
  51992. * ```
  51993. *
  51994. * 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.
  51995. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51996. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51997. *
  51998. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51999. * ```javascript
  52000. * var dracoCompression = new DracoCompression();
  52001. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  52002. * [VertexBuffer.PositionKind]: 0
  52003. * });
  52004. * ```
  52005. *
  52006. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52007. */
  52008. export class DracoCompression implements IDisposable {
  52009. private _workerPoolPromise;
  52010. /**
  52011. * The configuration. Defaults to the following urls:
  52012. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52013. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52014. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52015. */
  52016. static Configuration: IDracoCompressionConfiguration;
  52017. /**
  52018. * Returns true if the decoder is available.
  52019. */
  52020. static readonly DecoderAvailable: boolean;
  52021. /**
  52022. * Default number of workers to create when creating the draco compression object.
  52023. */
  52024. static DefaultNumWorkers: number;
  52025. private static GetDefaultNumWorkers;
  52026. private static _Default;
  52027. /**
  52028. * Default instance for the draco compression object.
  52029. */
  52030. static readonly Default: DracoCompression;
  52031. /**
  52032. * Constructor
  52033. * @param numWorkers The number of workers for async operations
  52034. */
  52035. constructor(numWorkers?: number);
  52036. /**
  52037. * Stop all async operations and release resources.
  52038. */
  52039. dispose(): void;
  52040. /**
  52041. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52042. * @returns a promise that resolves when ready
  52043. */
  52044. whenReadyAsync(): Promise<void>;
  52045. /**
  52046. * Decode Draco compressed mesh data to vertex data.
  52047. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52048. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52049. * @returns A promise that resolves with the decoded vertex data
  52050. */
  52051. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52052. [kind: string]: number;
  52053. }): Promise<VertexData>;
  52054. /**
  52055. * The worker function that gets converted to a blob url to pass into a worker.
  52056. */
  52057. private static _Worker;
  52058. private _loadDecoderWasmBinaryAsync;
  52059. }
  52060. }
  52061. declare module "babylonjs/Meshes/Compression/index" {
  52062. export * from "babylonjs/Meshes/Compression/dracoCompression";
  52063. }
  52064. declare module "babylonjs/Meshes/csg" {
  52065. import { Nullable } from "babylonjs/types";
  52066. import { Scene } from "babylonjs/scene";
  52067. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  52068. import { Mesh } from "babylonjs/Meshes/mesh";
  52069. import { Material } from "babylonjs/Materials/material";
  52070. /**
  52071. * Class for building Constructive Solid Geometry
  52072. */
  52073. export class CSG {
  52074. private polygons;
  52075. /**
  52076. * The world matrix
  52077. */
  52078. matrix: Matrix;
  52079. /**
  52080. * Stores the position
  52081. */
  52082. position: Vector3;
  52083. /**
  52084. * Stores the rotation
  52085. */
  52086. rotation: Vector3;
  52087. /**
  52088. * Stores the rotation quaternion
  52089. */
  52090. rotationQuaternion: Nullable<Quaternion>;
  52091. /**
  52092. * Stores the scaling vector
  52093. */
  52094. scaling: Vector3;
  52095. /**
  52096. * Convert the Mesh to CSG
  52097. * @param mesh The Mesh to convert to CSG
  52098. * @returns A new CSG from the Mesh
  52099. */
  52100. static FromMesh(mesh: Mesh): CSG;
  52101. /**
  52102. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52103. * @param polygons Polygons used to construct a CSG solid
  52104. */
  52105. private static FromPolygons;
  52106. /**
  52107. * Clones, or makes a deep copy, of the CSG
  52108. * @returns A new CSG
  52109. */
  52110. clone(): CSG;
  52111. /**
  52112. * Unions this CSG with another CSG
  52113. * @param csg The CSG to union against this CSG
  52114. * @returns The unioned CSG
  52115. */
  52116. union(csg: CSG): CSG;
  52117. /**
  52118. * Unions this CSG with another CSG in place
  52119. * @param csg The CSG to union against this CSG
  52120. */
  52121. unionInPlace(csg: CSG): void;
  52122. /**
  52123. * Subtracts this CSG with another CSG
  52124. * @param csg The CSG to subtract against this CSG
  52125. * @returns A new CSG
  52126. */
  52127. subtract(csg: CSG): CSG;
  52128. /**
  52129. * Subtracts this CSG with another CSG in place
  52130. * @param csg The CSG to subtact against this CSG
  52131. */
  52132. subtractInPlace(csg: CSG): void;
  52133. /**
  52134. * Intersect this CSG with another CSG
  52135. * @param csg The CSG to intersect against this CSG
  52136. * @returns A new CSG
  52137. */
  52138. intersect(csg: CSG): CSG;
  52139. /**
  52140. * Intersects this CSG with another CSG in place
  52141. * @param csg The CSG to intersect against this CSG
  52142. */
  52143. intersectInPlace(csg: CSG): void;
  52144. /**
  52145. * Return a new CSG solid with solid and empty space switched. This solid is
  52146. * not modified.
  52147. * @returns A new CSG solid with solid and empty space switched
  52148. */
  52149. inverse(): CSG;
  52150. /**
  52151. * Inverses the CSG in place
  52152. */
  52153. inverseInPlace(): void;
  52154. /**
  52155. * This is used to keep meshes transformations so they can be restored
  52156. * when we build back a Babylon Mesh
  52157. * NB : All CSG operations are performed in world coordinates
  52158. * @param csg The CSG to copy the transform attributes from
  52159. * @returns This CSG
  52160. */
  52161. copyTransformAttributes(csg: CSG): CSG;
  52162. /**
  52163. * Build Raw mesh from CSG
  52164. * Coordinates here are in world space
  52165. * @param name The name of the mesh geometry
  52166. * @param scene The Scene
  52167. * @param keepSubMeshes Specifies if the submeshes should be kept
  52168. * @returns A new Mesh
  52169. */
  52170. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52171. /**
  52172. * Build Mesh from CSG taking material and transforms into account
  52173. * @param name The name of the Mesh
  52174. * @param material The material of the Mesh
  52175. * @param scene The Scene
  52176. * @param keepSubMeshes Specifies if submeshes should be kept
  52177. * @returns The new Mesh
  52178. */
  52179. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52180. }
  52181. }
  52182. declare module "babylonjs/Meshes/trailMesh" {
  52183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52184. import { Mesh } from "babylonjs/Meshes/mesh";
  52185. import { Scene } from "babylonjs/scene";
  52186. /**
  52187. * Class used to create a trail following a mesh
  52188. */
  52189. export class TrailMesh extends Mesh {
  52190. private _generator;
  52191. private _autoStart;
  52192. private _running;
  52193. private _diameter;
  52194. private _length;
  52195. private _sectionPolygonPointsCount;
  52196. private _sectionVectors;
  52197. private _sectionNormalVectors;
  52198. private _beforeRenderObserver;
  52199. /**
  52200. * @constructor
  52201. * @param name The value used by scene.getMeshByName() to do a lookup.
  52202. * @param generator The mesh to generate a trail.
  52203. * @param scene The scene to add this mesh to.
  52204. * @param diameter Diameter of trailing mesh. Default is 1.
  52205. * @param length Length of trailing mesh. Default is 60.
  52206. * @param autoStart Automatically start trailing mesh. Default true.
  52207. */
  52208. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52209. /**
  52210. * "TrailMesh"
  52211. * @returns "TrailMesh"
  52212. */
  52213. getClassName(): string;
  52214. private _createMesh;
  52215. /**
  52216. * Start trailing mesh.
  52217. */
  52218. start(): void;
  52219. /**
  52220. * Stop trailing mesh.
  52221. */
  52222. stop(): void;
  52223. /**
  52224. * Update trailing mesh geometry.
  52225. */
  52226. update(): void;
  52227. /**
  52228. * Returns a new TrailMesh object.
  52229. * @param name is a string, the name given to the new mesh
  52230. * @param newGenerator use new generator object for cloned trail mesh
  52231. * @returns a new mesh
  52232. */
  52233. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52234. /**
  52235. * Serializes this trail mesh
  52236. * @param serializationObject object to write serialization to
  52237. */
  52238. serialize(serializationObject: any): void;
  52239. /**
  52240. * Parses a serialized trail mesh
  52241. * @param parsedMesh the serialized mesh
  52242. * @param scene the scene to create the trail mesh in
  52243. * @returns the created trail mesh
  52244. */
  52245. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52246. }
  52247. }
  52248. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52249. import { Vector4 } from "babylonjs/Maths/math";
  52250. import { Mesh } from "babylonjs/Meshes/mesh";
  52251. /**
  52252. * Class containing static functions to help procedurally build meshes
  52253. */
  52254. export class TorusKnotBuilder {
  52255. /**
  52256. * Creates a torus knot mesh
  52257. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52258. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52259. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52260. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52264. * @param name defines the name of the mesh
  52265. * @param options defines the options used to create the mesh
  52266. * @param scene defines the hosting scene
  52267. * @returns the torus knot mesh
  52268. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52269. */
  52270. static CreateTorusKnot(name: string, options: {
  52271. radius?: number;
  52272. tube?: number;
  52273. radialSegments?: number;
  52274. tubularSegments?: number;
  52275. p?: number;
  52276. q?: number;
  52277. updatable?: boolean;
  52278. sideOrientation?: number;
  52279. frontUVs?: Vector4;
  52280. backUVs?: Vector4;
  52281. }, scene: any): Mesh;
  52282. }
  52283. }
  52284. declare module "babylonjs/Meshes/polygonMesh" {
  52285. import { Scene } from "babylonjs/scene";
  52286. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52287. import { Mesh } from "babylonjs/Meshes/mesh";
  52288. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52289. /**
  52290. * Polygon
  52291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52292. */
  52293. export class Polygon {
  52294. /**
  52295. * Creates a rectangle
  52296. * @param xmin bottom X coord
  52297. * @param ymin bottom Y coord
  52298. * @param xmax top X coord
  52299. * @param ymax top Y coord
  52300. * @returns points that make the resulting rectation
  52301. */
  52302. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52303. /**
  52304. * Creates a circle
  52305. * @param radius radius of circle
  52306. * @param cx scale in x
  52307. * @param cy scale in y
  52308. * @param numberOfSides number of sides that make up the circle
  52309. * @returns points that make the resulting circle
  52310. */
  52311. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52312. /**
  52313. * Creates a polygon from input string
  52314. * @param input Input polygon data
  52315. * @returns the parsed points
  52316. */
  52317. static Parse(input: string): Vector2[];
  52318. /**
  52319. * Starts building a polygon from x and y coordinates
  52320. * @param x x coordinate
  52321. * @param y y coordinate
  52322. * @returns the started path2
  52323. */
  52324. static StartingAt(x: number, y: number): Path2;
  52325. }
  52326. /**
  52327. * Builds a polygon
  52328. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52329. */
  52330. export class PolygonMeshBuilder {
  52331. private _points;
  52332. private _outlinepoints;
  52333. private _holes;
  52334. private _name;
  52335. private _scene;
  52336. private _epoints;
  52337. private _eholes;
  52338. private _addToepoint;
  52339. /**
  52340. * Babylon reference to the earcut plugin.
  52341. */
  52342. bjsEarcut: any;
  52343. /**
  52344. * Creates a PolygonMeshBuilder
  52345. * @param name name of the builder
  52346. * @param contours Path of the polygon
  52347. * @param scene scene to add to when creating the mesh
  52348. * @param earcutInjection can be used to inject your own earcut reference
  52349. */
  52350. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52351. /**
  52352. * Adds a whole within the polygon
  52353. * @param hole Array of points defining the hole
  52354. * @returns this
  52355. */
  52356. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52357. /**
  52358. * Creates the polygon
  52359. * @param updatable If the mesh should be updatable
  52360. * @param depth The depth of the mesh created
  52361. * @returns the created mesh
  52362. */
  52363. build(updatable?: boolean, depth?: number): Mesh;
  52364. /**
  52365. * Creates the polygon
  52366. * @param depth The depth of the mesh created
  52367. * @returns the created VertexData
  52368. */
  52369. buildVertexData(depth?: number): VertexData;
  52370. /**
  52371. * Adds a side to the polygon
  52372. * @param positions points that make the polygon
  52373. * @param normals normals of the polygon
  52374. * @param uvs uvs of the polygon
  52375. * @param indices indices of the polygon
  52376. * @param bounds bounds of the polygon
  52377. * @param points points of the polygon
  52378. * @param depth depth of the polygon
  52379. * @param flip flip of the polygon
  52380. */
  52381. private addSide;
  52382. }
  52383. }
  52384. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52385. import { Scene } from "babylonjs/scene";
  52386. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52387. import { Mesh } from "babylonjs/Meshes/mesh";
  52388. import { Nullable } from "babylonjs/types";
  52389. /**
  52390. * Class containing static functions to help procedurally build meshes
  52391. */
  52392. export class PolygonBuilder {
  52393. /**
  52394. * Creates a polygon mesh
  52395. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52396. * * 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
  52397. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52400. * * Remember you can only change the shape positions, not their number when updating a polygon
  52401. * @param name defines the name of the mesh
  52402. * @param options defines the options used to create the mesh
  52403. * @param scene defines the hosting scene
  52404. * @param earcutInjection can be used to inject your own earcut reference
  52405. * @returns the polygon mesh
  52406. */
  52407. static CreatePolygon(name: string, options: {
  52408. shape: Vector3[];
  52409. holes?: Vector3[][];
  52410. depth?: number;
  52411. faceUV?: Vector4[];
  52412. faceColors?: Color4[];
  52413. updatable?: boolean;
  52414. sideOrientation?: number;
  52415. frontUVs?: Vector4;
  52416. backUVs?: Vector4;
  52417. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52418. /**
  52419. * Creates an extruded polygon mesh, with depth in the Y direction.
  52420. * * 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)
  52421. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52422. * @param name defines the name of the mesh
  52423. * @param options defines the options used to create the mesh
  52424. * @param scene defines the hosting scene
  52425. * @param earcutInjection can be used to inject your own earcut reference
  52426. * @returns the polygon mesh
  52427. */
  52428. static ExtrudePolygon(name: string, options: {
  52429. shape: Vector3[];
  52430. holes?: Vector3[][];
  52431. depth?: number;
  52432. faceUV?: Vector4[];
  52433. faceColors?: Color4[];
  52434. updatable?: boolean;
  52435. sideOrientation?: number;
  52436. frontUVs?: Vector4;
  52437. backUVs?: Vector4;
  52438. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52439. }
  52440. }
  52441. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52442. import { Scene } from "babylonjs/scene";
  52443. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52444. import { Mesh } from "babylonjs/Meshes/mesh";
  52445. import { Nullable } from "babylonjs/types";
  52446. /**
  52447. * Class containing static functions to help procedurally build meshes
  52448. */
  52449. export class LatheBuilder {
  52450. /**
  52451. * Creates lathe mesh.
  52452. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52453. * * 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
  52454. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52455. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52456. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52457. * * 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
  52458. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52459. * * 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
  52460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52462. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52464. * @param name defines the name of the mesh
  52465. * @param options defines the options used to create the mesh
  52466. * @param scene defines the hosting scene
  52467. * @returns the lathe mesh
  52468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52469. */
  52470. static CreateLathe(name: string, options: {
  52471. shape: Vector3[];
  52472. radius?: number;
  52473. tessellation?: number;
  52474. clip?: number;
  52475. arc?: number;
  52476. closed?: boolean;
  52477. updatable?: boolean;
  52478. sideOrientation?: number;
  52479. frontUVs?: Vector4;
  52480. backUVs?: Vector4;
  52481. cap?: number;
  52482. invertUV?: boolean;
  52483. }, scene?: Nullable<Scene>): Mesh;
  52484. }
  52485. }
  52486. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52487. import { Nullable } from "babylonjs/types";
  52488. import { Scene } from "babylonjs/scene";
  52489. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52490. import { Mesh } from "babylonjs/Meshes/mesh";
  52491. /**
  52492. * Class containing static functions to help procedurally build meshes
  52493. */
  52494. export class TubeBuilder {
  52495. /**
  52496. * Creates a tube mesh.
  52497. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52498. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52499. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52500. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52501. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52502. * * 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)
  52503. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52504. * * 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
  52505. * * 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
  52506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52508. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52510. * @param name defines the name of the mesh
  52511. * @param options defines the options used to create the mesh
  52512. * @param scene defines the hosting scene
  52513. * @returns the tube mesh
  52514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52515. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52516. */
  52517. static CreateTube(name: string, options: {
  52518. path: Vector3[];
  52519. radius?: number;
  52520. tessellation?: number;
  52521. radiusFunction?: {
  52522. (i: number, distance: number): number;
  52523. };
  52524. cap?: number;
  52525. arc?: number;
  52526. updatable?: boolean;
  52527. sideOrientation?: number;
  52528. frontUVs?: Vector4;
  52529. backUVs?: Vector4;
  52530. instance?: Mesh;
  52531. invertUV?: boolean;
  52532. }, scene?: Nullable<Scene>): Mesh;
  52533. }
  52534. }
  52535. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52536. import { Scene } from "babylonjs/scene";
  52537. import { Vector4 } from "babylonjs/Maths/math";
  52538. import { Mesh } from "babylonjs/Meshes/mesh";
  52539. import { Nullable } from "babylonjs/types";
  52540. /**
  52541. * Class containing static functions to help procedurally build meshes
  52542. */
  52543. export class IcoSphereBuilder {
  52544. /**
  52545. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52546. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52547. * * 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`)
  52548. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52549. * * 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
  52550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52553. * @param name defines the name of the mesh
  52554. * @param options defines the options used to create the mesh
  52555. * @param scene defines the hosting scene
  52556. * @returns the icosahedron mesh
  52557. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52558. */
  52559. static CreateIcoSphere(name: string, options: {
  52560. radius?: number;
  52561. radiusX?: number;
  52562. radiusY?: number;
  52563. radiusZ?: number;
  52564. flat?: boolean;
  52565. subdivisions?: number;
  52566. sideOrientation?: number;
  52567. frontUVs?: Vector4;
  52568. backUVs?: Vector4;
  52569. updatable?: boolean;
  52570. }, scene?: Nullable<Scene>): Mesh;
  52571. }
  52572. }
  52573. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52574. import { Vector3 } from "babylonjs/Maths/math";
  52575. import { Mesh } from "babylonjs/Meshes/mesh";
  52576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52577. /**
  52578. * Class containing static functions to help procedurally build meshes
  52579. */
  52580. export class DecalBuilder {
  52581. /**
  52582. * Creates a decal mesh.
  52583. * 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
  52584. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52585. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52586. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52587. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52588. * @param name defines the name of the mesh
  52589. * @param sourceMesh defines the mesh where the decal must be applied
  52590. * @param options defines the options used to create the mesh
  52591. * @param scene defines the hosting scene
  52592. * @returns the decal mesh
  52593. * @see https://doc.babylonjs.com/how_to/decals
  52594. */
  52595. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52596. position?: Vector3;
  52597. normal?: Vector3;
  52598. size?: Vector3;
  52599. angle?: number;
  52600. }): Mesh;
  52601. }
  52602. }
  52603. declare module "babylonjs/Meshes/meshBuilder" {
  52604. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52605. import { Nullable } from "babylonjs/types";
  52606. import { Scene } from "babylonjs/scene";
  52607. import { Mesh } from "babylonjs/Meshes/mesh";
  52608. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52609. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52611. /**
  52612. * Class containing static functions to help procedurally build meshes
  52613. */
  52614. export class MeshBuilder {
  52615. /**
  52616. * Creates a box mesh
  52617. * * The parameter `size` sets the size (float) of each box side (default 1)
  52618. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52619. * * 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)
  52620. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52624. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52625. * @param name defines the name of the mesh
  52626. * @param options defines the options used to create the mesh
  52627. * @param scene defines the hosting scene
  52628. * @returns the box mesh
  52629. */
  52630. static CreateBox(name: string, options: {
  52631. size?: number;
  52632. width?: number;
  52633. height?: number;
  52634. depth?: number;
  52635. faceUV?: Vector4[];
  52636. faceColors?: Color4[];
  52637. sideOrientation?: number;
  52638. frontUVs?: Vector4;
  52639. backUVs?: Vector4;
  52640. updatable?: boolean;
  52641. }, scene?: Nullable<Scene>): Mesh;
  52642. /**
  52643. * Creates a sphere mesh
  52644. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52645. * * 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`)
  52646. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52647. * * 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
  52648. * * 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)
  52649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52652. * @param name defines the name of the mesh
  52653. * @param options defines the options used to create the mesh
  52654. * @param scene defines the hosting scene
  52655. * @returns the sphere mesh
  52656. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52657. */
  52658. static CreateSphere(name: string, options: {
  52659. segments?: number;
  52660. diameter?: number;
  52661. diameterX?: number;
  52662. diameterY?: number;
  52663. diameterZ?: number;
  52664. arc?: number;
  52665. slice?: number;
  52666. sideOrientation?: number;
  52667. frontUVs?: Vector4;
  52668. backUVs?: Vector4;
  52669. updatable?: boolean;
  52670. }, scene?: Nullable<Scene>): Mesh;
  52671. /**
  52672. * Creates a plane polygonal mesh. By default, this is a disc
  52673. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52674. * * 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
  52675. * * 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
  52676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52679. * @param name defines the name of the mesh
  52680. * @param options defines the options used to create the mesh
  52681. * @param scene defines the hosting scene
  52682. * @returns the plane polygonal mesh
  52683. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52684. */
  52685. static CreateDisc(name: string, options: {
  52686. radius?: number;
  52687. tessellation?: number;
  52688. arc?: number;
  52689. updatable?: boolean;
  52690. sideOrientation?: number;
  52691. frontUVs?: Vector4;
  52692. backUVs?: Vector4;
  52693. }, scene?: Nullable<Scene>): Mesh;
  52694. /**
  52695. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52696. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52697. * * 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`)
  52698. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52699. * * 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
  52700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52703. * @param name defines the name of the mesh
  52704. * @param options defines the options used to create the mesh
  52705. * @param scene defines the hosting scene
  52706. * @returns the icosahedron mesh
  52707. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52708. */
  52709. static CreateIcoSphere(name: string, options: {
  52710. radius?: number;
  52711. radiusX?: number;
  52712. radiusY?: number;
  52713. radiusZ?: number;
  52714. flat?: boolean;
  52715. subdivisions?: number;
  52716. sideOrientation?: number;
  52717. frontUVs?: Vector4;
  52718. backUVs?: Vector4;
  52719. updatable?: boolean;
  52720. }, scene?: Nullable<Scene>): Mesh;
  52721. /**
  52722. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52723. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52724. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52725. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52726. * * 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
  52727. * * 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
  52728. * * 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
  52729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52731. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52732. * * 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
  52733. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52734. * * 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
  52735. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52737. * @param name defines the name of the mesh
  52738. * @param options defines the options used to create the mesh
  52739. * @param scene defines the hosting scene
  52740. * @returns the ribbon mesh
  52741. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52742. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52743. */
  52744. static CreateRibbon(name: string, options: {
  52745. pathArray: Vector3[][];
  52746. closeArray?: boolean;
  52747. closePath?: boolean;
  52748. offset?: number;
  52749. updatable?: boolean;
  52750. sideOrientation?: number;
  52751. frontUVs?: Vector4;
  52752. backUVs?: Vector4;
  52753. instance?: Mesh;
  52754. invertUV?: boolean;
  52755. uvs?: Vector2[];
  52756. colors?: Color4[];
  52757. }, scene?: Nullable<Scene>): Mesh;
  52758. /**
  52759. * Creates a cylinder or a cone mesh
  52760. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52761. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52762. * * 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.
  52763. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52764. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52765. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52766. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52767. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52768. * * 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).
  52769. * * 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
  52770. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52771. * * 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
  52772. * * 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.
  52773. * * If `enclose` is false, a ring surface is one element.
  52774. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52775. * * 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
  52776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52779. * @param name defines the name of the mesh
  52780. * @param options defines the options used to create the mesh
  52781. * @param scene defines the hosting scene
  52782. * @returns the cylinder mesh
  52783. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52784. */
  52785. static CreateCylinder(name: string, options: {
  52786. height?: number;
  52787. diameterTop?: number;
  52788. diameterBottom?: number;
  52789. diameter?: number;
  52790. tessellation?: number;
  52791. subdivisions?: number;
  52792. arc?: number;
  52793. faceColors?: Color4[];
  52794. faceUV?: Vector4[];
  52795. updatable?: boolean;
  52796. hasRings?: boolean;
  52797. enclose?: boolean;
  52798. sideOrientation?: number;
  52799. frontUVs?: Vector4;
  52800. backUVs?: Vector4;
  52801. }, scene?: Nullable<Scene>): Mesh;
  52802. /**
  52803. * Creates a torus mesh
  52804. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52805. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52806. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52808. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52810. * @param name defines the name of the mesh
  52811. * @param options defines the options used to create the mesh
  52812. * @param scene defines the hosting scene
  52813. * @returns the torus mesh
  52814. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52815. */
  52816. static CreateTorus(name: string, options: {
  52817. diameter?: number;
  52818. thickness?: number;
  52819. tessellation?: number;
  52820. updatable?: boolean;
  52821. sideOrientation?: number;
  52822. frontUVs?: Vector4;
  52823. backUVs?: Vector4;
  52824. }, scene?: Nullable<Scene>): Mesh;
  52825. /**
  52826. * Creates a torus knot mesh
  52827. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52828. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52829. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52830. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52832. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52834. * @param name defines the name of the mesh
  52835. * @param options defines the options used to create the mesh
  52836. * @param scene defines the hosting scene
  52837. * @returns the torus knot mesh
  52838. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52839. */
  52840. static CreateTorusKnot(name: string, options: {
  52841. radius?: number;
  52842. tube?: number;
  52843. radialSegments?: number;
  52844. tubularSegments?: number;
  52845. p?: number;
  52846. q?: number;
  52847. updatable?: boolean;
  52848. sideOrientation?: number;
  52849. frontUVs?: Vector4;
  52850. backUVs?: Vector4;
  52851. }, scene?: Nullable<Scene>): Mesh;
  52852. /**
  52853. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52854. * * 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
  52855. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52856. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52857. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52858. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52859. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52860. * * 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
  52861. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52864. * @param name defines the name of the new line system
  52865. * @param options defines the options used to create the line system
  52866. * @param scene defines the hosting scene
  52867. * @returns a new line system mesh
  52868. */
  52869. static CreateLineSystem(name: string, options: {
  52870. lines: Vector3[][];
  52871. updatable?: boolean;
  52872. instance?: Nullable<LinesMesh>;
  52873. colors?: Nullable<Color4[][]>;
  52874. useVertexAlpha?: boolean;
  52875. }, scene: Nullable<Scene>): LinesMesh;
  52876. /**
  52877. * Creates a line mesh
  52878. * 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
  52879. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52880. * * The parameter `points` is an array successive Vector3
  52881. * * 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
  52882. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52883. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52884. * * When updating an instance, remember that only point positions can change, not the number of points
  52885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52887. * @param name defines the name of the new line system
  52888. * @param options defines the options used to create the line system
  52889. * @param scene defines the hosting scene
  52890. * @returns a new line mesh
  52891. */
  52892. static CreateLines(name: string, options: {
  52893. points: Vector3[];
  52894. updatable?: boolean;
  52895. instance?: Nullable<LinesMesh>;
  52896. colors?: Color4[];
  52897. useVertexAlpha?: boolean;
  52898. }, scene?: Nullable<Scene>): LinesMesh;
  52899. /**
  52900. * Creates a dashed line mesh
  52901. * * 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
  52902. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52903. * * The parameter `points` is an array successive Vector3
  52904. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52905. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52906. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52907. * * 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
  52908. * * When updating an instance, remember that only point positions can change, not the number of points
  52909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52910. * @param name defines the name of the mesh
  52911. * @param options defines the options used to create the mesh
  52912. * @param scene defines the hosting scene
  52913. * @returns the dashed line mesh
  52914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52915. */
  52916. static CreateDashedLines(name: string, options: {
  52917. points: Vector3[];
  52918. dashSize?: number;
  52919. gapSize?: number;
  52920. dashNb?: number;
  52921. updatable?: boolean;
  52922. instance?: LinesMesh;
  52923. }, scene?: Nullable<Scene>): LinesMesh;
  52924. /**
  52925. * 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.
  52926. * * 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.
  52927. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52928. * * 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.
  52929. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52930. * * 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
  52931. * * 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
  52932. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52935. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52937. * @param name defines the name of the mesh
  52938. * @param options defines the options used to create the mesh
  52939. * @param scene defines the hosting scene
  52940. * @returns the extruded shape mesh
  52941. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52943. */
  52944. static ExtrudeShape(name: string, options: {
  52945. shape: Vector3[];
  52946. path: Vector3[];
  52947. scale?: number;
  52948. rotation?: number;
  52949. cap?: number;
  52950. updatable?: boolean;
  52951. sideOrientation?: number;
  52952. frontUVs?: Vector4;
  52953. backUVs?: Vector4;
  52954. instance?: Mesh;
  52955. invertUV?: boolean;
  52956. }, scene?: Nullable<Scene>): Mesh;
  52957. /**
  52958. * Creates an custom extruded shape mesh.
  52959. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52960. * * 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.
  52961. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52962. * * 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
  52963. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52964. * * 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
  52965. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52966. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52967. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52968. * * 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
  52969. * * 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
  52970. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52973. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52975. * @param name defines the name of the mesh
  52976. * @param options defines the options used to create the mesh
  52977. * @param scene defines the hosting scene
  52978. * @returns the custom extruded shape mesh
  52979. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52980. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52982. */
  52983. static ExtrudeShapeCustom(name: string, options: {
  52984. shape: Vector3[];
  52985. path: Vector3[];
  52986. scaleFunction?: any;
  52987. rotationFunction?: any;
  52988. ribbonCloseArray?: boolean;
  52989. ribbonClosePath?: boolean;
  52990. cap?: number;
  52991. updatable?: boolean;
  52992. sideOrientation?: number;
  52993. frontUVs?: Vector4;
  52994. backUVs?: Vector4;
  52995. instance?: Mesh;
  52996. invertUV?: boolean;
  52997. }, scene?: Nullable<Scene>): Mesh;
  52998. /**
  52999. * Creates lathe mesh.
  53000. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53001. * * 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
  53002. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53003. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53004. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53005. * * 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
  53006. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53007. * * 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
  53008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53010. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53012. * @param name defines the name of the mesh
  53013. * @param options defines the options used to create the mesh
  53014. * @param scene defines the hosting scene
  53015. * @returns the lathe mesh
  53016. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53017. */
  53018. static CreateLathe(name: string, options: {
  53019. shape: Vector3[];
  53020. radius?: number;
  53021. tessellation?: number;
  53022. clip?: number;
  53023. arc?: number;
  53024. closed?: boolean;
  53025. updatable?: boolean;
  53026. sideOrientation?: number;
  53027. frontUVs?: Vector4;
  53028. backUVs?: Vector4;
  53029. cap?: number;
  53030. invertUV?: boolean;
  53031. }, scene?: Nullable<Scene>): Mesh;
  53032. /**
  53033. * Creates a plane mesh
  53034. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53035. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53036. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53040. * @param name defines the name of the mesh
  53041. * @param options defines the options used to create the mesh
  53042. * @param scene defines the hosting scene
  53043. * @returns the plane mesh
  53044. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53045. */
  53046. static CreatePlane(name: string, options: {
  53047. size?: number;
  53048. width?: number;
  53049. height?: number;
  53050. sideOrientation?: number;
  53051. frontUVs?: Vector4;
  53052. backUVs?: Vector4;
  53053. updatable?: boolean;
  53054. sourcePlane?: Plane;
  53055. }, scene?: Nullable<Scene>): Mesh;
  53056. /**
  53057. * Creates a ground mesh
  53058. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53059. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53061. * @param name defines the name of the mesh
  53062. * @param options defines the options used to create the mesh
  53063. * @param scene defines the hosting scene
  53064. * @returns the ground mesh
  53065. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53066. */
  53067. static CreateGround(name: string, options: {
  53068. width?: number;
  53069. height?: number;
  53070. subdivisions?: number;
  53071. subdivisionsX?: number;
  53072. subdivisionsY?: number;
  53073. updatable?: boolean;
  53074. }, scene?: Nullable<Scene>): Mesh;
  53075. /**
  53076. * Creates a tiled ground mesh
  53077. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53078. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53079. * * 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
  53080. * * 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
  53081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53082. * @param name defines the name of the mesh
  53083. * @param options defines the options used to create the mesh
  53084. * @param scene defines the hosting scene
  53085. * @returns the tiled ground mesh
  53086. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53087. */
  53088. static CreateTiledGround(name: string, options: {
  53089. xmin: number;
  53090. zmin: number;
  53091. xmax: number;
  53092. zmax: number;
  53093. subdivisions?: {
  53094. w: number;
  53095. h: number;
  53096. };
  53097. precision?: {
  53098. w: number;
  53099. h: number;
  53100. };
  53101. updatable?: boolean;
  53102. }, scene?: Nullable<Scene>): Mesh;
  53103. /**
  53104. * Creates a ground mesh from a height map
  53105. * * The parameter `url` sets the URL of the height map image resource.
  53106. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53107. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53108. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53109. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53110. * * 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.
  53111. * * 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).
  53112. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53114. * @param name defines the name of the mesh
  53115. * @param url defines the url to the height map
  53116. * @param options defines the options used to create the mesh
  53117. * @param scene defines the hosting scene
  53118. * @returns the ground mesh
  53119. * @see https://doc.babylonjs.com/babylon101/height_map
  53120. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53121. */
  53122. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53123. width?: number;
  53124. height?: number;
  53125. subdivisions?: number;
  53126. minHeight?: number;
  53127. maxHeight?: number;
  53128. colorFilter?: Color3;
  53129. alphaFilter?: number;
  53130. updatable?: boolean;
  53131. onReady?: (mesh: GroundMesh) => void;
  53132. }, scene?: Nullable<Scene>): GroundMesh;
  53133. /**
  53134. * Creates a polygon mesh
  53135. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53136. * * 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
  53137. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53140. * * Remember you can only change the shape positions, not their number when updating a polygon
  53141. * @param name defines the name of the mesh
  53142. * @param options defines the options used to create the mesh
  53143. * @param scene defines the hosting scene
  53144. * @param earcutInjection can be used to inject your own earcut reference
  53145. * @returns the polygon mesh
  53146. */
  53147. static CreatePolygon(name: string, options: {
  53148. shape: Vector3[];
  53149. holes?: Vector3[][];
  53150. depth?: number;
  53151. faceUV?: Vector4[];
  53152. faceColors?: Color4[];
  53153. updatable?: boolean;
  53154. sideOrientation?: number;
  53155. frontUVs?: Vector4;
  53156. backUVs?: Vector4;
  53157. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53158. /**
  53159. * Creates an extruded polygon mesh, with depth in the Y direction.
  53160. * * 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)
  53161. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53162. * @param name defines the name of the mesh
  53163. * @param options defines the options used to create the mesh
  53164. * @param scene defines the hosting scene
  53165. * @param earcutInjection can be used to inject your own earcut reference
  53166. * @returns the polygon mesh
  53167. */
  53168. static ExtrudePolygon(name: string, options: {
  53169. shape: Vector3[];
  53170. holes?: Vector3[][];
  53171. depth?: number;
  53172. faceUV?: Vector4[];
  53173. faceColors?: Color4[];
  53174. updatable?: boolean;
  53175. sideOrientation?: number;
  53176. frontUVs?: Vector4;
  53177. backUVs?: Vector4;
  53178. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53179. /**
  53180. * Creates a tube mesh.
  53181. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53182. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53183. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53184. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53185. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53186. * * 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)
  53187. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53188. * * 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
  53189. * * 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
  53190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53192. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53194. * @param name defines the name of the mesh
  53195. * @param options defines the options used to create the mesh
  53196. * @param scene defines the hosting scene
  53197. * @returns the tube mesh
  53198. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53199. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53200. */
  53201. static CreateTube(name: string, options: {
  53202. path: Vector3[];
  53203. radius?: number;
  53204. tessellation?: number;
  53205. radiusFunction?: {
  53206. (i: number, distance: number): number;
  53207. };
  53208. cap?: number;
  53209. arc?: number;
  53210. updatable?: boolean;
  53211. sideOrientation?: number;
  53212. frontUVs?: Vector4;
  53213. backUVs?: Vector4;
  53214. instance?: Mesh;
  53215. invertUV?: boolean;
  53216. }, scene?: Nullable<Scene>): Mesh;
  53217. /**
  53218. * Creates a polyhedron mesh
  53219. * * 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
  53220. * * The parameter `size` (positive float, default 1) sets the polygon size
  53221. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53222. * * 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`
  53223. * * 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
  53224. * * 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)`)
  53225. * * 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
  53226. * * 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
  53227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53230. * @param name defines the name of the mesh
  53231. * @param options defines the options used to create the mesh
  53232. * @param scene defines the hosting scene
  53233. * @returns the polyhedron mesh
  53234. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53235. */
  53236. static CreatePolyhedron(name: string, options: {
  53237. type?: number;
  53238. size?: number;
  53239. sizeX?: number;
  53240. sizeY?: number;
  53241. sizeZ?: number;
  53242. custom?: any;
  53243. faceUV?: Vector4[];
  53244. faceColors?: Color4[];
  53245. flat?: boolean;
  53246. updatable?: boolean;
  53247. sideOrientation?: number;
  53248. frontUVs?: Vector4;
  53249. backUVs?: Vector4;
  53250. }, scene?: Nullable<Scene>): Mesh;
  53251. /**
  53252. * Creates a decal mesh.
  53253. * 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
  53254. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53255. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53256. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53257. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53258. * @param name defines the name of the mesh
  53259. * @param sourceMesh defines the mesh where the decal must be applied
  53260. * @param options defines the options used to create the mesh
  53261. * @param scene defines the hosting scene
  53262. * @returns the decal mesh
  53263. * @see https://doc.babylonjs.com/how_to/decals
  53264. */
  53265. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53266. position?: Vector3;
  53267. normal?: Vector3;
  53268. size?: Vector3;
  53269. angle?: number;
  53270. }): Mesh;
  53271. }
  53272. }
  53273. declare module "babylonjs/Meshes/meshSimplification" {
  53274. import { Mesh } from "babylonjs/Meshes/mesh";
  53275. /**
  53276. * A simplifier interface for future simplification implementations
  53277. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53278. */
  53279. export interface ISimplifier {
  53280. /**
  53281. * Simplification of a given mesh according to the given settings.
  53282. * Since this requires computation, it is assumed that the function runs async.
  53283. * @param settings The settings of the simplification, including quality and distance
  53284. * @param successCallback A callback that will be called after the mesh was simplified.
  53285. * @param errorCallback in case of an error, this callback will be called. optional.
  53286. */
  53287. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53288. }
  53289. /**
  53290. * Expected simplification settings.
  53291. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53292. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53293. */
  53294. export interface ISimplificationSettings {
  53295. /**
  53296. * Gets or sets the expected quality
  53297. */
  53298. quality: number;
  53299. /**
  53300. * Gets or sets the distance when this optimized version should be used
  53301. */
  53302. distance: number;
  53303. /**
  53304. * Gets an already optimized mesh
  53305. */
  53306. optimizeMesh?: boolean;
  53307. }
  53308. /**
  53309. * Class used to specify simplification options
  53310. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53311. */
  53312. export class SimplificationSettings implements ISimplificationSettings {
  53313. /** expected quality */
  53314. quality: number;
  53315. /** distance when this optimized version should be used */
  53316. distance: number;
  53317. /** already optimized mesh */
  53318. optimizeMesh?: boolean | undefined;
  53319. /**
  53320. * Creates a SimplificationSettings
  53321. * @param quality expected quality
  53322. * @param distance distance when this optimized version should be used
  53323. * @param optimizeMesh already optimized mesh
  53324. */
  53325. constructor(
  53326. /** expected quality */
  53327. quality: number,
  53328. /** distance when this optimized version should be used */
  53329. distance: number,
  53330. /** already optimized mesh */
  53331. optimizeMesh?: boolean | undefined);
  53332. }
  53333. /**
  53334. * Interface used to define a simplification task
  53335. */
  53336. export interface ISimplificationTask {
  53337. /**
  53338. * Array of settings
  53339. */
  53340. settings: Array<ISimplificationSettings>;
  53341. /**
  53342. * Simplification type
  53343. */
  53344. simplificationType: SimplificationType;
  53345. /**
  53346. * Mesh to simplify
  53347. */
  53348. mesh: Mesh;
  53349. /**
  53350. * Callback called on success
  53351. */
  53352. successCallback?: () => void;
  53353. /**
  53354. * Defines if parallel processing can be used
  53355. */
  53356. parallelProcessing: boolean;
  53357. }
  53358. /**
  53359. * Queue used to order the simplification tasks
  53360. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53361. */
  53362. export class SimplificationQueue {
  53363. private _simplificationArray;
  53364. /**
  53365. * Gets a boolean indicating that the process is still running
  53366. */
  53367. running: boolean;
  53368. /**
  53369. * Creates a new queue
  53370. */
  53371. constructor();
  53372. /**
  53373. * Adds a new simplification task
  53374. * @param task defines a task to add
  53375. */
  53376. addTask(task: ISimplificationTask): void;
  53377. /**
  53378. * Execute next task
  53379. */
  53380. executeNext(): void;
  53381. /**
  53382. * Execute a simplification task
  53383. * @param task defines the task to run
  53384. */
  53385. runSimplification(task: ISimplificationTask): void;
  53386. private getSimplifier;
  53387. }
  53388. /**
  53389. * The implemented types of simplification
  53390. * At the moment only Quadratic Error Decimation is implemented
  53391. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53392. */
  53393. export enum SimplificationType {
  53394. /** Quadratic error decimation */
  53395. QUADRATIC = 0
  53396. }
  53397. }
  53398. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53399. import { Scene } from "babylonjs/scene";
  53400. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53401. import { ISceneComponent } from "babylonjs/sceneComponent";
  53402. module "babylonjs/scene" {
  53403. interface Scene {
  53404. /** @hidden (Backing field) */
  53405. _simplificationQueue: SimplificationQueue;
  53406. /**
  53407. * Gets or sets the simplification queue attached to the scene
  53408. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53409. */
  53410. simplificationQueue: SimplificationQueue;
  53411. }
  53412. }
  53413. module "babylonjs/Meshes/mesh" {
  53414. interface Mesh {
  53415. /**
  53416. * Simplify the mesh according to the given array of settings.
  53417. * Function will return immediately and will simplify async
  53418. * @param settings a collection of simplification settings
  53419. * @param parallelProcessing should all levels calculate parallel or one after the other
  53420. * @param simplificationType the type of simplification to run
  53421. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53422. * @returns the current mesh
  53423. */
  53424. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53425. }
  53426. }
  53427. /**
  53428. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53429. * created in a scene
  53430. */
  53431. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53432. /**
  53433. * The component name helpfull to identify the component in the list of scene components.
  53434. */
  53435. readonly name: string;
  53436. /**
  53437. * The scene the component belongs to.
  53438. */
  53439. scene: Scene;
  53440. /**
  53441. * Creates a new instance of the component for the given scene
  53442. * @param scene Defines the scene to register the component in
  53443. */
  53444. constructor(scene: Scene);
  53445. /**
  53446. * Registers the component in a given scene
  53447. */
  53448. register(): void;
  53449. /**
  53450. * Rebuilds the elements related to this component in case of
  53451. * context lost for instance.
  53452. */
  53453. rebuild(): void;
  53454. /**
  53455. * Disposes the component and the associated ressources
  53456. */
  53457. dispose(): void;
  53458. private _beforeCameraUpdate;
  53459. }
  53460. }
  53461. declare module "babylonjs/Meshes/Builders/index" {
  53462. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53463. export * from "babylonjs/Meshes/Builders/discBuilder";
  53464. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53465. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53466. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53467. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53468. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53469. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53470. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53471. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53472. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53473. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53474. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53475. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53476. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53477. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53478. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53479. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53480. }
  53481. declare module "babylonjs/Meshes/index" {
  53482. export * from "babylonjs/Meshes/abstractMesh";
  53483. export * from "babylonjs/Meshes/buffer";
  53484. export * from "babylonjs/Meshes/Compression/index";
  53485. export * from "babylonjs/Meshes/csg";
  53486. export * from "babylonjs/Meshes/geometry";
  53487. export * from "babylonjs/Meshes/groundMesh";
  53488. export * from "babylonjs/Meshes/trailMesh";
  53489. export * from "babylonjs/Meshes/instancedMesh";
  53490. export * from "babylonjs/Meshes/linesMesh";
  53491. export * from "babylonjs/Meshes/mesh";
  53492. export * from "babylonjs/Meshes/mesh.vertexData";
  53493. export * from "babylonjs/Meshes/meshBuilder";
  53494. export * from "babylonjs/Meshes/meshSimplification";
  53495. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53496. export * from "babylonjs/Meshes/polygonMesh";
  53497. export * from "babylonjs/Meshes/subMesh";
  53498. export * from "babylonjs/Meshes/meshLODLevel";
  53499. export * from "babylonjs/Meshes/transformNode";
  53500. export * from "babylonjs/Meshes/Builders/index";
  53501. export * from "babylonjs/Meshes/dataBuffer";
  53502. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53503. }
  53504. declare module "babylonjs/Morph/index" {
  53505. export * from "babylonjs/Morph/morphTarget";
  53506. export * from "babylonjs/Morph/morphTargetManager";
  53507. }
  53508. declare module "babylonjs/Offline/database" {
  53509. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53510. /**
  53511. * Class used to enable access to IndexedDB
  53512. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53513. */
  53514. export class Database implements IOfflineProvider {
  53515. private _callbackManifestChecked;
  53516. private _currentSceneUrl;
  53517. private _db;
  53518. private _enableSceneOffline;
  53519. private _enableTexturesOffline;
  53520. private _manifestVersionFound;
  53521. private _mustUpdateRessources;
  53522. private _hasReachedQuota;
  53523. private _isSupported;
  53524. private _idbFactory;
  53525. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53526. private static IsUASupportingBlobStorage;
  53527. /**
  53528. * Gets a boolean indicating if Database storate is enabled (off by default)
  53529. */
  53530. static IDBStorageEnabled: boolean;
  53531. /**
  53532. * Gets a boolean indicating if scene must be saved in the database
  53533. */
  53534. readonly enableSceneOffline: boolean;
  53535. /**
  53536. * Gets a boolean indicating if textures must be saved in the database
  53537. */
  53538. readonly enableTexturesOffline: boolean;
  53539. /**
  53540. * Creates a new Database
  53541. * @param urlToScene defines the url to load the scene
  53542. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53543. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53544. */
  53545. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53546. private static _ParseURL;
  53547. private static _ReturnFullUrlLocation;
  53548. private _checkManifestFile;
  53549. /**
  53550. * Open the database and make it available
  53551. * @param successCallback defines the callback to call on success
  53552. * @param errorCallback defines the callback to call on error
  53553. */
  53554. open(successCallback: () => void, errorCallback: () => void): void;
  53555. /**
  53556. * Loads an image from the database
  53557. * @param url defines the url to load from
  53558. * @param image defines the target DOM image
  53559. */
  53560. loadImage(url: string, image: HTMLImageElement): void;
  53561. private _loadImageFromDBAsync;
  53562. private _saveImageIntoDBAsync;
  53563. private _checkVersionFromDB;
  53564. private _loadVersionFromDBAsync;
  53565. private _saveVersionIntoDBAsync;
  53566. /**
  53567. * Loads a file from database
  53568. * @param url defines the URL to load from
  53569. * @param sceneLoaded defines a callback to call on success
  53570. * @param progressCallBack defines a callback to call when progress changed
  53571. * @param errorCallback defines a callback to call on error
  53572. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53573. */
  53574. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53575. private _loadFileAsync;
  53576. private _saveFileAsync;
  53577. /**
  53578. * Validates if xhr data is correct
  53579. * @param xhr defines the request to validate
  53580. * @param dataType defines the expected data type
  53581. * @returns true if data is correct
  53582. */
  53583. private static _ValidateXHRData;
  53584. }
  53585. }
  53586. declare module "babylonjs/Offline/index" {
  53587. export * from "babylonjs/Offline/database";
  53588. export * from "babylonjs/Offline/IOfflineProvider";
  53589. }
  53590. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53591. /** @hidden */
  53592. export var gpuUpdateParticlesPixelShader: {
  53593. name: string;
  53594. shader: string;
  53595. };
  53596. }
  53597. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53598. /** @hidden */
  53599. export var gpuUpdateParticlesVertexShader: {
  53600. name: string;
  53601. shader: string;
  53602. };
  53603. }
  53604. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53605. /** @hidden */
  53606. export var clipPlaneFragmentDeclaration2: {
  53607. name: string;
  53608. shader: string;
  53609. };
  53610. }
  53611. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53612. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53613. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53614. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53615. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53616. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53617. /** @hidden */
  53618. export var gpuRenderParticlesPixelShader: {
  53619. name: string;
  53620. shader: string;
  53621. };
  53622. }
  53623. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53624. /** @hidden */
  53625. export var clipPlaneVertexDeclaration2: {
  53626. name: string;
  53627. shader: string;
  53628. };
  53629. }
  53630. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53631. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53632. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53633. /** @hidden */
  53634. export var gpuRenderParticlesVertexShader: {
  53635. name: string;
  53636. shader: string;
  53637. };
  53638. }
  53639. declare module "babylonjs/Particles/gpuParticleSystem" {
  53640. import { Nullable } from "babylonjs/types";
  53641. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53642. import { Observable } from "babylonjs/Misc/observable";
  53643. import { Color4, Color3 } from "babylonjs/Maths/math";
  53644. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53645. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53646. import { Scene, IDisposable } from "babylonjs/scene";
  53647. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53648. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53649. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53650. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53651. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53652. /**
  53653. * This represents a GPU particle system in Babylon
  53654. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53655. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53656. */
  53657. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53658. /**
  53659. * The layer mask we are rendering the particles through.
  53660. */
  53661. layerMask: number;
  53662. private _capacity;
  53663. private _activeCount;
  53664. private _currentActiveCount;
  53665. private _accumulatedCount;
  53666. private _renderEffect;
  53667. private _updateEffect;
  53668. private _buffer0;
  53669. private _buffer1;
  53670. private _spriteBuffer;
  53671. private _updateVAO;
  53672. private _renderVAO;
  53673. private _targetIndex;
  53674. private _sourceBuffer;
  53675. private _targetBuffer;
  53676. private _engine;
  53677. private _currentRenderId;
  53678. private _started;
  53679. private _stopped;
  53680. private _timeDelta;
  53681. private _randomTexture;
  53682. private _randomTexture2;
  53683. private _attributesStrideSize;
  53684. private _updateEffectOptions;
  53685. private _randomTextureSize;
  53686. private _actualFrame;
  53687. private readonly _rawTextureWidth;
  53688. /**
  53689. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53690. */
  53691. static readonly IsSupported: boolean;
  53692. /**
  53693. * An event triggered when the system is disposed.
  53694. */
  53695. onDisposeObservable: Observable<GPUParticleSystem>;
  53696. /**
  53697. * Gets the maximum number of particles active at the same time.
  53698. * @returns The max number of active particles.
  53699. */
  53700. getCapacity(): number;
  53701. /**
  53702. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53703. * to override the particles.
  53704. */
  53705. forceDepthWrite: boolean;
  53706. /**
  53707. * Gets or set the number of active particles
  53708. */
  53709. activeParticleCount: number;
  53710. private _preWarmDone;
  53711. /**
  53712. * Is this system ready to be used/rendered
  53713. * @return true if the system is ready
  53714. */
  53715. isReady(): boolean;
  53716. /**
  53717. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53718. * @returns True if it has been started, otherwise false.
  53719. */
  53720. isStarted(): boolean;
  53721. /**
  53722. * Starts the particle system and begins to emit
  53723. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53724. */
  53725. start(delay?: number): void;
  53726. /**
  53727. * Stops the particle system.
  53728. */
  53729. stop(): void;
  53730. /**
  53731. * Remove all active particles
  53732. */
  53733. reset(): void;
  53734. /**
  53735. * Returns the string "GPUParticleSystem"
  53736. * @returns a string containing the class name
  53737. */
  53738. getClassName(): string;
  53739. private _colorGradientsTexture;
  53740. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53741. /**
  53742. * Adds a new color gradient
  53743. * @param gradient defines the gradient to use (between 0 and 1)
  53744. * @param color1 defines the color to affect to the specified gradient
  53745. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53746. * @returns the current particle system
  53747. */
  53748. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53749. /**
  53750. * Remove a specific color gradient
  53751. * @param gradient defines the gradient to remove
  53752. * @returns the current particle system
  53753. */
  53754. removeColorGradient(gradient: number): GPUParticleSystem;
  53755. private _angularSpeedGradientsTexture;
  53756. private _sizeGradientsTexture;
  53757. private _velocityGradientsTexture;
  53758. private _limitVelocityGradientsTexture;
  53759. private _dragGradientsTexture;
  53760. private _addFactorGradient;
  53761. /**
  53762. * Adds a new size gradient
  53763. * @param gradient defines the gradient to use (between 0 and 1)
  53764. * @param factor defines the size factor to affect to the specified gradient
  53765. * @returns the current particle system
  53766. */
  53767. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53768. /**
  53769. * Remove a specific size gradient
  53770. * @param gradient defines the gradient to remove
  53771. * @returns the current particle system
  53772. */
  53773. removeSizeGradient(gradient: number): GPUParticleSystem;
  53774. /**
  53775. * Adds a new angular speed gradient
  53776. * @param gradient defines the gradient to use (between 0 and 1)
  53777. * @param factor defines the angular speed to affect to the specified gradient
  53778. * @returns the current particle system
  53779. */
  53780. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53781. /**
  53782. * Remove a specific angular speed gradient
  53783. * @param gradient defines the gradient to remove
  53784. * @returns the current particle system
  53785. */
  53786. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53787. /**
  53788. * Adds a new velocity gradient
  53789. * @param gradient defines the gradient to use (between 0 and 1)
  53790. * @param factor defines the velocity to affect to the specified gradient
  53791. * @returns the current particle system
  53792. */
  53793. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53794. /**
  53795. * Remove a specific velocity gradient
  53796. * @param gradient defines the gradient to remove
  53797. * @returns the current particle system
  53798. */
  53799. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53800. /**
  53801. * Adds a new limit velocity gradient
  53802. * @param gradient defines the gradient to use (between 0 and 1)
  53803. * @param factor defines the limit velocity value to affect to the specified gradient
  53804. * @returns the current particle system
  53805. */
  53806. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53807. /**
  53808. * Remove a specific limit velocity gradient
  53809. * @param gradient defines the gradient to remove
  53810. * @returns the current particle system
  53811. */
  53812. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53813. /**
  53814. * Adds a new drag gradient
  53815. * @param gradient defines the gradient to use (between 0 and 1)
  53816. * @param factor defines the drag value to affect to the specified gradient
  53817. * @returns the current particle system
  53818. */
  53819. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53820. /**
  53821. * Remove a specific drag gradient
  53822. * @param gradient defines the gradient to remove
  53823. * @returns the current particle system
  53824. */
  53825. removeDragGradient(gradient: number): GPUParticleSystem;
  53826. /**
  53827. * Not supported by GPUParticleSystem
  53828. * @param gradient defines the gradient to use (between 0 and 1)
  53829. * @param factor defines the emit rate value to affect to the specified gradient
  53830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53831. * @returns the current particle system
  53832. */
  53833. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53834. /**
  53835. * Not supported by GPUParticleSystem
  53836. * @param gradient defines the gradient to remove
  53837. * @returns the current particle system
  53838. */
  53839. removeEmitRateGradient(gradient: number): IParticleSystem;
  53840. /**
  53841. * Not supported by GPUParticleSystem
  53842. * @param gradient defines the gradient to use (between 0 and 1)
  53843. * @param factor defines the start size value to affect to the specified gradient
  53844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53845. * @returns the current particle system
  53846. */
  53847. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53848. /**
  53849. * Not supported by GPUParticleSystem
  53850. * @param gradient defines the gradient to remove
  53851. * @returns the current particle system
  53852. */
  53853. removeStartSizeGradient(gradient: number): IParticleSystem;
  53854. /**
  53855. * Not supported by GPUParticleSystem
  53856. * @param gradient defines the gradient to use (between 0 and 1)
  53857. * @param min defines the color remap minimal range
  53858. * @param max defines the color remap maximal range
  53859. * @returns the current particle system
  53860. */
  53861. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53862. /**
  53863. * Not supported by GPUParticleSystem
  53864. * @param gradient defines the gradient to remove
  53865. * @returns the current particle system
  53866. */
  53867. removeColorRemapGradient(): IParticleSystem;
  53868. /**
  53869. * Not supported by GPUParticleSystem
  53870. * @param gradient defines the gradient to use (between 0 and 1)
  53871. * @param min defines the alpha remap minimal range
  53872. * @param max defines the alpha remap maximal range
  53873. * @returns the current particle system
  53874. */
  53875. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53876. /**
  53877. * Not supported by GPUParticleSystem
  53878. * @param gradient defines the gradient to remove
  53879. * @returns the current particle system
  53880. */
  53881. removeAlphaRemapGradient(): IParticleSystem;
  53882. /**
  53883. * Not supported by GPUParticleSystem
  53884. * @param gradient defines the gradient to use (between 0 and 1)
  53885. * @param color defines the color to affect to the specified gradient
  53886. * @returns the current particle system
  53887. */
  53888. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53889. /**
  53890. * Not supported by GPUParticleSystem
  53891. * @param gradient defines the gradient to remove
  53892. * @returns the current particle system
  53893. */
  53894. removeRampGradient(): IParticleSystem;
  53895. /**
  53896. * Not supported by GPUParticleSystem
  53897. * @returns the list of ramp gradients
  53898. */
  53899. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53900. /**
  53901. * Not supported by GPUParticleSystem
  53902. * Gets or sets a boolean indicating that ramp gradients must be used
  53903. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53904. */
  53905. useRampGradients: boolean;
  53906. /**
  53907. * Not supported by GPUParticleSystem
  53908. * @param gradient defines the gradient to use (between 0 and 1)
  53909. * @param factor defines the life time factor to affect to the specified gradient
  53910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53911. * @returns the current particle system
  53912. */
  53913. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53914. /**
  53915. * Not supported by GPUParticleSystem
  53916. * @param gradient defines the gradient to remove
  53917. * @returns the current particle system
  53918. */
  53919. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53920. /**
  53921. * Instantiates a GPU particle system.
  53922. * 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.
  53923. * @param name The name of the particle system
  53924. * @param options The options used to create the system
  53925. * @param scene The scene the particle system belongs to
  53926. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53927. */
  53928. constructor(name: string, options: Partial<{
  53929. capacity: number;
  53930. randomTextureSize: number;
  53931. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53932. protected _reset(): void;
  53933. private _createUpdateVAO;
  53934. private _createRenderVAO;
  53935. private _initialize;
  53936. /** @hidden */
  53937. _recreateUpdateEffect(): void;
  53938. /** @hidden */
  53939. _recreateRenderEffect(): void;
  53940. /**
  53941. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53942. * @param preWarm defines if we are in the pre-warmimg phase
  53943. */
  53944. animate(preWarm?: boolean): void;
  53945. private _createFactorGradientTexture;
  53946. private _createSizeGradientTexture;
  53947. private _createAngularSpeedGradientTexture;
  53948. private _createVelocityGradientTexture;
  53949. private _createLimitVelocityGradientTexture;
  53950. private _createDragGradientTexture;
  53951. private _createColorGradientTexture;
  53952. /**
  53953. * Renders the particle system in its current state
  53954. * @param preWarm defines if the system should only update the particles but not render them
  53955. * @returns the current number of particles
  53956. */
  53957. render(preWarm?: boolean): number;
  53958. /**
  53959. * Rebuilds the particle system
  53960. */
  53961. rebuild(): void;
  53962. private _releaseBuffers;
  53963. private _releaseVAOs;
  53964. /**
  53965. * Disposes the particle system and free the associated resources
  53966. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53967. */
  53968. dispose(disposeTexture?: boolean): void;
  53969. /**
  53970. * Clones the particle system.
  53971. * @param name The name of the cloned object
  53972. * @param newEmitter The new emitter to use
  53973. * @returns the cloned particle system
  53974. */
  53975. clone(name: string, newEmitter: any): GPUParticleSystem;
  53976. /**
  53977. * Serializes the particle system to a JSON object.
  53978. * @returns the JSON object
  53979. */
  53980. serialize(): any;
  53981. /**
  53982. * Parses a JSON object to create a GPU particle system.
  53983. * @param parsedParticleSystem The JSON object to parse
  53984. * @param scene The scene to create the particle system in
  53985. * @param rootUrl The root url to use to load external dependencies like texture
  53986. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53987. * @returns the parsed GPU particle system
  53988. */
  53989. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53990. }
  53991. }
  53992. declare module "babylonjs/Particles/particleSystemSet" {
  53993. import { Nullable } from "babylonjs/types";
  53994. import { Color3 } from "babylonjs/Maths/math";
  53995. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53997. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53998. import { Scene, IDisposable } from "babylonjs/scene";
  53999. /**
  54000. * Represents a set of particle systems working together to create a specific effect
  54001. */
  54002. export class ParticleSystemSet implements IDisposable {
  54003. private _emitterCreationOptions;
  54004. private _emitterNode;
  54005. /**
  54006. * Gets the particle system list
  54007. */
  54008. systems: IParticleSystem[];
  54009. /**
  54010. * Gets the emitter node used with this set
  54011. */
  54012. readonly emitterNode: Nullable<TransformNode>;
  54013. /**
  54014. * Creates a new emitter mesh as a sphere
  54015. * @param options defines the options used to create the sphere
  54016. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54017. * @param scene defines the hosting scene
  54018. */
  54019. setEmitterAsSphere(options: {
  54020. diameter: number;
  54021. segments: number;
  54022. color: Color3;
  54023. }, renderingGroupId: number, scene: Scene): void;
  54024. /**
  54025. * Starts all particle systems of the set
  54026. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54027. */
  54028. start(emitter?: AbstractMesh): void;
  54029. /**
  54030. * Release all associated resources
  54031. */
  54032. dispose(): void;
  54033. /**
  54034. * Serialize the set into a JSON compatible object
  54035. * @returns a JSON compatible representation of the set
  54036. */
  54037. serialize(): any;
  54038. /**
  54039. * Parse a new ParticleSystemSet from a serialized source
  54040. * @param data defines a JSON compatible representation of the set
  54041. * @param scene defines the hosting scene
  54042. * @param gpu defines if we want GPU particles or CPU particles
  54043. * @returns a new ParticleSystemSet
  54044. */
  54045. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54046. }
  54047. }
  54048. declare module "babylonjs/Particles/particleHelper" {
  54049. import { Nullable } from "babylonjs/types";
  54050. import { Scene } from "babylonjs/scene";
  54051. import { Vector3 } from "babylonjs/Maths/math";
  54052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54053. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54054. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  54055. /**
  54056. * This class is made for on one-liner static method to help creating particle system set.
  54057. */
  54058. export class ParticleHelper {
  54059. /**
  54060. * Gets or sets base Assets URL
  54061. */
  54062. static BaseAssetsUrl: string;
  54063. /**
  54064. * Create a default particle system that you can tweak
  54065. * @param emitter defines the emitter to use
  54066. * @param capacity defines the system capacity (default is 500 particles)
  54067. * @param scene defines the hosting scene
  54068. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54069. * @returns the new Particle system
  54070. */
  54071. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54072. /**
  54073. * This is the main static method (one-liner) of this helper to create different particle systems
  54074. * @param type This string represents the type to the particle system to create
  54075. * @param scene The scene where the particle system should live
  54076. * @param gpu If the system will use gpu
  54077. * @returns the ParticleSystemSet created
  54078. */
  54079. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54080. /**
  54081. * Static function used to export a particle system to a ParticleSystemSet variable.
  54082. * Please note that the emitter shape is not exported
  54083. * @param systems defines the particle systems to export
  54084. * @returns the created particle system set
  54085. */
  54086. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54087. }
  54088. }
  54089. declare module "babylonjs/Particles/particleSystemComponent" {
  54090. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54091. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54092. import "babylonjs/Shaders/particles.vertex";
  54093. module "babylonjs/Engines/engine" {
  54094. interface Engine {
  54095. /**
  54096. * Create an effect to use with particle systems.
  54097. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54098. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54099. * @param uniformsNames defines a list of attribute names
  54100. * @param samplers defines an array of string used to represent textures
  54101. * @param defines defines the string containing the defines to use to compile the shaders
  54102. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54103. * @param onCompiled defines a function to call when the effect creation is successful
  54104. * @param onError defines a function to call when the effect creation has failed
  54105. * @returns the new Effect
  54106. */
  54107. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54108. }
  54109. }
  54110. module "babylonjs/Meshes/mesh" {
  54111. interface Mesh {
  54112. /**
  54113. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54114. * @returns an array of IParticleSystem
  54115. */
  54116. getEmittedParticleSystems(): IParticleSystem[];
  54117. /**
  54118. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54119. * @returns an array of IParticleSystem
  54120. */
  54121. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54122. }
  54123. }
  54124. /**
  54125. * @hidden
  54126. */
  54127. export var _IDoNeedToBeInTheBuild: number;
  54128. }
  54129. declare module "babylonjs/Particles/index" {
  54130. export * from "babylonjs/Particles/baseParticleSystem";
  54131. export * from "babylonjs/Particles/EmitterTypes/index";
  54132. export * from "babylonjs/Particles/gpuParticleSystem";
  54133. export * from "babylonjs/Particles/IParticleSystem";
  54134. export * from "babylonjs/Particles/particle";
  54135. export * from "babylonjs/Particles/particleHelper";
  54136. export * from "babylonjs/Particles/particleSystem";
  54137. export * from "babylonjs/Particles/particleSystemComponent";
  54138. export * from "babylonjs/Particles/particleSystemSet";
  54139. export * from "babylonjs/Particles/solidParticle";
  54140. export * from "babylonjs/Particles/solidParticleSystem";
  54141. export * from "babylonjs/Particles/subEmitter";
  54142. }
  54143. declare module "babylonjs/Physics/physicsEngineComponent" {
  54144. import { Nullable } from "babylonjs/types";
  54145. import { Observable, Observer } from "babylonjs/Misc/observable";
  54146. import { Vector3 } from "babylonjs/Maths/math";
  54147. import { Mesh } from "babylonjs/Meshes/mesh";
  54148. import { ISceneComponent } from "babylonjs/sceneComponent";
  54149. import { Scene } from "babylonjs/scene";
  54150. import { Node } from "babylonjs/node";
  54151. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54152. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54153. module "babylonjs/scene" {
  54154. interface Scene {
  54155. /** @hidden (Backing field) */
  54156. _physicsEngine: Nullable<IPhysicsEngine>;
  54157. /**
  54158. * Gets the current physics engine
  54159. * @returns a IPhysicsEngine or null if none attached
  54160. */
  54161. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54162. /**
  54163. * Enables physics to the current scene
  54164. * @param gravity defines the scene's gravity for the physics engine
  54165. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54166. * @return a boolean indicating if the physics engine was initialized
  54167. */
  54168. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54169. /**
  54170. * Disables and disposes the physics engine associated with the scene
  54171. */
  54172. disablePhysicsEngine(): void;
  54173. /**
  54174. * Gets a boolean indicating if there is an active physics engine
  54175. * @returns a boolean indicating if there is an active physics engine
  54176. */
  54177. isPhysicsEnabled(): boolean;
  54178. /**
  54179. * Deletes a physics compound impostor
  54180. * @param compound defines the compound to delete
  54181. */
  54182. deleteCompoundImpostor(compound: any): void;
  54183. /**
  54184. * An event triggered when physic simulation is about to be run
  54185. */
  54186. onBeforePhysicsObservable: Observable<Scene>;
  54187. /**
  54188. * An event triggered when physic simulation has been done
  54189. */
  54190. onAfterPhysicsObservable: Observable<Scene>;
  54191. }
  54192. }
  54193. module "babylonjs/Meshes/abstractMesh" {
  54194. interface AbstractMesh {
  54195. /** @hidden */
  54196. _physicsImpostor: Nullable<PhysicsImpostor>;
  54197. /**
  54198. * Gets or sets impostor used for physic simulation
  54199. * @see http://doc.babylonjs.com/features/physics_engine
  54200. */
  54201. physicsImpostor: Nullable<PhysicsImpostor>;
  54202. /**
  54203. * Gets the current physics impostor
  54204. * @see http://doc.babylonjs.com/features/physics_engine
  54205. * @returns a physics impostor or null
  54206. */
  54207. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54208. /** Apply a physic impulse to the mesh
  54209. * @param force defines the force to apply
  54210. * @param contactPoint defines where to apply the force
  54211. * @returns the current mesh
  54212. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54213. */
  54214. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54215. /**
  54216. * Creates a physic joint between two meshes
  54217. * @param otherMesh defines the other mesh to use
  54218. * @param pivot1 defines the pivot to use on this mesh
  54219. * @param pivot2 defines the pivot to use on the other mesh
  54220. * @param options defines additional options (can be plugin dependent)
  54221. * @returns the current mesh
  54222. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54223. */
  54224. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54225. /** @hidden */
  54226. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54227. }
  54228. }
  54229. /**
  54230. * Defines the physics engine scene component responsible to manage a physics engine
  54231. */
  54232. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54233. /**
  54234. * The component name helpful to identify the component in the list of scene components.
  54235. */
  54236. readonly name: string;
  54237. /**
  54238. * The scene the component belongs to.
  54239. */
  54240. scene: Scene;
  54241. /**
  54242. * Creates a new instance of the component for the given scene
  54243. * @param scene Defines the scene to register the component in
  54244. */
  54245. constructor(scene: Scene);
  54246. /**
  54247. * Registers the component in a given scene
  54248. */
  54249. register(): void;
  54250. /**
  54251. * Rebuilds the elements related to this component in case of
  54252. * context lost for instance.
  54253. */
  54254. rebuild(): void;
  54255. /**
  54256. * Disposes the component and the associated ressources
  54257. */
  54258. dispose(): void;
  54259. }
  54260. }
  54261. declare module "babylonjs/Physics/physicsHelper" {
  54262. import { Nullable } from "babylonjs/types";
  54263. import { Vector3 } from "babylonjs/Maths/math";
  54264. import { Mesh } from "babylonjs/Meshes/mesh";
  54265. import { Scene } from "babylonjs/scene";
  54266. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54267. /**
  54268. * A helper for physics simulations
  54269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54270. */
  54271. export class PhysicsHelper {
  54272. private _scene;
  54273. private _physicsEngine;
  54274. /**
  54275. * Initializes the Physics helper
  54276. * @param scene Babylon.js scene
  54277. */
  54278. constructor(scene: Scene);
  54279. /**
  54280. * Applies a radial explosion impulse
  54281. * @param origin the origin of the explosion
  54282. * @param radiusOrEventOptions the radius or the options of radial explosion
  54283. * @param strength the explosion strength
  54284. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54285. * @returns A physics radial explosion event, or null
  54286. */
  54287. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54288. /**
  54289. * Applies a radial explosion force
  54290. * @param origin the origin of the explosion
  54291. * @param radiusOrEventOptions the radius or the options of radial explosion
  54292. * @param strength the explosion strength
  54293. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54294. * @returns A physics radial explosion event, or null
  54295. */
  54296. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54297. /**
  54298. * Creates a gravitational field
  54299. * @param origin the origin of the explosion
  54300. * @param radiusOrEventOptions the radius or the options of radial explosion
  54301. * @param strength the explosion strength
  54302. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54303. * @returns A physics gravitational field event, or null
  54304. */
  54305. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54306. /**
  54307. * Creates a physics updraft event
  54308. * @param origin the origin of the updraft
  54309. * @param radiusOrEventOptions the radius or the options of the updraft
  54310. * @param strength the strength of the updraft
  54311. * @param height the height of the updraft
  54312. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54313. * @returns A physics updraft event, or null
  54314. */
  54315. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54316. /**
  54317. * Creates a physics vortex event
  54318. * @param origin the of the vortex
  54319. * @param radiusOrEventOptions the radius or the options of the vortex
  54320. * @param strength the strength of the vortex
  54321. * @param height the height of the vortex
  54322. * @returns a Physics vortex event, or null
  54323. * A physics vortex event or null
  54324. */
  54325. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54326. }
  54327. /**
  54328. * Represents a physics radial explosion event
  54329. */
  54330. class PhysicsRadialExplosionEvent {
  54331. private _scene;
  54332. private _options;
  54333. private _sphere;
  54334. private _dataFetched;
  54335. /**
  54336. * Initializes a radial explosioin event
  54337. * @param _scene BabylonJS scene
  54338. * @param _options The options for the vortex event
  54339. */
  54340. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54341. /**
  54342. * Returns the data related to the radial explosion event (sphere).
  54343. * @returns The radial explosion event data
  54344. */
  54345. getData(): PhysicsRadialExplosionEventData;
  54346. /**
  54347. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54348. * @param impostor A physics imposter
  54349. * @param origin the origin of the explosion
  54350. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54351. */
  54352. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54353. /**
  54354. * Triggers affecterd impostors callbacks
  54355. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54356. */
  54357. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54358. /**
  54359. * Disposes the sphere.
  54360. * @param force Specifies if the sphere should be disposed by force
  54361. */
  54362. dispose(force?: boolean): void;
  54363. /*** Helpers ***/
  54364. private _prepareSphere;
  54365. private _intersectsWithSphere;
  54366. }
  54367. /**
  54368. * Represents a gravitational field event
  54369. */
  54370. class PhysicsGravitationalFieldEvent {
  54371. private _physicsHelper;
  54372. private _scene;
  54373. private _origin;
  54374. private _options;
  54375. private _tickCallback;
  54376. private _sphere;
  54377. private _dataFetched;
  54378. /**
  54379. * Initializes the physics gravitational field event
  54380. * @param _physicsHelper A physics helper
  54381. * @param _scene BabylonJS scene
  54382. * @param _origin The origin position of the gravitational field event
  54383. * @param _options The options for the vortex event
  54384. */
  54385. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54386. /**
  54387. * Returns the data related to the gravitational field event (sphere).
  54388. * @returns A gravitational field event
  54389. */
  54390. getData(): PhysicsGravitationalFieldEventData;
  54391. /**
  54392. * Enables the gravitational field.
  54393. */
  54394. enable(): void;
  54395. /**
  54396. * Disables the gravitational field.
  54397. */
  54398. disable(): void;
  54399. /**
  54400. * Disposes the sphere.
  54401. * @param force The force to dispose from the gravitational field event
  54402. */
  54403. dispose(force?: boolean): void;
  54404. private _tick;
  54405. }
  54406. /**
  54407. * Represents a physics updraft event
  54408. */
  54409. class PhysicsUpdraftEvent {
  54410. private _scene;
  54411. private _origin;
  54412. private _options;
  54413. private _physicsEngine;
  54414. private _originTop;
  54415. private _originDirection;
  54416. private _tickCallback;
  54417. private _cylinder;
  54418. private _cylinderPosition;
  54419. private _dataFetched;
  54420. /**
  54421. * Initializes the physics updraft event
  54422. * @param _scene BabylonJS scene
  54423. * @param _origin The origin position of the updraft
  54424. * @param _options The options for the updraft event
  54425. */
  54426. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54427. /**
  54428. * Returns the data related to the updraft event (cylinder).
  54429. * @returns A physics updraft event
  54430. */
  54431. getData(): PhysicsUpdraftEventData;
  54432. /**
  54433. * Enables the updraft.
  54434. */
  54435. enable(): void;
  54436. /**
  54437. * Disables the updraft.
  54438. */
  54439. disable(): void;
  54440. /**
  54441. * Disposes the cylinder.
  54442. * @param force Specifies if the updraft should be disposed by force
  54443. */
  54444. dispose(force?: boolean): void;
  54445. private getImpostorHitData;
  54446. private _tick;
  54447. /*** Helpers ***/
  54448. private _prepareCylinder;
  54449. private _intersectsWithCylinder;
  54450. }
  54451. /**
  54452. * Represents a physics vortex event
  54453. */
  54454. class PhysicsVortexEvent {
  54455. private _scene;
  54456. private _origin;
  54457. private _options;
  54458. private _physicsEngine;
  54459. private _originTop;
  54460. private _tickCallback;
  54461. private _cylinder;
  54462. private _cylinderPosition;
  54463. private _dataFetched;
  54464. /**
  54465. * Initializes the physics vortex event
  54466. * @param _scene The BabylonJS scene
  54467. * @param _origin The origin position of the vortex
  54468. * @param _options The options for the vortex event
  54469. */
  54470. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54471. /**
  54472. * Returns the data related to the vortex event (cylinder).
  54473. * @returns The physics vortex event data
  54474. */
  54475. getData(): PhysicsVortexEventData;
  54476. /**
  54477. * Enables the vortex.
  54478. */
  54479. enable(): void;
  54480. /**
  54481. * Disables the cortex.
  54482. */
  54483. disable(): void;
  54484. /**
  54485. * Disposes the sphere.
  54486. * @param force
  54487. */
  54488. dispose(force?: boolean): void;
  54489. private getImpostorHitData;
  54490. private _tick;
  54491. /*** Helpers ***/
  54492. private _prepareCylinder;
  54493. private _intersectsWithCylinder;
  54494. }
  54495. /**
  54496. * Options fot the radial explosion event
  54497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54498. */
  54499. export class PhysicsRadialExplosionEventOptions {
  54500. /**
  54501. * The radius of the sphere for the radial explosion.
  54502. */
  54503. radius: number;
  54504. /**
  54505. * The strenth of the explosion.
  54506. */
  54507. strength: number;
  54508. /**
  54509. * The strenght of the force in correspondence to the distance of the affected object
  54510. */
  54511. falloff: PhysicsRadialImpulseFalloff;
  54512. /**
  54513. * Sphere options for the radial explosion.
  54514. */
  54515. sphere: {
  54516. segments: number;
  54517. diameter: number;
  54518. };
  54519. /**
  54520. * Sphere options for the radial explosion.
  54521. */
  54522. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54523. }
  54524. /**
  54525. * Options fot the updraft event
  54526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54527. */
  54528. export class PhysicsUpdraftEventOptions {
  54529. /**
  54530. * The radius of the cylinder for the vortex
  54531. */
  54532. radius: number;
  54533. /**
  54534. * The strenth of the updraft.
  54535. */
  54536. strength: number;
  54537. /**
  54538. * The height of the cylinder for the updraft.
  54539. */
  54540. height: number;
  54541. /**
  54542. * The mode for the the updraft.
  54543. */
  54544. updraftMode: PhysicsUpdraftMode;
  54545. }
  54546. /**
  54547. * Options fot the vortex event
  54548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54549. */
  54550. export class PhysicsVortexEventOptions {
  54551. /**
  54552. * The radius of the cylinder for the vortex
  54553. */
  54554. radius: number;
  54555. /**
  54556. * The strenth of the vortex.
  54557. */
  54558. strength: number;
  54559. /**
  54560. * The height of the cylinder for the vortex.
  54561. */
  54562. height: number;
  54563. /**
  54564. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54565. */
  54566. centripetalForceThreshold: number;
  54567. /**
  54568. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54569. */
  54570. centripetalForceMultiplier: number;
  54571. /**
  54572. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54573. */
  54574. centrifugalForceMultiplier: number;
  54575. /**
  54576. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54577. */
  54578. updraftForceMultiplier: number;
  54579. }
  54580. /**
  54581. * The strenght of the force in correspondence to the distance of the affected object
  54582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54583. */
  54584. export enum PhysicsRadialImpulseFalloff {
  54585. /** Defines that impulse is constant in strength across it's whole radius */
  54586. Constant = 0,
  54587. /** Defines that impulse gets weaker if it's further from the origin */
  54588. Linear = 1
  54589. }
  54590. /**
  54591. * The strength of the force in correspondence to the distance of the affected object
  54592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54593. */
  54594. export enum PhysicsUpdraftMode {
  54595. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54596. Center = 0,
  54597. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54598. Perpendicular = 1
  54599. }
  54600. /**
  54601. * Interface for a physics hit data
  54602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54603. */
  54604. export interface PhysicsHitData {
  54605. /**
  54606. * The force applied at the contact point
  54607. */
  54608. force: Vector3;
  54609. /**
  54610. * The contact point
  54611. */
  54612. contactPoint: Vector3;
  54613. /**
  54614. * The distance from the origin to the contact point
  54615. */
  54616. distanceFromOrigin: number;
  54617. }
  54618. /**
  54619. * Interface for radial explosion event data
  54620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54621. */
  54622. export interface PhysicsRadialExplosionEventData {
  54623. /**
  54624. * A sphere used for the radial explosion event
  54625. */
  54626. sphere: Mesh;
  54627. }
  54628. /**
  54629. * Interface for gravitational field event data
  54630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54631. */
  54632. export interface PhysicsGravitationalFieldEventData {
  54633. /**
  54634. * A sphere mesh used for the gravitational field event
  54635. */
  54636. sphere: Mesh;
  54637. }
  54638. /**
  54639. * Interface for updraft event data
  54640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54641. */
  54642. export interface PhysicsUpdraftEventData {
  54643. /**
  54644. * A cylinder used for the updraft event
  54645. */
  54646. cylinder: Mesh;
  54647. }
  54648. /**
  54649. * Interface for vortex event data
  54650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54651. */
  54652. export interface PhysicsVortexEventData {
  54653. /**
  54654. * A cylinder used for the vortex event
  54655. */
  54656. cylinder: Mesh;
  54657. }
  54658. /**
  54659. * Interface for an affected physics impostor
  54660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54661. */
  54662. export interface PhysicsAffectedImpostorWithData {
  54663. /**
  54664. * The impostor affected by the effect
  54665. */
  54666. impostor: PhysicsImpostor;
  54667. /**
  54668. * The data about the hit/horce from the explosion
  54669. */
  54670. hitData: PhysicsHitData;
  54671. }
  54672. }
  54673. declare module "babylonjs/Physics/Plugins/index" {
  54674. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54675. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54676. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54677. }
  54678. declare module "babylonjs/Physics/index" {
  54679. export * from "babylonjs/Physics/IPhysicsEngine";
  54680. export * from "babylonjs/Physics/physicsEngine";
  54681. export * from "babylonjs/Physics/physicsEngineComponent";
  54682. export * from "babylonjs/Physics/physicsHelper";
  54683. export * from "babylonjs/Physics/physicsImpostor";
  54684. export * from "babylonjs/Physics/physicsJoint";
  54685. export * from "babylonjs/Physics/Plugins/index";
  54686. }
  54687. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54688. /** @hidden */
  54689. export var blackAndWhitePixelShader: {
  54690. name: string;
  54691. shader: string;
  54692. };
  54693. }
  54694. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54695. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54696. import { Camera } from "babylonjs/Cameras/camera";
  54697. import { Engine } from "babylonjs/Engines/engine";
  54698. import "babylonjs/Shaders/blackAndWhite.fragment";
  54699. /**
  54700. * Post process used to render in black and white
  54701. */
  54702. export class BlackAndWhitePostProcess extends PostProcess {
  54703. /**
  54704. * Linear about to convert he result to black and white (default: 1)
  54705. */
  54706. degree: number;
  54707. /**
  54708. * Creates a black and white post process
  54709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54710. * @param name The name of the effect.
  54711. * @param options The required width/height ratio to downsize to before computing the render pass.
  54712. * @param camera The camera to apply the render pass to.
  54713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54714. * @param engine The engine which the post process will be applied. (default: current engine)
  54715. * @param reusable If the post process can be reused on the same frame. (default: false)
  54716. */
  54717. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54718. }
  54719. }
  54720. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54721. import { Nullable } from "babylonjs/types";
  54722. import { Camera } from "babylonjs/Cameras/camera";
  54723. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54724. import { Engine } from "babylonjs/Engines/engine";
  54725. /**
  54726. * This represents a set of one or more post processes in Babylon.
  54727. * A post process can be used to apply a shader to a texture after it is rendered.
  54728. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54729. */
  54730. export class PostProcessRenderEffect {
  54731. private _postProcesses;
  54732. private _getPostProcesses;
  54733. private _singleInstance;
  54734. private _cameras;
  54735. private _indicesForCamera;
  54736. /**
  54737. * Name of the effect
  54738. * @hidden
  54739. */
  54740. _name: string;
  54741. /**
  54742. * Instantiates a post process render effect.
  54743. * A post process can be used to apply a shader to a texture after it is rendered.
  54744. * @param engine The engine the effect is tied to
  54745. * @param name The name of the effect
  54746. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54747. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54748. */
  54749. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54750. /**
  54751. * Checks if all the post processes in the effect are supported.
  54752. */
  54753. readonly isSupported: boolean;
  54754. /**
  54755. * Updates the current state of the effect
  54756. * @hidden
  54757. */
  54758. _update(): void;
  54759. /**
  54760. * Attaches the effect on cameras
  54761. * @param cameras The camera to attach to.
  54762. * @hidden
  54763. */
  54764. _attachCameras(cameras: Camera): void;
  54765. /**
  54766. * Attaches the effect on cameras
  54767. * @param cameras The camera to attach to.
  54768. * @hidden
  54769. */
  54770. _attachCameras(cameras: Camera[]): void;
  54771. /**
  54772. * Detaches the effect on cameras
  54773. * @param cameras The camera to detatch from.
  54774. * @hidden
  54775. */
  54776. _detachCameras(cameras: Camera): void;
  54777. /**
  54778. * Detatches the effect on cameras
  54779. * @param cameras The camera to detatch from.
  54780. * @hidden
  54781. */
  54782. _detachCameras(cameras: Camera[]): void;
  54783. /**
  54784. * Enables the effect on given cameras
  54785. * @param cameras The camera to enable.
  54786. * @hidden
  54787. */
  54788. _enable(cameras: Camera): void;
  54789. /**
  54790. * Enables the effect on given cameras
  54791. * @param cameras The camera to enable.
  54792. * @hidden
  54793. */
  54794. _enable(cameras: Nullable<Camera[]>): void;
  54795. /**
  54796. * Disables the effect on the given cameras
  54797. * @param cameras The camera to disable.
  54798. * @hidden
  54799. */
  54800. _disable(cameras: Camera): void;
  54801. /**
  54802. * Disables the effect on the given cameras
  54803. * @param cameras The camera to disable.
  54804. * @hidden
  54805. */
  54806. _disable(cameras: Nullable<Camera[]>): void;
  54807. /**
  54808. * Gets a list of the post processes contained in the effect.
  54809. * @param camera The camera to get the post processes on.
  54810. * @returns The list of the post processes in the effect.
  54811. */
  54812. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54813. }
  54814. }
  54815. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54816. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54817. /** @hidden */
  54818. export var extractHighlightsPixelShader: {
  54819. name: string;
  54820. shader: string;
  54821. };
  54822. }
  54823. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54824. import { Nullable } from "babylonjs/types";
  54825. import { Camera } from "babylonjs/Cameras/camera";
  54826. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54827. import { Engine } from "babylonjs/Engines/engine";
  54828. import "babylonjs/Shaders/extractHighlights.fragment";
  54829. /**
  54830. * 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.
  54831. */
  54832. export class ExtractHighlightsPostProcess extends PostProcess {
  54833. /**
  54834. * The luminance threshold, pixels below this value will be set to black.
  54835. */
  54836. threshold: number;
  54837. /** @hidden */
  54838. _exposure: number;
  54839. /**
  54840. * Post process which has the input texture to be used when performing highlight extraction
  54841. * @hidden
  54842. */
  54843. _inputPostProcess: Nullable<PostProcess>;
  54844. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54845. }
  54846. }
  54847. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54848. /** @hidden */
  54849. export var bloomMergePixelShader: {
  54850. name: string;
  54851. shader: string;
  54852. };
  54853. }
  54854. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54855. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54856. import { Nullable } from "babylonjs/types";
  54857. import { Engine } from "babylonjs/Engines/engine";
  54858. import { Camera } from "babylonjs/Cameras/camera";
  54859. import "babylonjs/Shaders/bloomMerge.fragment";
  54860. /**
  54861. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54862. */
  54863. export class BloomMergePostProcess extends PostProcess {
  54864. /** Weight of the bloom to be added to the original input. */
  54865. weight: number;
  54866. /**
  54867. * Creates a new instance of @see BloomMergePostProcess
  54868. * @param name The name of the effect.
  54869. * @param originalFromInput Post process which's input will be used for the merge.
  54870. * @param blurred Blurred highlights post process which's output will be used.
  54871. * @param weight Weight of the bloom to be added to the original input.
  54872. * @param options The required width/height ratio to downsize to before computing the render pass.
  54873. * @param camera The camera to apply the render pass to.
  54874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54875. * @param engine The engine which the post process will be applied. (default: current engine)
  54876. * @param reusable If the post process can be reused on the same frame. (default: false)
  54877. * @param textureType Type of textures used when performing the post process. (default: 0)
  54878. * @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)
  54879. */
  54880. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54881. /** Weight of the bloom to be added to the original input. */
  54882. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54883. }
  54884. }
  54885. declare module "babylonjs/PostProcesses/bloomEffect" {
  54886. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54887. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54888. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54889. import { Camera } from "babylonjs/Cameras/camera";
  54890. import { Scene } from "babylonjs/scene";
  54891. /**
  54892. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54893. */
  54894. export class BloomEffect extends PostProcessRenderEffect {
  54895. private bloomScale;
  54896. /**
  54897. * @hidden Internal
  54898. */
  54899. _effects: Array<PostProcess>;
  54900. /**
  54901. * @hidden Internal
  54902. */
  54903. _downscale: ExtractHighlightsPostProcess;
  54904. private _blurX;
  54905. private _blurY;
  54906. private _merge;
  54907. /**
  54908. * The luminance threshold to find bright areas of the image to bloom.
  54909. */
  54910. threshold: number;
  54911. /**
  54912. * The strength of the bloom.
  54913. */
  54914. weight: number;
  54915. /**
  54916. * Specifies the size of the bloom blur kernel, relative to the final output size
  54917. */
  54918. kernel: number;
  54919. /**
  54920. * Creates a new instance of @see BloomEffect
  54921. * @param scene The scene the effect belongs to.
  54922. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54923. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54924. * @param bloomWeight The the strength of bloom.
  54925. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54926. * @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)
  54927. */
  54928. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54929. /**
  54930. * Disposes each of the internal effects for a given camera.
  54931. * @param camera The camera to dispose the effect on.
  54932. */
  54933. disposeEffects(camera: Camera): void;
  54934. /**
  54935. * @hidden Internal
  54936. */
  54937. _updateEffects(): void;
  54938. /**
  54939. * Internal
  54940. * @returns if all the contained post processes are ready.
  54941. * @hidden
  54942. */
  54943. _isReady(): boolean;
  54944. }
  54945. }
  54946. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54947. /** @hidden */
  54948. export var chromaticAberrationPixelShader: {
  54949. name: string;
  54950. shader: string;
  54951. };
  54952. }
  54953. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54954. import { Vector2 } from "babylonjs/Maths/math";
  54955. import { Nullable } from "babylonjs/types";
  54956. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54957. import { Camera } from "babylonjs/Cameras/camera";
  54958. import { Engine } from "babylonjs/Engines/engine";
  54959. import "babylonjs/Shaders/chromaticAberration.fragment";
  54960. /**
  54961. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54962. */
  54963. export class ChromaticAberrationPostProcess extends PostProcess {
  54964. /**
  54965. * The amount of seperation of rgb channels (default: 30)
  54966. */
  54967. aberrationAmount: number;
  54968. /**
  54969. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54970. */
  54971. radialIntensity: number;
  54972. /**
  54973. * 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))
  54974. */
  54975. direction: Vector2;
  54976. /**
  54977. * 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))
  54978. */
  54979. centerPosition: Vector2;
  54980. /**
  54981. * Creates a new instance ChromaticAberrationPostProcess
  54982. * @param name The name of the effect.
  54983. * @param screenWidth The width of the screen to apply the effect on.
  54984. * @param screenHeight The height of the screen to apply the effect on.
  54985. * @param options The required width/height ratio to downsize to before computing the render pass.
  54986. * @param camera The camera to apply the render pass to.
  54987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54988. * @param engine The engine which the post process will be applied. (default: current engine)
  54989. * @param reusable If the post process can be reused on the same frame. (default: false)
  54990. * @param textureType Type of textures used when performing the post process. (default: 0)
  54991. * @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)
  54992. */
  54993. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54994. }
  54995. }
  54996. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54997. /** @hidden */
  54998. export var circleOfConfusionPixelShader: {
  54999. name: string;
  55000. shader: string;
  55001. };
  55002. }
  55003. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  55004. import { Nullable } from "babylonjs/types";
  55005. import { Engine } from "babylonjs/Engines/engine";
  55006. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55007. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55008. import { Camera } from "babylonjs/Cameras/camera";
  55009. import "babylonjs/Shaders/circleOfConfusion.fragment";
  55010. /**
  55011. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55012. */
  55013. export class CircleOfConfusionPostProcess extends PostProcess {
  55014. /**
  55015. * 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.
  55016. */
  55017. lensSize: number;
  55018. /**
  55019. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55020. */
  55021. fStop: number;
  55022. /**
  55023. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55024. */
  55025. focusDistance: number;
  55026. /**
  55027. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55028. */
  55029. focalLength: number;
  55030. private _depthTexture;
  55031. /**
  55032. * Creates a new instance CircleOfConfusionPostProcess
  55033. * @param name The name of the effect.
  55034. * @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.
  55035. * @param options The required width/height ratio to downsize to before computing the render pass.
  55036. * @param camera The camera to apply the render pass to.
  55037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55038. * @param engine The engine which the post process will be applied. (default: current engine)
  55039. * @param reusable If the post process can be reused on the same frame. (default: false)
  55040. * @param textureType Type of textures used when performing the post process. (default: 0)
  55041. * @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)
  55042. */
  55043. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55044. /**
  55045. * 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.
  55046. */
  55047. depthTexture: RenderTargetTexture;
  55048. }
  55049. }
  55050. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  55051. /** @hidden */
  55052. export var colorCorrectionPixelShader: {
  55053. name: string;
  55054. shader: string;
  55055. };
  55056. }
  55057. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  55058. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55059. import { Engine } from "babylonjs/Engines/engine";
  55060. import { Camera } from "babylonjs/Cameras/camera";
  55061. import "babylonjs/Shaders/colorCorrection.fragment";
  55062. /**
  55063. *
  55064. * This post-process allows the modification of rendered colors by using
  55065. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55066. *
  55067. * The object needs to be provided an url to a texture containing the color
  55068. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55069. * Use an image editing software to tweak the LUT to match your needs.
  55070. *
  55071. * For an example of a color LUT, see here:
  55072. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55073. * For explanations on color grading, see here:
  55074. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55075. *
  55076. */
  55077. export class ColorCorrectionPostProcess extends PostProcess {
  55078. private _colorTableTexture;
  55079. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55080. }
  55081. }
  55082. declare module "babylonjs/Shaders/convolution.fragment" {
  55083. /** @hidden */
  55084. export var convolutionPixelShader: {
  55085. name: string;
  55086. shader: string;
  55087. };
  55088. }
  55089. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  55090. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55091. import { Nullable } from "babylonjs/types";
  55092. import { Camera } from "babylonjs/Cameras/camera";
  55093. import { Engine } from "babylonjs/Engines/engine";
  55094. import "babylonjs/Shaders/convolution.fragment";
  55095. /**
  55096. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55097. * input texture to perform effects such as edge detection or sharpening
  55098. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55099. */
  55100. export class ConvolutionPostProcess extends PostProcess {
  55101. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55102. kernel: number[];
  55103. /**
  55104. * Creates a new instance ConvolutionPostProcess
  55105. * @param name The name of the effect.
  55106. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  55107. * @param options The required width/height ratio to downsize to before computing the render pass.
  55108. * @param camera The camera to apply the render pass to.
  55109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55110. * @param engine The engine which the post process will be applied. (default: current engine)
  55111. * @param reusable If the post process can be reused on the same frame. (default: false)
  55112. * @param textureType Type of textures used when performing the post process. (default: 0)
  55113. */
  55114. constructor(name: string,
  55115. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55116. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55117. /**
  55118. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55119. */
  55120. static EdgeDetect0Kernel: number[];
  55121. /**
  55122. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55123. */
  55124. static EdgeDetect1Kernel: number[];
  55125. /**
  55126. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55127. */
  55128. static EdgeDetect2Kernel: number[];
  55129. /**
  55130. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55131. */
  55132. static SharpenKernel: number[];
  55133. /**
  55134. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55135. */
  55136. static EmbossKernel: number[];
  55137. /**
  55138. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55139. */
  55140. static GaussianKernel: number[];
  55141. }
  55142. }
  55143. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  55144. import { Nullable } from "babylonjs/types";
  55145. import { Vector2 } from "babylonjs/Maths/math";
  55146. import { Camera } from "babylonjs/Cameras/camera";
  55147. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55148. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55149. import { Engine } from "babylonjs/Engines/engine";
  55150. import { Scene } from "babylonjs/scene";
  55151. /**
  55152. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55153. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55154. * based on samples that have a large difference in distance than the center pixel.
  55155. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55156. */
  55157. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55158. direction: Vector2;
  55159. /**
  55160. * Creates a new instance CircleOfConfusionPostProcess
  55161. * @param name The name of the effect.
  55162. * @param scene The scene the effect belongs to.
  55163. * @param direction The direction the blur should be applied.
  55164. * @param kernel The size of the kernel used to blur.
  55165. * @param options The required width/height ratio to downsize to before computing the render pass.
  55166. * @param camera The camera to apply the render pass to.
  55167. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55168. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55170. * @param engine The engine which the post process will be applied. (default: current engine)
  55171. * @param reusable If the post process can be reused on the same frame. (default: false)
  55172. * @param textureType Type of textures used when performing the post process. (default: 0)
  55173. * @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)
  55174. */
  55175. 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);
  55176. }
  55177. }
  55178. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  55179. /** @hidden */
  55180. export var depthOfFieldMergePixelShader: {
  55181. name: string;
  55182. shader: string;
  55183. };
  55184. }
  55185. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  55186. import { Nullable } from "babylonjs/types";
  55187. import { Camera } from "babylonjs/Cameras/camera";
  55188. import { Effect } from "babylonjs/Materials/effect";
  55189. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55190. import { Engine } from "babylonjs/Engines/engine";
  55191. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  55192. /**
  55193. * Options to be set when merging outputs from the default pipeline.
  55194. */
  55195. export class DepthOfFieldMergePostProcessOptions {
  55196. /**
  55197. * The original image to merge on top of
  55198. */
  55199. originalFromInput: PostProcess;
  55200. /**
  55201. * Parameters to perform the merge of the depth of field effect
  55202. */
  55203. depthOfField?: {
  55204. circleOfConfusion: PostProcess;
  55205. blurSteps: Array<PostProcess>;
  55206. };
  55207. /**
  55208. * Parameters to perform the merge of bloom effect
  55209. */
  55210. bloom?: {
  55211. blurred: PostProcess;
  55212. weight: number;
  55213. };
  55214. }
  55215. /**
  55216. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55217. */
  55218. export class DepthOfFieldMergePostProcess extends PostProcess {
  55219. private blurSteps;
  55220. /**
  55221. * Creates a new instance of DepthOfFieldMergePostProcess
  55222. * @param name The name of the effect.
  55223. * @param originalFromInput Post process which's input will be used for the merge.
  55224. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55225. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55226. * @param options The required width/height ratio to downsize to before computing the render pass.
  55227. * @param camera The camera to apply the render pass to.
  55228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55229. * @param engine The engine which the post process will be applied. (default: current engine)
  55230. * @param reusable If the post process can be reused on the same frame. (default: false)
  55231. * @param textureType Type of textures used when performing the post process. (default: 0)
  55232. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  55233. */
  55234. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55235. /**
  55236. * Updates the effect with the current post process compile time values and recompiles the shader.
  55237. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55238. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55239. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55240. * @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
  55241. * @param onCompiled Called when the shader has been compiled.
  55242. * @param onError Called if there is an error when compiling a shader.
  55243. */
  55244. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55245. }
  55246. }
  55247. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55248. import { Nullable } from "babylonjs/types";
  55249. import { Camera } from "babylonjs/Cameras/camera";
  55250. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55251. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55252. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55253. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55254. import { Scene } from "babylonjs/scene";
  55255. /**
  55256. * Specifies the level of max blur that should be applied when using the depth of field effect
  55257. */
  55258. export enum DepthOfFieldEffectBlurLevel {
  55259. /**
  55260. * Subtle blur
  55261. */
  55262. Low = 0,
  55263. /**
  55264. * Medium blur
  55265. */
  55266. Medium = 1,
  55267. /**
  55268. * Large blur
  55269. */
  55270. High = 2
  55271. }
  55272. /**
  55273. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55274. */
  55275. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55276. private _circleOfConfusion;
  55277. /**
  55278. * @hidden Internal, blurs from high to low
  55279. */
  55280. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55281. private _depthOfFieldBlurY;
  55282. private _dofMerge;
  55283. /**
  55284. * @hidden Internal post processes in depth of field effect
  55285. */
  55286. _effects: Array<PostProcess>;
  55287. /**
  55288. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55289. */
  55290. focalLength: number;
  55291. /**
  55292. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55293. */
  55294. fStop: number;
  55295. /**
  55296. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55297. */
  55298. focusDistance: number;
  55299. /**
  55300. * 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.
  55301. */
  55302. lensSize: number;
  55303. /**
  55304. * Creates a new instance DepthOfFieldEffect
  55305. * @param scene The scene the effect belongs to.
  55306. * @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.
  55307. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55308. * @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)
  55309. */
  55310. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55311. /**
  55312. * Get the current class name of the current effet
  55313. * @returns "DepthOfFieldEffect"
  55314. */
  55315. getClassName(): string;
  55316. /**
  55317. * 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.
  55318. */
  55319. depthTexture: RenderTargetTexture;
  55320. /**
  55321. * Disposes each of the internal effects for a given camera.
  55322. * @param camera The camera to dispose the effect on.
  55323. */
  55324. disposeEffects(camera: Camera): void;
  55325. /**
  55326. * @hidden Internal
  55327. */
  55328. _updateEffects(): void;
  55329. /**
  55330. * Internal
  55331. * @returns if all the contained post processes are ready.
  55332. * @hidden
  55333. */
  55334. _isReady(): boolean;
  55335. }
  55336. }
  55337. declare module "babylonjs/Shaders/displayPass.fragment" {
  55338. /** @hidden */
  55339. export var displayPassPixelShader: {
  55340. name: string;
  55341. shader: string;
  55342. };
  55343. }
  55344. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55345. import { Nullable } from "babylonjs/types";
  55346. import { Camera } from "babylonjs/Cameras/camera";
  55347. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55348. import { Engine } from "babylonjs/Engines/engine";
  55349. import "babylonjs/Shaders/displayPass.fragment";
  55350. /**
  55351. * DisplayPassPostProcess which produces an output the same as it's input
  55352. */
  55353. export class DisplayPassPostProcess extends PostProcess {
  55354. /**
  55355. * Creates the DisplayPassPostProcess
  55356. * @param name The name of the effect.
  55357. * @param options The required width/height ratio to downsize to before computing the render pass.
  55358. * @param camera The camera to apply the render pass to.
  55359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55360. * @param engine The engine which the post process will be applied. (default: current engine)
  55361. * @param reusable If the post process can be reused on the same frame. (default: false)
  55362. */
  55363. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55364. }
  55365. }
  55366. declare module "babylonjs/Shaders/filter.fragment" {
  55367. /** @hidden */
  55368. export var filterPixelShader: {
  55369. name: string;
  55370. shader: string;
  55371. };
  55372. }
  55373. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55374. import { Nullable } from "babylonjs/types";
  55375. import { Matrix } from "babylonjs/Maths/math";
  55376. import { Camera } from "babylonjs/Cameras/camera";
  55377. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55378. import { Engine } from "babylonjs/Engines/engine";
  55379. import "babylonjs/Shaders/filter.fragment";
  55380. /**
  55381. * Applies a kernel filter to the image
  55382. */
  55383. export class FilterPostProcess extends PostProcess {
  55384. /** The matrix to be applied to the image */
  55385. kernelMatrix: Matrix;
  55386. /**
  55387. *
  55388. * @param name The name of the effect.
  55389. * @param kernelMatrix The matrix to be applied to the image
  55390. * @param options The required width/height ratio to downsize to before computing the render pass.
  55391. * @param camera The camera to apply the render pass to.
  55392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55393. * @param engine The engine which the post process will be applied. (default: current engine)
  55394. * @param reusable If the post process can be reused on the same frame. (default: false)
  55395. */
  55396. constructor(name: string,
  55397. /** The matrix to be applied to the image */
  55398. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55399. }
  55400. }
  55401. declare module "babylonjs/Shaders/fxaa.fragment" {
  55402. /** @hidden */
  55403. export var fxaaPixelShader: {
  55404. name: string;
  55405. shader: string;
  55406. };
  55407. }
  55408. declare module "babylonjs/Shaders/fxaa.vertex" {
  55409. /** @hidden */
  55410. export var fxaaVertexShader: {
  55411. name: string;
  55412. shader: string;
  55413. };
  55414. }
  55415. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55416. import { Nullable } from "babylonjs/types";
  55417. import { Camera } from "babylonjs/Cameras/camera";
  55418. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55419. import { Engine } from "babylonjs/Engines/engine";
  55420. import "babylonjs/Shaders/fxaa.fragment";
  55421. import "babylonjs/Shaders/fxaa.vertex";
  55422. /**
  55423. * Fxaa post process
  55424. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55425. */
  55426. export class FxaaPostProcess extends PostProcess {
  55427. /** @hidden */
  55428. texelWidth: number;
  55429. /** @hidden */
  55430. texelHeight: number;
  55431. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55432. private _getDefines;
  55433. }
  55434. }
  55435. declare module "babylonjs/Shaders/grain.fragment" {
  55436. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55437. /** @hidden */
  55438. export var grainPixelShader: {
  55439. name: string;
  55440. shader: string;
  55441. };
  55442. }
  55443. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55444. import { Nullable } from "babylonjs/types";
  55445. import { Camera } from "babylonjs/Cameras/camera";
  55446. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55447. import { Engine } from "babylonjs/Engines/engine";
  55448. import "babylonjs/Shaders/grain.fragment";
  55449. /**
  55450. * The GrainPostProcess adds noise to the image at mid luminance levels
  55451. */
  55452. export class GrainPostProcess extends PostProcess {
  55453. /**
  55454. * The intensity of the grain added (default: 30)
  55455. */
  55456. intensity: number;
  55457. /**
  55458. * If the grain should be randomized on every frame
  55459. */
  55460. animated: boolean;
  55461. /**
  55462. * Creates a new instance of @see GrainPostProcess
  55463. * @param name The name of the effect.
  55464. * @param options The required width/height ratio to downsize to before computing the render pass.
  55465. * @param camera The camera to apply the render pass to.
  55466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55467. * @param engine The engine which the post process will be applied. (default: current engine)
  55468. * @param reusable If the post process can be reused on the same frame. (default: false)
  55469. * @param textureType Type of textures used when performing the post process. (default: 0)
  55470. * @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)
  55471. */
  55472. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55473. }
  55474. }
  55475. declare module "babylonjs/Shaders/highlights.fragment" {
  55476. /** @hidden */
  55477. export var highlightsPixelShader: {
  55478. name: string;
  55479. shader: string;
  55480. };
  55481. }
  55482. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55483. import { Nullable } from "babylonjs/types";
  55484. import { Camera } from "babylonjs/Cameras/camera";
  55485. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55486. import { Engine } from "babylonjs/Engines/engine";
  55487. import "babylonjs/Shaders/highlights.fragment";
  55488. /**
  55489. * Extracts highlights from the image
  55490. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55491. */
  55492. export class HighlightsPostProcess extends PostProcess {
  55493. /**
  55494. * Extracts highlights from the image
  55495. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55496. * @param name The name of the effect.
  55497. * @param options The required width/height ratio to downsize to before computing the render pass.
  55498. * @param camera The camera to apply the render pass to.
  55499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55500. * @param engine The engine which the post process will be applied. (default: current engine)
  55501. * @param reusable If the post process can be reused on the same frame. (default: false)
  55502. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55503. */
  55504. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55505. }
  55506. }
  55507. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55508. /** @hidden */
  55509. export var mrtFragmentDeclaration: {
  55510. name: string;
  55511. shader: string;
  55512. };
  55513. }
  55514. declare module "babylonjs/Shaders/geometry.fragment" {
  55515. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55516. /** @hidden */
  55517. export var geometryPixelShader: {
  55518. name: string;
  55519. shader: string;
  55520. };
  55521. }
  55522. declare module "babylonjs/Shaders/geometry.vertex" {
  55523. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55524. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55525. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55526. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55527. /** @hidden */
  55528. export var geometryVertexShader: {
  55529. name: string;
  55530. shader: string;
  55531. };
  55532. }
  55533. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55534. import { Matrix } from "babylonjs/Maths/math";
  55535. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55536. import { Mesh } from "babylonjs/Meshes/mesh";
  55537. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55538. import { Effect } from "babylonjs/Materials/effect";
  55539. import { Scene } from "babylonjs/scene";
  55540. import "babylonjs/Shaders/geometry.fragment";
  55541. import "babylonjs/Shaders/geometry.vertex";
  55542. /**
  55543. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55544. */
  55545. export class GeometryBufferRenderer {
  55546. /**
  55547. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55548. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55549. */
  55550. static readonly POSITION_TEXTURE_TYPE: number;
  55551. /**
  55552. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55553. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55554. */
  55555. static readonly VELOCITY_TEXTURE_TYPE: number;
  55556. /**
  55557. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55558. * in order to compute objects velocities when enableVelocity is set to "true"
  55559. * @hidden
  55560. */
  55561. _previousTransformationMatrices: {
  55562. [index: number]: Matrix;
  55563. };
  55564. private _scene;
  55565. private _multiRenderTarget;
  55566. private _ratio;
  55567. private _enablePosition;
  55568. private _enableVelocity;
  55569. private _positionIndex;
  55570. private _velocityIndex;
  55571. protected _effect: Effect;
  55572. protected _cachedDefines: string;
  55573. /**
  55574. * Set the render list (meshes to be rendered) used in the G buffer.
  55575. */
  55576. renderList: Mesh[];
  55577. /**
  55578. * Gets wether or not G buffer are supported by the running hardware.
  55579. * This requires draw buffer supports
  55580. */
  55581. readonly isSupported: boolean;
  55582. /**
  55583. * Returns the index of the given texture type in the G-Buffer textures array
  55584. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55585. * @returns the index of the given texture type in the G-Buffer textures array
  55586. */
  55587. getTextureIndex(textureType: number): number;
  55588. /**
  55589. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55590. */
  55591. /**
  55592. * Sets whether or not objects positions are enabled for the G buffer.
  55593. */
  55594. enablePosition: boolean;
  55595. /**
  55596. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55597. */
  55598. /**
  55599. * Sets wether or not objects velocities are enabled for the G buffer.
  55600. */
  55601. enableVelocity: boolean;
  55602. /**
  55603. * Gets the scene associated with the buffer.
  55604. */
  55605. readonly scene: Scene;
  55606. /**
  55607. * Gets the ratio used by the buffer during its creation.
  55608. * How big is the buffer related to the main canvas.
  55609. */
  55610. readonly ratio: number;
  55611. /** @hidden */
  55612. static _SceneComponentInitialization: (scene: Scene) => void;
  55613. /**
  55614. * Creates a new G Buffer for the scene
  55615. * @param scene The scene the buffer belongs to
  55616. * @param ratio How big is the buffer related to the main canvas.
  55617. */
  55618. constructor(scene: Scene, ratio?: number);
  55619. /**
  55620. * Checks wether everything is ready to render a submesh to the G buffer.
  55621. * @param subMesh the submesh to check readiness for
  55622. * @param useInstances is the mesh drawn using instance or not
  55623. * @returns true if ready otherwise false
  55624. */
  55625. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55626. /**
  55627. * Gets the current underlying G Buffer.
  55628. * @returns the buffer
  55629. */
  55630. getGBuffer(): MultiRenderTarget;
  55631. /**
  55632. * Gets the number of samples used to render the buffer (anti aliasing).
  55633. */
  55634. /**
  55635. * Sets the number of samples used to render the buffer (anti aliasing).
  55636. */
  55637. samples: number;
  55638. /**
  55639. * Disposes the renderer and frees up associated resources.
  55640. */
  55641. dispose(): void;
  55642. protected _createRenderTargets(): void;
  55643. }
  55644. }
  55645. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55646. import { Nullable } from "babylonjs/types";
  55647. import { Scene } from "babylonjs/scene";
  55648. import { ISceneComponent } from "babylonjs/sceneComponent";
  55649. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55650. module "babylonjs/scene" {
  55651. interface Scene {
  55652. /** @hidden (Backing field) */
  55653. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55654. /**
  55655. * Gets or Sets the current geometry buffer associated to the scene.
  55656. */
  55657. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55658. /**
  55659. * Enables a GeometryBufferRender and associates it with the scene
  55660. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55661. * @returns the GeometryBufferRenderer
  55662. */
  55663. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55664. /**
  55665. * Disables the GeometryBufferRender associated with the scene
  55666. */
  55667. disableGeometryBufferRenderer(): void;
  55668. }
  55669. }
  55670. /**
  55671. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55672. * in several rendering techniques.
  55673. */
  55674. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55675. /**
  55676. * The component name helpful to identify the component in the list of scene components.
  55677. */
  55678. readonly name: string;
  55679. /**
  55680. * The scene the component belongs to.
  55681. */
  55682. scene: Scene;
  55683. /**
  55684. * Creates a new instance of the component for the given scene
  55685. * @param scene Defines the scene to register the component in
  55686. */
  55687. constructor(scene: Scene);
  55688. /**
  55689. * Registers the component in a given scene
  55690. */
  55691. register(): void;
  55692. /**
  55693. * Rebuilds the elements related to this component in case of
  55694. * context lost for instance.
  55695. */
  55696. rebuild(): void;
  55697. /**
  55698. * Disposes the component and the associated ressources
  55699. */
  55700. dispose(): void;
  55701. private _gatherRenderTargets;
  55702. }
  55703. }
  55704. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55705. /** @hidden */
  55706. export var motionBlurPixelShader: {
  55707. name: string;
  55708. shader: string;
  55709. };
  55710. }
  55711. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55712. import { Nullable } from "babylonjs/types";
  55713. import { Camera } from "babylonjs/Cameras/camera";
  55714. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55715. import { Scene } from "babylonjs/scene";
  55716. import "babylonjs/Animations/animatable";
  55717. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55718. import "babylonjs/Shaders/motionBlur.fragment";
  55719. import { Engine } from "babylonjs/Engines/engine";
  55720. /**
  55721. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55722. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55723. * As an example, all you have to do is to create the post-process:
  55724. * var mb = new BABYLON.MotionBlurPostProcess(
  55725. * 'mb', // The name of the effect.
  55726. * scene, // The scene containing the objects to blur according to their velocity.
  55727. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55728. * camera // The camera to apply the render pass to.
  55729. * );
  55730. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55731. */
  55732. export class MotionBlurPostProcess extends PostProcess {
  55733. /**
  55734. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55735. */
  55736. motionStrength: number;
  55737. /**
  55738. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55739. */
  55740. /**
  55741. * Sets the number of iterations to be used for motion blur quality
  55742. */
  55743. motionBlurSamples: number;
  55744. private _motionBlurSamples;
  55745. private _geometryBufferRenderer;
  55746. /**
  55747. * Creates a new instance MotionBlurPostProcess
  55748. * @param name The name of the effect.
  55749. * @param scene The scene containing the objects to blur according to their velocity.
  55750. * @param options The required width/height ratio to downsize to before computing the render pass.
  55751. * @param camera The camera to apply the render pass to.
  55752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55753. * @param engine The engine which the post process will be applied. (default: current engine)
  55754. * @param reusable If the post process can be reused on the same frame. (default: false)
  55755. * @param textureType Type of textures used when performing the post process. (default: 0)
  55756. * @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)
  55757. */
  55758. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55759. /**
  55760. * Disposes the post process.
  55761. * @param camera The camera to dispose the post process on.
  55762. */
  55763. dispose(camera?: Camera): void;
  55764. }
  55765. }
  55766. declare module "babylonjs/Shaders/refraction.fragment" {
  55767. /** @hidden */
  55768. export var refractionPixelShader: {
  55769. name: string;
  55770. shader: string;
  55771. };
  55772. }
  55773. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55774. import { Color3 } from "babylonjs/Maths/math";
  55775. import { Camera } from "babylonjs/Cameras/camera";
  55776. import { Texture } from "babylonjs/Materials/Textures/texture";
  55777. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55778. import { Engine } from "babylonjs/Engines/engine";
  55779. import "babylonjs/Shaders/refraction.fragment";
  55780. /**
  55781. * Post process which applies a refractin texture
  55782. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55783. */
  55784. export class RefractionPostProcess extends PostProcess {
  55785. /** the base color of the refraction (used to taint the rendering) */
  55786. color: Color3;
  55787. /** simulated refraction depth */
  55788. depth: number;
  55789. /** the coefficient of the base color (0 to remove base color tainting) */
  55790. colorLevel: number;
  55791. private _refTexture;
  55792. private _ownRefractionTexture;
  55793. /**
  55794. * Gets or sets the refraction texture
  55795. * Please note that you are responsible for disposing the texture if you set it manually
  55796. */
  55797. refractionTexture: Texture;
  55798. /**
  55799. * Initializes the RefractionPostProcess
  55800. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55801. * @param name The name of the effect.
  55802. * @param refractionTextureUrl Url of the refraction texture to use
  55803. * @param color the base color of the refraction (used to taint the rendering)
  55804. * @param depth simulated refraction depth
  55805. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55806. * @param camera The camera to apply the render pass to.
  55807. * @param options The required width/height ratio to downsize to before computing the render pass.
  55808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55809. * @param engine The engine which the post process will be applied. (default: current engine)
  55810. * @param reusable If the post process can be reused on the same frame. (default: false)
  55811. */
  55812. constructor(name: string, refractionTextureUrl: string,
  55813. /** the base color of the refraction (used to taint the rendering) */
  55814. color: Color3,
  55815. /** simulated refraction depth */
  55816. depth: number,
  55817. /** the coefficient of the base color (0 to remove base color tainting) */
  55818. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55819. /**
  55820. * Disposes of the post process
  55821. * @param camera Camera to dispose post process on
  55822. */
  55823. dispose(camera: Camera): void;
  55824. }
  55825. }
  55826. declare module "babylonjs/Shaders/sharpen.fragment" {
  55827. /** @hidden */
  55828. export var sharpenPixelShader: {
  55829. name: string;
  55830. shader: string;
  55831. };
  55832. }
  55833. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55834. import { Nullable } from "babylonjs/types";
  55835. import { Camera } from "babylonjs/Cameras/camera";
  55836. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55837. import "babylonjs/Shaders/sharpen.fragment";
  55838. import { Engine } from "babylonjs/Engines/engine";
  55839. /**
  55840. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55841. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55842. */
  55843. export class SharpenPostProcess extends PostProcess {
  55844. /**
  55845. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55846. */
  55847. colorAmount: number;
  55848. /**
  55849. * How much sharpness should be applied (default: 0.3)
  55850. */
  55851. edgeAmount: number;
  55852. /**
  55853. * Creates a new instance ConvolutionPostProcess
  55854. * @param name The name of the effect.
  55855. * @param options The required width/height ratio to downsize to before computing the render pass.
  55856. * @param camera The camera to apply the render pass to.
  55857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55858. * @param engine The engine which the post process will be applied. (default: current engine)
  55859. * @param reusable If the post process can be reused on the same frame. (default: false)
  55860. * @param textureType Type of textures used when performing the post process. (default: 0)
  55861. * @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)
  55862. */
  55863. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55864. }
  55865. }
  55866. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55867. import { Nullable } from "babylonjs/types";
  55868. import { Camera } from "babylonjs/Cameras/camera";
  55869. import { Engine } from "babylonjs/Engines/engine";
  55870. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55871. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55872. /**
  55873. * PostProcessRenderPipeline
  55874. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55875. */
  55876. export class PostProcessRenderPipeline {
  55877. private engine;
  55878. private _renderEffects;
  55879. private _renderEffectsForIsolatedPass;
  55880. /**
  55881. * List of inspectable custom properties (used by the Inspector)
  55882. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55883. */
  55884. inspectableCustomProperties: IInspectable[];
  55885. /**
  55886. * @hidden
  55887. */
  55888. protected _cameras: Camera[];
  55889. /** @hidden */
  55890. _name: string;
  55891. /**
  55892. * Gets pipeline name
  55893. */
  55894. readonly name: string;
  55895. /**
  55896. * Initializes a PostProcessRenderPipeline
  55897. * @param engine engine to add the pipeline to
  55898. * @param name name of the pipeline
  55899. */
  55900. constructor(engine: Engine, name: string);
  55901. /**
  55902. * Gets the class name
  55903. * @returns "PostProcessRenderPipeline"
  55904. */
  55905. getClassName(): string;
  55906. /**
  55907. * If all the render effects in the pipeline are supported
  55908. */
  55909. readonly isSupported: boolean;
  55910. /**
  55911. * Adds an effect to the pipeline
  55912. * @param renderEffect the effect to add
  55913. */
  55914. addEffect(renderEffect: PostProcessRenderEffect): void;
  55915. /** @hidden */
  55916. _rebuild(): void;
  55917. /** @hidden */
  55918. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55919. /** @hidden */
  55920. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55921. /** @hidden */
  55922. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55923. /** @hidden */
  55924. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55925. /** @hidden */
  55926. _attachCameras(cameras: Camera, unique: boolean): void;
  55927. /** @hidden */
  55928. _attachCameras(cameras: Camera[], unique: boolean): void;
  55929. /** @hidden */
  55930. _detachCameras(cameras: Camera): void;
  55931. /** @hidden */
  55932. _detachCameras(cameras: Nullable<Camera[]>): void;
  55933. /** @hidden */
  55934. _update(): void;
  55935. /** @hidden */
  55936. _reset(): void;
  55937. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55938. /**
  55939. * Disposes of the pipeline
  55940. */
  55941. dispose(): void;
  55942. }
  55943. }
  55944. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55945. import { Camera } from "babylonjs/Cameras/camera";
  55946. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55947. /**
  55948. * PostProcessRenderPipelineManager class
  55949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55950. */
  55951. export class PostProcessRenderPipelineManager {
  55952. private _renderPipelines;
  55953. /**
  55954. * Initializes a PostProcessRenderPipelineManager
  55955. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55956. */
  55957. constructor();
  55958. /**
  55959. * Gets the list of supported render pipelines
  55960. */
  55961. readonly supportedPipelines: PostProcessRenderPipeline[];
  55962. /**
  55963. * Adds a pipeline to the manager
  55964. * @param renderPipeline The pipeline to add
  55965. */
  55966. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55967. /**
  55968. * Attaches a camera to the pipeline
  55969. * @param renderPipelineName The name of the pipeline to attach to
  55970. * @param cameras the camera to attach
  55971. * @param unique if the camera can be attached multiple times to the pipeline
  55972. */
  55973. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55974. /**
  55975. * Detaches a camera from the pipeline
  55976. * @param renderPipelineName The name of the pipeline to detach from
  55977. * @param cameras the camera to detach
  55978. */
  55979. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55980. /**
  55981. * Enables an effect by name on a pipeline
  55982. * @param renderPipelineName the name of the pipeline to enable the effect in
  55983. * @param renderEffectName the name of the effect to enable
  55984. * @param cameras the cameras that the effect should be enabled on
  55985. */
  55986. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55987. /**
  55988. * Disables an effect by name on a pipeline
  55989. * @param renderPipelineName the name of the pipeline to disable the effect in
  55990. * @param renderEffectName the name of the effect to disable
  55991. * @param cameras the cameras that the effect should be disabled on
  55992. */
  55993. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55994. /**
  55995. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55996. */
  55997. update(): void;
  55998. /** @hidden */
  55999. _rebuild(): void;
  56000. /**
  56001. * Disposes of the manager and pipelines
  56002. */
  56003. dispose(): void;
  56004. }
  56005. }
  56006. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  56007. import { ISceneComponent } from "babylonjs/sceneComponent";
  56008. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56009. import { Scene } from "babylonjs/scene";
  56010. module "babylonjs/scene" {
  56011. interface Scene {
  56012. /** @hidden (Backing field) */
  56013. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56014. /**
  56015. * Gets the postprocess render pipeline manager
  56016. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56017. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56018. */
  56019. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56020. }
  56021. }
  56022. /**
  56023. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56024. */
  56025. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56026. /**
  56027. * The component name helpfull to identify the component in the list of scene components.
  56028. */
  56029. readonly name: string;
  56030. /**
  56031. * The scene the component belongs to.
  56032. */
  56033. scene: Scene;
  56034. /**
  56035. * Creates a new instance of the component for the given scene
  56036. * @param scene Defines the scene to register the component in
  56037. */
  56038. constructor(scene: Scene);
  56039. /**
  56040. * Registers the component in a given scene
  56041. */
  56042. register(): void;
  56043. /**
  56044. * Rebuilds the elements related to this component in case of
  56045. * context lost for instance.
  56046. */
  56047. rebuild(): void;
  56048. /**
  56049. * Disposes the component and the associated ressources
  56050. */
  56051. dispose(): void;
  56052. private _gatherRenderTargets;
  56053. }
  56054. }
  56055. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  56056. import { IAnimatable } from "babylonjs/Misc/tools";
  56057. import { Camera } from "babylonjs/Cameras/camera";
  56058. import { IDisposable } from "babylonjs/scene";
  56059. import { Scene } from "babylonjs/scene";
  56060. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  56061. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56062. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56063. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  56064. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56065. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56066. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  56067. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56068. import { Animation } from "babylonjs/Animations/animation";
  56069. /**
  56070. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56071. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56072. */
  56073. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56074. private _scene;
  56075. private _camerasToBeAttached;
  56076. /**
  56077. * ID of the sharpen post process,
  56078. */
  56079. private readonly SharpenPostProcessId;
  56080. /**
  56081. * @ignore
  56082. * ID of the image processing post process;
  56083. */
  56084. readonly ImageProcessingPostProcessId: string;
  56085. /**
  56086. * @ignore
  56087. * ID of the Fast Approximate Anti-Aliasing post process;
  56088. */
  56089. readonly FxaaPostProcessId: string;
  56090. /**
  56091. * ID of the chromatic aberration post process,
  56092. */
  56093. private readonly ChromaticAberrationPostProcessId;
  56094. /**
  56095. * ID of the grain post process
  56096. */
  56097. private readonly GrainPostProcessId;
  56098. /**
  56099. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56100. */
  56101. sharpen: SharpenPostProcess;
  56102. private _sharpenEffect;
  56103. private bloom;
  56104. /**
  56105. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56106. */
  56107. depthOfField: DepthOfFieldEffect;
  56108. /**
  56109. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56110. */
  56111. fxaa: FxaaPostProcess;
  56112. /**
  56113. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56114. */
  56115. imageProcessing: ImageProcessingPostProcess;
  56116. /**
  56117. * Chromatic aberration post process which will shift rgb colors in the image
  56118. */
  56119. chromaticAberration: ChromaticAberrationPostProcess;
  56120. private _chromaticAberrationEffect;
  56121. /**
  56122. * Grain post process which add noise to the image
  56123. */
  56124. grain: GrainPostProcess;
  56125. private _grainEffect;
  56126. /**
  56127. * Glow post process which adds a glow to emissive areas of the image
  56128. */
  56129. private _glowLayer;
  56130. /**
  56131. * Animations which can be used to tweak settings over a period of time
  56132. */
  56133. animations: Animation[];
  56134. private _imageProcessingConfigurationObserver;
  56135. private _sharpenEnabled;
  56136. private _bloomEnabled;
  56137. private _depthOfFieldEnabled;
  56138. private _depthOfFieldBlurLevel;
  56139. private _fxaaEnabled;
  56140. private _imageProcessingEnabled;
  56141. private _defaultPipelineTextureType;
  56142. private _bloomScale;
  56143. private _chromaticAberrationEnabled;
  56144. private _grainEnabled;
  56145. private _buildAllowed;
  56146. /**
  56147. * Gets active scene
  56148. */
  56149. readonly scene: Scene;
  56150. /**
  56151. * Enable or disable the sharpen process from the pipeline
  56152. */
  56153. sharpenEnabled: boolean;
  56154. private _resizeObserver;
  56155. private _hardwareScaleLevel;
  56156. private _bloomKernel;
  56157. /**
  56158. * Specifies the size of the bloom blur kernel, relative to the final output size
  56159. */
  56160. bloomKernel: number;
  56161. /**
  56162. * Specifies the weight of the bloom in the final rendering
  56163. */
  56164. private _bloomWeight;
  56165. /**
  56166. * Specifies the luma threshold for the area that will be blurred by the bloom
  56167. */
  56168. private _bloomThreshold;
  56169. private _hdr;
  56170. /**
  56171. * The strength of the bloom.
  56172. */
  56173. bloomWeight: number;
  56174. /**
  56175. * The strength of the bloom.
  56176. */
  56177. bloomThreshold: number;
  56178. /**
  56179. * The scale of the bloom, lower value will provide better performance.
  56180. */
  56181. bloomScale: number;
  56182. /**
  56183. * Enable or disable the bloom from the pipeline
  56184. */
  56185. bloomEnabled: boolean;
  56186. private _rebuildBloom;
  56187. /**
  56188. * If the depth of field is enabled.
  56189. */
  56190. depthOfFieldEnabled: boolean;
  56191. /**
  56192. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56193. */
  56194. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56195. /**
  56196. * If the anti aliasing is enabled.
  56197. */
  56198. fxaaEnabled: boolean;
  56199. private _samples;
  56200. /**
  56201. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56202. */
  56203. samples: number;
  56204. /**
  56205. * If image processing is enabled.
  56206. */
  56207. imageProcessingEnabled: boolean;
  56208. /**
  56209. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56210. */
  56211. glowLayerEnabled: boolean;
  56212. /**
  56213. * Enable or disable the chromaticAberration process from the pipeline
  56214. */
  56215. chromaticAberrationEnabled: boolean;
  56216. /**
  56217. * Enable or disable the grain process from the pipeline
  56218. */
  56219. grainEnabled: boolean;
  56220. /**
  56221. * @constructor
  56222. * @param name - The rendering pipeline name (default: "")
  56223. * @param hdr - If high dynamic range textures should be used (default: true)
  56224. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56225. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56226. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56227. */
  56228. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56229. /**
  56230. * Get the class name
  56231. * @returns "DefaultRenderingPipeline"
  56232. */
  56233. getClassName(): string;
  56234. /**
  56235. * Force the compilation of the entire pipeline.
  56236. */
  56237. prepare(): void;
  56238. private _hasCleared;
  56239. private _prevPostProcess;
  56240. private _prevPrevPostProcess;
  56241. private _setAutoClearAndTextureSharing;
  56242. private _depthOfFieldSceneObserver;
  56243. private _buildPipeline;
  56244. private _disposePostProcesses;
  56245. /**
  56246. * Adds a camera to the pipeline
  56247. * @param camera the camera to be added
  56248. */
  56249. addCamera(camera: Camera): void;
  56250. /**
  56251. * Removes a camera from the pipeline
  56252. * @param camera the camera to remove
  56253. */
  56254. removeCamera(camera: Camera): void;
  56255. /**
  56256. * Dispose of the pipeline and stop all post processes
  56257. */
  56258. dispose(): void;
  56259. /**
  56260. * Serialize the rendering pipeline (Used when exporting)
  56261. * @returns the serialized object
  56262. */
  56263. serialize(): any;
  56264. /**
  56265. * Parse the serialized pipeline
  56266. * @param source Source pipeline.
  56267. * @param scene The scene to load the pipeline to.
  56268. * @param rootUrl The URL of the serialized pipeline.
  56269. * @returns An instantiated pipeline from the serialized object.
  56270. */
  56271. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56272. }
  56273. }
  56274. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56275. /** @hidden */
  56276. export var lensHighlightsPixelShader: {
  56277. name: string;
  56278. shader: string;
  56279. };
  56280. }
  56281. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56282. /** @hidden */
  56283. export var depthOfFieldPixelShader: {
  56284. name: string;
  56285. shader: string;
  56286. };
  56287. }
  56288. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56289. import { Camera } from "babylonjs/Cameras/camera";
  56290. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56291. import { Scene } from "babylonjs/scene";
  56292. import "babylonjs/Shaders/chromaticAberration.fragment";
  56293. import "babylonjs/Shaders/lensHighlights.fragment";
  56294. import "babylonjs/Shaders/depthOfField.fragment";
  56295. /**
  56296. * BABYLON.JS Chromatic Aberration GLSL Shader
  56297. * Author: Olivier Guyot
  56298. * Separates very slightly R, G and B colors on the edges of the screen
  56299. * Inspired by Francois Tarlier & Martins Upitis
  56300. */
  56301. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56302. /**
  56303. * @ignore
  56304. * The chromatic aberration PostProcess id in the pipeline
  56305. */
  56306. LensChromaticAberrationEffect: string;
  56307. /**
  56308. * @ignore
  56309. * The highlights enhancing PostProcess id in the pipeline
  56310. */
  56311. HighlightsEnhancingEffect: string;
  56312. /**
  56313. * @ignore
  56314. * The depth-of-field PostProcess id in the pipeline
  56315. */
  56316. LensDepthOfFieldEffect: string;
  56317. private _scene;
  56318. private _depthTexture;
  56319. private _grainTexture;
  56320. private _chromaticAberrationPostProcess;
  56321. private _highlightsPostProcess;
  56322. private _depthOfFieldPostProcess;
  56323. private _edgeBlur;
  56324. private _grainAmount;
  56325. private _chromaticAberration;
  56326. private _distortion;
  56327. private _highlightsGain;
  56328. private _highlightsThreshold;
  56329. private _dofDistance;
  56330. private _dofAperture;
  56331. private _dofDarken;
  56332. private _dofPentagon;
  56333. private _blurNoise;
  56334. /**
  56335. * @constructor
  56336. *
  56337. * Effect parameters are as follow:
  56338. * {
  56339. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56340. * edge_blur: number; // from 0 to x (1 for realism)
  56341. * distortion: number; // from 0 to x (1 for realism)
  56342. * grain_amount: number; // from 0 to 1
  56343. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56344. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56345. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56346. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56347. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56348. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56349. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56350. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56351. * }
  56352. * Note: if an effect parameter is unset, effect is disabled
  56353. *
  56354. * @param name The rendering pipeline name
  56355. * @param parameters - An object containing all parameters (see above)
  56356. * @param scene The scene linked to this pipeline
  56357. * @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)
  56358. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56359. */
  56360. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56361. /**
  56362. * Get the class name
  56363. * @returns "LensRenderingPipeline"
  56364. */
  56365. getClassName(): string;
  56366. /**
  56367. * Gets associated scene
  56368. */
  56369. readonly scene: Scene;
  56370. /**
  56371. * Gets or sets the edge blur
  56372. */
  56373. edgeBlur: number;
  56374. /**
  56375. * Gets or sets the grain amount
  56376. */
  56377. grainAmount: number;
  56378. /**
  56379. * Gets or sets the chromatic aberration amount
  56380. */
  56381. chromaticAberration: number;
  56382. /**
  56383. * Gets or sets the depth of field aperture
  56384. */
  56385. dofAperture: number;
  56386. /**
  56387. * Gets or sets the edge distortion
  56388. */
  56389. edgeDistortion: number;
  56390. /**
  56391. * Gets or sets the depth of field distortion
  56392. */
  56393. dofDistortion: number;
  56394. /**
  56395. * Gets or sets the darken out of focus amount
  56396. */
  56397. darkenOutOfFocus: number;
  56398. /**
  56399. * Gets or sets a boolean indicating if blur noise is enabled
  56400. */
  56401. blurNoise: boolean;
  56402. /**
  56403. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56404. */
  56405. pentagonBokeh: boolean;
  56406. /**
  56407. * Gets or sets the highlight grain amount
  56408. */
  56409. highlightsGain: number;
  56410. /**
  56411. * Gets or sets the highlight threshold
  56412. */
  56413. highlightsThreshold: number;
  56414. /**
  56415. * Sets the amount of blur at the edges
  56416. * @param amount blur amount
  56417. */
  56418. setEdgeBlur(amount: number): void;
  56419. /**
  56420. * Sets edge blur to 0
  56421. */
  56422. disableEdgeBlur(): void;
  56423. /**
  56424. * Sets the amout of grain
  56425. * @param amount Amount of grain
  56426. */
  56427. setGrainAmount(amount: number): void;
  56428. /**
  56429. * Set grain amount to 0
  56430. */
  56431. disableGrain(): void;
  56432. /**
  56433. * Sets the chromatic aberration amount
  56434. * @param amount amount of chromatic aberration
  56435. */
  56436. setChromaticAberration(amount: number): void;
  56437. /**
  56438. * Sets chromatic aberration amount to 0
  56439. */
  56440. disableChromaticAberration(): void;
  56441. /**
  56442. * Sets the EdgeDistortion amount
  56443. * @param amount amount of EdgeDistortion
  56444. */
  56445. setEdgeDistortion(amount: number): void;
  56446. /**
  56447. * Sets edge distortion to 0
  56448. */
  56449. disableEdgeDistortion(): void;
  56450. /**
  56451. * Sets the FocusDistance amount
  56452. * @param amount amount of FocusDistance
  56453. */
  56454. setFocusDistance(amount: number): void;
  56455. /**
  56456. * Disables depth of field
  56457. */
  56458. disableDepthOfField(): void;
  56459. /**
  56460. * Sets the Aperture amount
  56461. * @param amount amount of Aperture
  56462. */
  56463. setAperture(amount: number): void;
  56464. /**
  56465. * Sets the DarkenOutOfFocus amount
  56466. * @param amount amount of DarkenOutOfFocus
  56467. */
  56468. setDarkenOutOfFocus(amount: number): void;
  56469. private _pentagonBokehIsEnabled;
  56470. /**
  56471. * Creates a pentagon bokeh effect
  56472. */
  56473. enablePentagonBokeh(): void;
  56474. /**
  56475. * Disables the pentagon bokeh effect
  56476. */
  56477. disablePentagonBokeh(): void;
  56478. /**
  56479. * Enables noise blur
  56480. */
  56481. enableNoiseBlur(): void;
  56482. /**
  56483. * Disables noise blur
  56484. */
  56485. disableNoiseBlur(): void;
  56486. /**
  56487. * Sets the HighlightsGain amount
  56488. * @param amount amount of HighlightsGain
  56489. */
  56490. setHighlightsGain(amount: number): void;
  56491. /**
  56492. * Sets the HighlightsThreshold amount
  56493. * @param amount amount of HighlightsThreshold
  56494. */
  56495. setHighlightsThreshold(amount: number): void;
  56496. /**
  56497. * Disables highlights
  56498. */
  56499. disableHighlights(): void;
  56500. /**
  56501. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56502. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56503. */
  56504. dispose(disableDepthRender?: boolean): void;
  56505. private _createChromaticAberrationPostProcess;
  56506. private _createHighlightsPostProcess;
  56507. private _createDepthOfFieldPostProcess;
  56508. private _createGrainTexture;
  56509. }
  56510. }
  56511. declare module "babylonjs/Shaders/ssao2.fragment" {
  56512. /** @hidden */
  56513. export var ssao2PixelShader: {
  56514. name: string;
  56515. shader: string;
  56516. };
  56517. }
  56518. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56519. /** @hidden */
  56520. export var ssaoCombinePixelShader: {
  56521. name: string;
  56522. shader: string;
  56523. };
  56524. }
  56525. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56526. import { Camera } from "babylonjs/Cameras/camera";
  56527. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56528. import { Scene } from "babylonjs/scene";
  56529. import "babylonjs/Shaders/ssao2.fragment";
  56530. import "babylonjs/Shaders/ssaoCombine.fragment";
  56531. /**
  56532. * Render pipeline to produce ssao effect
  56533. */
  56534. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56535. /**
  56536. * @ignore
  56537. * The PassPostProcess id in the pipeline that contains the original scene color
  56538. */
  56539. SSAOOriginalSceneColorEffect: string;
  56540. /**
  56541. * @ignore
  56542. * The SSAO PostProcess id in the pipeline
  56543. */
  56544. SSAORenderEffect: string;
  56545. /**
  56546. * @ignore
  56547. * The horizontal blur PostProcess id in the pipeline
  56548. */
  56549. SSAOBlurHRenderEffect: string;
  56550. /**
  56551. * @ignore
  56552. * The vertical blur PostProcess id in the pipeline
  56553. */
  56554. SSAOBlurVRenderEffect: string;
  56555. /**
  56556. * @ignore
  56557. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56558. */
  56559. SSAOCombineRenderEffect: string;
  56560. /**
  56561. * The output strength of the SSAO post-process. Default value is 1.0.
  56562. */
  56563. totalStrength: number;
  56564. /**
  56565. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56566. */
  56567. maxZ: number;
  56568. /**
  56569. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56570. */
  56571. minZAspect: number;
  56572. private _samples;
  56573. /**
  56574. * Number of samples used for the SSAO calculations. Default value is 8
  56575. */
  56576. samples: number;
  56577. private _textureSamples;
  56578. /**
  56579. * Number of samples to use for antialiasing
  56580. */
  56581. textureSamples: number;
  56582. /**
  56583. * Ratio object used for SSAO ratio and blur ratio
  56584. */
  56585. private _ratio;
  56586. /**
  56587. * Dynamically generated sphere sampler.
  56588. */
  56589. private _sampleSphere;
  56590. /**
  56591. * Blur filter offsets
  56592. */
  56593. private _samplerOffsets;
  56594. private _expensiveBlur;
  56595. /**
  56596. * If bilateral blur should be used
  56597. */
  56598. expensiveBlur: boolean;
  56599. /**
  56600. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56601. */
  56602. radius: number;
  56603. /**
  56604. * The base color of the SSAO post-process
  56605. * The final result is "base + ssao" between [0, 1]
  56606. */
  56607. base: number;
  56608. /**
  56609. * Support test.
  56610. */
  56611. static readonly IsSupported: boolean;
  56612. private _scene;
  56613. private _depthTexture;
  56614. private _normalTexture;
  56615. private _randomTexture;
  56616. private _originalColorPostProcess;
  56617. private _ssaoPostProcess;
  56618. private _blurHPostProcess;
  56619. private _blurVPostProcess;
  56620. private _ssaoCombinePostProcess;
  56621. private _firstUpdate;
  56622. /**
  56623. * Gets active scene
  56624. */
  56625. readonly scene: Scene;
  56626. /**
  56627. * @constructor
  56628. * @param name The rendering pipeline name
  56629. * @param scene The scene linked to this pipeline
  56630. * @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 }
  56631. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56632. */
  56633. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56634. /**
  56635. * Get the class name
  56636. * @returns "SSAO2RenderingPipeline"
  56637. */
  56638. getClassName(): string;
  56639. /**
  56640. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56641. */
  56642. dispose(disableGeometryBufferRenderer?: boolean): void;
  56643. private _createBlurPostProcess;
  56644. /** @hidden */
  56645. _rebuild(): void;
  56646. private _bits;
  56647. private _radicalInverse_VdC;
  56648. private _hammersley;
  56649. private _hemisphereSample_uniform;
  56650. private _generateHemisphere;
  56651. private _createSSAOPostProcess;
  56652. private _createSSAOCombinePostProcess;
  56653. private _createRandomTexture;
  56654. /**
  56655. * Serialize the rendering pipeline (Used when exporting)
  56656. * @returns the serialized object
  56657. */
  56658. serialize(): any;
  56659. /**
  56660. * Parse the serialized pipeline
  56661. * @param source Source pipeline.
  56662. * @param scene The scene to load the pipeline to.
  56663. * @param rootUrl The URL of the serialized pipeline.
  56664. * @returns An instantiated pipeline from the serialized object.
  56665. */
  56666. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56667. }
  56668. }
  56669. declare module "babylonjs/Shaders/ssao.fragment" {
  56670. /** @hidden */
  56671. export var ssaoPixelShader: {
  56672. name: string;
  56673. shader: string;
  56674. };
  56675. }
  56676. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56677. import { Camera } from "babylonjs/Cameras/camera";
  56678. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56679. import { Scene } from "babylonjs/scene";
  56680. import "babylonjs/Shaders/ssao.fragment";
  56681. import "babylonjs/Shaders/ssaoCombine.fragment";
  56682. /**
  56683. * Render pipeline to produce ssao effect
  56684. */
  56685. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56686. /**
  56687. * @ignore
  56688. * The PassPostProcess id in the pipeline that contains the original scene color
  56689. */
  56690. SSAOOriginalSceneColorEffect: string;
  56691. /**
  56692. * @ignore
  56693. * The SSAO PostProcess id in the pipeline
  56694. */
  56695. SSAORenderEffect: string;
  56696. /**
  56697. * @ignore
  56698. * The horizontal blur PostProcess id in the pipeline
  56699. */
  56700. SSAOBlurHRenderEffect: string;
  56701. /**
  56702. * @ignore
  56703. * The vertical blur PostProcess id in the pipeline
  56704. */
  56705. SSAOBlurVRenderEffect: string;
  56706. /**
  56707. * @ignore
  56708. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56709. */
  56710. SSAOCombineRenderEffect: string;
  56711. /**
  56712. * The output strength of the SSAO post-process. Default value is 1.0.
  56713. */
  56714. totalStrength: number;
  56715. /**
  56716. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56717. */
  56718. radius: number;
  56719. /**
  56720. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56721. * Must not be equal to fallOff and superior to fallOff.
  56722. * Default value is 0.0075
  56723. */
  56724. area: number;
  56725. /**
  56726. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56727. * Must not be equal to area and inferior to area.
  56728. * Default value is 0.000001
  56729. */
  56730. fallOff: number;
  56731. /**
  56732. * The base color of the SSAO post-process
  56733. * The final result is "base + ssao" between [0, 1]
  56734. */
  56735. base: number;
  56736. private _scene;
  56737. private _depthTexture;
  56738. private _randomTexture;
  56739. private _originalColorPostProcess;
  56740. private _ssaoPostProcess;
  56741. private _blurHPostProcess;
  56742. private _blurVPostProcess;
  56743. private _ssaoCombinePostProcess;
  56744. private _firstUpdate;
  56745. /**
  56746. * Gets active scene
  56747. */
  56748. readonly scene: Scene;
  56749. /**
  56750. * @constructor
  56751. * @param name - The rendering pipeline name
  56752. * @param scene - The scene linked to this pipeline
  56753. * @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 }
  56754. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56755. */
  56756. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56757. /**
  56758. * Get the class name
  56759. * @returns "SSAORenderingPipeline"
  56760. */
  56761. getClassName(): string;
  56762. /**
  56763. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56764. */
  56765. dispose(disableDepthRender?: boolean): void;
  56766. private _createBlurPostProcess;
  56767. /** @hidden */
  56768. _rebuild(): void;
  56769. private _createSSAOPostProcess;
  56770. private _createSSAOCombinePostProcess;
  56771. private _createRandomTexture;
  56772. }
  56773. }
  56774. declare module "babylonjs/Shaders/standard.fragment" {
  56775. /** @hidden */
  56776. export var standardPixelShader: {
  56777. name: string;
  56778. shader: string;
  56779. };
  56780. }
  56781. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56782. import { Nullable } from "babylonjs/types";
  56783. import { IAnimatable } from "babylonjs/Misc/tools";
  56784. import { Camera } from "babylonjs/Cameras/camera";
  56785. import { Texture } from "babylonjs/Materials/Textures/texture";
  56786. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56787. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56788. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56789. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56790. import { IDisposable } from "babylonjs/scene";
  56791. import { SpotLight } from "babylonjs/Lights/spotLight";
  56792. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56793. import { Scene } from "babylonjs/scene";
  56794. import { Animation } from "babylonjs/Animations/animation";
  56795. import "babylonjs/Shaders/standard.fragment";
  56796. /**
  56797. * Standard rendering pipeline
  56798. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56799. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56800. */
  56801. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56802. /**
  56803. * Public members
  56804. */
  56805. /**
  56806. * Post-process which contains the original scene color before the pipeline applies all the effects
  56807. */
  56808. originalPostProcess: Nullable<PostProcess>;
  56809. /**
  56810. * Post-process used to down scale an image x4
  56811. */
  56812. downSampleX4PostProcess: Nullable<PostProcess>;
  56813. /**
  56814. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56815. */
  56816. brightPassPostProcess: Nullable<PostProcess>;
  56817. /**
  56818. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56819. */
  56820. blurHPostProcesses: PostProcess[];
  56821. /**
  56822. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56823. */
  56824. blurVPostProcesses: PostProcess[];
  56825. /**
  56826. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56827. */
  56828. textureAdderPostProcess: Nullable<PostProcess>;
  56829. /**
  56830. * Post-process used to create volumetric lighting effect
  56831. */
  56832. volumetricLightPostProcess: Nullable<PostProcess>;
  56833. /**
  56834. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56835. */
  56836. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56837. /**
  56838. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56839. */
  56840. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56841. /**
  56842. * Post-process used to merge the volumetric light effect and the real scene color
  56843. */
  56844. volumetricLightMergePostProces: Nullable<PostProcess>;
  56845. /**
  56846. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56847. */
  56848. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56849. /**
  56850. * Base post-process used to calculate the average luminance of the final image for HDR
  56851. */
  56852. luminancePostProcess: Nullable<PostProcess>;
  56853. /**
  56854. * Post-processes used to create down sample post-processes in order to get
  56855. * the average luminance of the final image for HDR
  56856. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56857. */
  56858. luminanceDownSamplePostProcesses: PostProcess[];
  56859. /**
  56860. * Post-process used to create a HDR effect (light adaptation)
  56861. */
  56862. hdrPostProcess: Nullable<PostProcess>;
  56863. /**
  56864. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56865. */
  56866. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56867. /**
  56868. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56869. */
  56870. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56871. /**
  56872. * Post-process used to merge the final HDR post-process and the real scene color
  56873. */
  56874. hdrFinalPostProcess: Nullable<PostProcess>;
  56875. /**
  56876. * Post-process used to create a lens flare effect
  56877. */
  56878. lensFlarePostProcess: Nullable<PostProcess>;
  56879. /**
  56880. * Post-process that merges the result of the lens flare post-process and the real scene color
  56881. */
  56882. lensFlareComposePostProcess: Nullable<PostProcess>;
  56883. /**
  56884. * Post-process used to create a motion blur effect
  56885. */
  56886. motionBlurPostProcess: Nullable<PostProcess>;
  56887. /**
  56888. * Post-process used to create a depth of field effect
  56889. */
  56890. depthOfFieldPostProcess: Nullable<PostProcess>;
  56891. /**
  56892. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56893. */
  56894. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56895. /**
  56896. * Represents the brightness threshold in order to configure the illuminated surfaces
  56897. */
  56898. brightThreshold: number;
  56899. /**
  56900. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56901. */
  56902. blurWidth: number;
  56903. /**
  56904. * Sets if the blur for highlighted surfaces must be only horizontal
  56905. */
  56906. horizontalBlur: boolean;
  56907. /**
  56908. * Gets the overall exposure used by the pipeline
  56909. */
  56910. /**
  56911. * Sets the overall exposure used by the pipeline
  56912. */
  56913. exposure: number;
  56914. /**
  56915. * Texture used typically to simulate "dirty" on camera lens
  56916. */
  56917. lensTexture: Nullable<Texture>;
  56918. /**
  56919. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56920. */
  56921. volumetricLightCoefficient: number;
  56922. /**
  56923. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56924. */
  56925. volumetricLightPower: number;
  56926. /**
  56927. * Used the set the blur intensity to smooth the volumetric lights
  56928. */
  56929. volumetricLightBlurScale: number;
  56930. /**
  56931. * Light (spot or directional) used to generate the volumetric lights rays
  56932. * The source light must have a shadow generate so the pipeline can get its
  56933. * depth map
  56934. */
  56935. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56936. /**
  56937. * For eye adaptation, represents the minimum luminance the eye can see
  56938. */
  56939. hdrMinimumLuminance: number;
  56940. /**
  56941. * For eye adaptation, represents the decrease luminance speed
  56942. */
  56943. hdrDecreaseRate: number;
  56944. /**
  56945. * For eye adaptation, represents the increase luminance speed
  56946. */
  56947. hdrIncreaseRate: number;
  56948. /**
  56949. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56950. */
  56951. /**
  56952. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56953. */
  56954. hdrAutoExposure: boolean;
  56955. /**
  56956. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56957. */
  56958. lensColorTexture: Nullable<Texture>;
  56959. /**
  56960. * The overall strengh for the lens flare effect
  56961. */
  56962. lensFlareStrength: number;
  56963. /**
  56964. * Dispersion coefficient for lens flare ghosts
  56965. */
  56966. lensFlareGhostDispersal: number;
  56967. /**
  56968. * Main lens flare halo width
  56969. */
  56970. lensFlareHaloWidth: number;
  56971. /**
  56972. * Based on the lens distortion effect, defines how much the lens flare result
  56973. * is distorted
  56974. */
  56975. lensFlareDistortionStrength: number;
  56976. /**
  56977. * Lens star texture must be used to simulate rays on the flares and is available
  56978. * in the documentation
  56979. */
  56980. lensStarTexture: Nullable<Texture>;
  56981. /**
  56982. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56983. * flare effect by taking account of the dirt texture
  56984. */
  56985. lensFlareDirtTexture: Nullable<Texture>;
  56986. /**
  56987. * Represents the focal length for the depth of field effect
  56988. */
  56989. depthOfFieldDistance: number;
  56990. /**
  56991. * Represents the blur intensity for the blurred part of the depth of field effect
  56992. */
  56993. depthOfFieldBlurWidth: number;
  56994. /**
  56995. * For motion blur, defines how much the image is blurred by the movement
  56996. */
  56997. motionStrength: number;
  56998. /**
  56999. * List of animations for the pipeline (IAnimatable implementation)
  57000. */
  57001. animations: Animation[];
  57002. /**
  57003. * Private members
  57004. */
  57005. private _scene;
  57006. private _currentDepthOfFieldSource;
  57007. private _basePostProcess;
  57008. private _fixedExposure;
  57009. private _currentExposure;
  57010. private _hdrAutoExposure;
  57011. private _hdrCurrentLuminance;
  57012. private _floatTextureType;
  57013. private _ratio;
  57014. private _bloomEnabled;
  57015. private _depthOfFieldEnabled;
  57016. private _vlsEnabled;
  57017. private _lensFlareEnabled;
  57018. private _hdrEnabled;
  57019. private _motionBlurEnabled;
  57020. private _fxaaEnabled;
  57021. private _motionBlurSamples;
  57022. private _volumetricLightStepsCount;
  57023. private _samples;
  57024. /**
  57025. * @ignore
  57026. * Specifies if the bloom pipeline is enabled
  57027. */
  57028. BloomEnabled: boolean;
  57029. /**
  57030. * @ignore
  57031. * Specifies if the depth of field pipeline is enabed
  57032. */
  57033. DepthOfFieldEnabled: boolean;
  57034. /**
  57035. * @ignore
  57036. * Specifies if the lens flare pipeline is enabed
  57037. */
  57038. LensFlareEnabled: boolean;
  57039. /**
  57040. * @ignore
  57041. * Specifies if the HDR pipeline is enabled
  57042. */
  57043. HDREnabled: boolean;
  57044. /**
  57045. * @ignore
  57046. * Specifies if the volumetric lights scattering effect is enabled
  57047. */
  57048. VLSEnabled: boolean;
  57049. /**
  57050. * @ignore
  57051. * Specifies if the motion blur effect is enabled
  57052. */
  57053. MotionBlurEnabled: boolean;
  57054. /**
  57055. * Specifies if anti-aliasing is enabled
  57056. */
  57057. fxaaEnabled: boolean;
  57058. /**
  57059. * Specifies the number of steps used to calculate the volumetric lights
  57060. * Typically in interval [50, 200]
  57061. */
  57062. volumetricLightStepsCount: number;
  57063. /**
  57064. * Specifies the number of samples used for the motion blur effect
  57065. * Typically in interval [16, 64]
  57066. */
  57067. motionBlurSamples: number;
  57068. /**
  57069. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57070. */
  57071. samples: number;
  57072. /**
  57073. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57074. * @constructor
  57075. * @param name The rendering pipeline name
  57076. * @param scene The scene linked to this pipeline
  57077. * @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)
  57078. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57079. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57080. */
  57081. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57082. private _buildPipeline;
  57083. private _createDownSampleX4PostProcess;
  57084. private _createBrightPassPostProcess;
  57085. private _createBlurPostProcesses;
  57086. private _createTextureAdderPostProcess;
  57087. private _createVolumetricLightPostProcess;
  57088. private _createLuminancePostProcesses;
  57089. private _createHdrPostProcess;
  57090. private _createLensFlarePostProcess;
  57091. private _createDepthOfFieldPostProcess;
  57092. private _createMotionBlurPostProcess;
  57093. private _getDepthTexture;
  57094. private _disposePostProcesses;
  57095. /**
  57096. * Dispose of the pipeline and stop all post processes
  57097. */
  57098. dispose(): void;
  57099. /**
  57100. * Serialize the rendering pipeline (Used when exporting)
  57101. * @returns the serialized object
  57102. */
  57103. serialize(): any;
  57104. /**
  57105. * Parse the serialized pipeline
  57106. * @param source Source pipeline.
  57107. * @param scene The scene to load the pipeline to.
  57108. * @param rootUrl The URL of the serialized pipeline.
  57109. * @returns An instantiated pipeline from the serialized object.
  57110. */
  57111. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57112. /**
  57113. * Luminance steps
  57114. */
  57115. static LuminanceSteps: number;
  57116. }
  57117. }
  57118. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  57119. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  57120. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  57121. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  57122. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  57123. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  57124. }
  57125. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  57126. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  57127. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57128. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57129. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  57130. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  57131. }
  57132. declare module "babylonjs/Shaders/tonemap.fragment" {
  57133. /** @hidden */
  57134. export var tonemapPixelShader: {
  57135. name: string;
  57136. shader: string;
  57137. };
  57138. }
  57139. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  57140. import { Camera } from "babylonjs/Cameras/camera";
  57141. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57142. import "babylonjs/Shaders/tonemap.fragment";
  57143. import { Engine } from "babylonjs/Engines/engine";
  57144. /** Defines operator used for tonemapping */
  57145. export enum TonemappingOperator {
  57146. /** Hable */
  57147. Hable = 0,
  57148. /** Reinhard */
  57149. Reinhard = 1,
  57150. /** HejiDawson */
  57151. HejiDawson = 2,
  57152. /** Photographic */
  57153. Photographic = 3
  57154. }
  57155. /**
  57156. * Defines a post process to apply tone mapping
  57157. */
  57158. export class TonemapPostProcess extends PostProcess {
  57159. private _operator;
  57160. /** Defines the required exposure adjustement */
  57161. exposureAdjustment: number;
  57162. /**
  57163. * Creates a new TonemapPostProcess
  57164. * @param name defines the name of the postprocess
  57165. * @param _operator defines the operator to use
  57166. * @param exposureAdjustment defines the required exposure adjustement
  57167. * @param camera defines the camera to use (can be null)
  57168. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57169. * @param engine defines the hosting engine (can be ignore if camera is set)
  57170. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57171. */
  57172. constructor(name: string, _operator: TonemappingOperator,
  57173. /** Defines the required exposure adjustement */
  57174. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57175. }
  57176. }
  57177. declare module "babylonjs/Shaders/depth.vertex" {
  57178. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57179. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57180. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57181. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57182. /** @hidden */
  57183. export var depthVertexShader: {
  57184. name: string;
  57185. shader: string;
  57186. };
  57187. }
  57188. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  57189. /** @hidden */
  57190. export var volumetricLightScatteringPixelShader: {
  57191. name: string;
  57192. shader: string;
  57193. };
  57194. }
  57195. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  57196. /** @hidden */
  57197. export var volumetricLightScatteringPassPixelShader: {
  57198. name: string;
  57199. shader: string;
  57200. };
  57201. }
  57202. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  57203. import { Vector3 } from "babylonjs/Maths/math";
  57204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57205. import { Mesh } from "babylonjs/Meshes/mesh";
  57206. import { Camera } from "babylonjs/Cameras/camera";
  57207. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57208. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57209. import { Scene } from "babylonjs/scene";
  57210. import "babylonjs/Meshes/Builders/planeBuilder";
  57211. import "babylonjs/Shaders/depth.vertex";
  57212. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57213. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57214. import { Engine } from "babylonjs/Engines/engine";
  57215. /**
  57216. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57217. */
  57218. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57219. private _volumetricLightScatteringPass;
  57220. private _volumetricLightScatteringRTT;
  57221. private _viewPort;
  57222. private _screenCoordinates;
  57223. private _cachedDefines;
  57224. /**
  57225. * If not undefined, the mesh position is computed from the attached node position
  57226. */
  57227. attachedNode: {
  57228. position: Vector3;
  57229. };
  57230. /**
  57231. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57232. */
  57233. customMeshPosition: Vector3;
  57234. /**
  57235. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57236. */
  57237. useCustomMeshPosition: boolean;
  57238. /**
  57239. * If the post-process should inverse the light scattering direction
  57240. */
  57241. invert: boolean;
  57242. /**
  57243. * The internal mesh used by the post-process
  57244. */
  57245. mesh: Mesh;
  57246. /**
  57247. * @hidden
  57248. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57249. */
  57250. useDiffuseColor: boolean;
  57251. /**
  57252. * Array containing the excluded meshes not rendered in the internal pass
  57253. */
  57254. excludedMeshes: AbstractMesh[];
  57255. /**
  57256. * Controls the overall intensity of the post-process
  57257. */
  57258. exposure: number;
  57259. /**
  57260. * Dissipates each sample's contribution in range [0, 1]
  57261. */
  57262. decay: number;
  57263. /**
  57264. * Controls the overall intensity of each sample
  57265. */
  57266. weight: number;
  57267. /**
  57268. * Controls the density of each sample
  57269. */
  57270. density: number;
  57271. /**
  57272. * @constructor
  57273. * @param name The post-process name
  57274. * @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)
  57275. * @param camera The camera that the post-process will be attached to
  57276. * @param mesh The mesh used to create the light scattering
  57277. * @param samples The post-process quality, default 100
  57278. * @param samplingModeThe post-process filtering mode
  57279. * @param engine The babylon engine
  57280. * @param reusable If the post-process is reusable
  57281. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57282. */
  57283. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57284. /**
  57285. * Returns the string "VolumetricLightScatteringPostProcess"
  57286. * @returns "VolumetricLightScatteringPostProcess"
  57287. */
  57288. getClassName(): string;
  57289. private _isReady;
  57290. /**
  57291. * Sets the new light position for light scattering effect
  57292. * @param position The new custom light position
  57293. */
  57294. setCustomMeshPosition(position: Vector3): void;
  57295. /**
  57296. * Returns the light position for light scattering effect
  57297. * @return Vector3 The custom light position
  57298. */
  57299. getCustomMeshPosition(): Vector3;
  57300. /**
  57301. * Disposes the internal assets and detaches the post-process from the camera
  57302. */
  57303. dispose(camera: Camera): void;
  57304. /**
  57305. * Returns the render target texture used by the post-process
  57306. * @return the render target texture used by the post-process
  57307. */
  57308. getPass(): RenderTargetTexture;
  57309. private _meshExcluded;
  57310. private _createPass;
  57311. private _updateMeshScreenCoordinates;
  57312. /**
  57313. * Creates a default mesh for the Volumeric Light Scattering post-process
  57314. * @param name The mesh name
  57315. * @param scene The scene where to create the mesh
  57316. * @return the default mesh
  57317. */
  57318. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57319. }
  57320. }
  57321. declare module "babylonjs/PostProcesses/index" {
  57322. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57323. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57324. export * from "babylonjs/PostProcesses/bloomEffect";
  57325. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57326. export * from "babylonjs/PostProcesses/blurPostProcess";
  57327. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57328. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57329. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57330. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57331. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57332. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57333. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57334. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57335. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57336. export * from "babylonjs/PostProcesses/filterPostProcess";
  57337. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57338. export * from "babylonjs/PostProcesses/grainPostProcess";
  57339. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57340. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57341. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57342. export * from "babylonjs/PostProcesses/passPostProcess";
  57343. export * from "babylonjs/PostProcesses/postProcess";
  57344. export * from "babylonjs/PostProcesses/postProcessManager";
  57345. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57346. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57347. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57348. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57349. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57350. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57351. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57352. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57353. }
  57354. declare module "babylonjs/Probes/index" {
  57355. export * from "babylonjs/Probes/reflectionProbe";
  57356. }
  57357. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57358. import { Scene } from "babylonjs/scene";
  57359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57360. import { Color3 } from "babylonjs/Maths/math";
  57361. import { SmartArray } from "babylonjs/Misc/smartArray";
  57362. import { ISceneComponent } from "babylonjs/sceneComponent";
  57363. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57364. import "babylonjs/Meshes/Builders/boxBuilder";
  57365. import "babylonjs/Shaders/color.fragment";
  57366. import "babylonjs/Shaders/color.vertex";
  57367. module "babylonjs/scene" {
  57368. interface Scene {
  57369. /** @hidden (Backing field) */
  57370. _boundingBoxRenderer: BoundingBoxRenderer;
  57371. /** @hidden (Backing field) */
  57372. _forceShowBoundingBoxes: boolean;
  57373. /**
  57374. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57375. */
  57376. forceShowBoundingBoxes: boolean;
  57377. /**
  57378. * Gets the bounding box renderer associated with the scene
  57379. * @returns a BoundingBoxRenderer
  57380. */
  57381. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57382. }
  57383. }
  57384. module "babylonjs/Meshes/abstractMesh" {
  57385. interface AbstractMesh {
  57386. /** @hidden (Backing field) */
  57387. _showBoundingBox: boolean;
  57388. /**
  57389. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57390. */
  57391. showBoundingBox: boolean;
  57392. }
  57393. }
  57394. /**
  57395. * Component responsible of rendering the bounding box of the meshes in a scene.
  57396. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57397. */
  57398. export class BoundingBoxRenderer implements ISceneComponent {
  57399. /**
  57400. * The component name helpfull to identify the component in the list of scene components.
  57401. */
  57402. readonly name: string;
  57403. /**
  57404. * The scene the component belongs to.
  57405. */
  57406. scene: Scene;
  57407. /**
  57408. * Color of the bounding box lines placed in front of an object
  57409. */
  57410. frontColor: Color3;
  57411. /**
  57412. * Color of the bounding box lines placed behind an object
  57413. */
  57414. backColor: Color3;
  57415. /**
  57416. * Defines if the renderer should show the back lines or not
  57417. */
  57418. showBackLines: boolean;
  57419. /**
  57420. * @hidden
  57421. */
  57422. renderList: SmartArray<BoundingBox>;
  57423. private _colorShader;
  57424. private _vertexBuffers;
  57425. private _indexBuffer;
  57426. /**
  57427. * Instantiates a new bounding box renderer in a scene.
  57428. * @param scene the scene the renderer renders in
  57429. */
  57430. constructor(scene: Scene);
  57431. /**
  57432. * Registers the component in a given scene
  57433. */
  57434. register(): void;
  57435. private _evaluateSubMesh;
  57436. private _activeMesh;
  57437. private _prepareRessources;
  57438. private _createIndexBuffer;
  57439. /**
  57440. * Rebuilds the elements related to this component in case of
  57441. * context lost for instance.
  57442. */
  57443. rebuild(): void;
  57444. /**
  57445. * @hidden
  57446. */
  57447. reset(): void;
  57448. /**
  57449. * Render the bounding boxes of a specific rendering group
  57450. * @param renderingGroupId defines the rendering group to render
  57451. */
  57452. render(renderingGroupId: number): void;
  57453. /**
  57454. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57455. * @param mesh Define the mesh to render the occlusion bounding box for
  57456. */
  57457. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57458. /**
  57459. * Dispose and release the resources attached to this renderer.
  57460. */
  57461. dispose(): void;
  57462. }
  57463. }
  57464. declare module "babylonjs/Shaders/depth.fragment" {
  57465. /** @hidden */
  57466. export var depthPixelShader: {
  57467. name: string;
  57468. shader: string;
  57469. };
  57470. }
  57471. declare module "babylonjs/Rendering/depthRenderer" {
  57472. import { Nullable } from "babylonjs/types";
  57473. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57474. import { Scene } from "babylonjs/scene";
  57475. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57476. import { Camera } from "babylonjs/Cameras/camera";
  57477. import "babylonjs/Shaders/depth.fragment";
  57478. import "babylonjs/Shaders/depth.vertex";
  57479. /**
  57480. * This represents a depth renderer in Babylon.
  57481. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57482. */
  57483. export class DepthRenderer {
  57484. private _scene;
  57485. private _depthMap;
  57486. private _effect;
  57487. private _cachedDefines;
  57488. private _camera;
  57489. /**
  57490. * Specifiess that the depth renderer will only be used within
  57491. * the camera it is created for.
  57492. * This can help forcing its rendering during the camera processing.
  57493. */
  57494. useOnlyInActiveCamera: boolean;
  57495. /** @hidden */
  57496. static _SceneComponentInitialization: (scene: Scene) => void;
  57497. /**
  57498. * Instantiates a depth renderer
  57499. * @param scene The scene the renderer belongs to
  57500. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57501. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57502. */
  57503. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57504. /**
  57505. * Creates the depth rendering effect and checks if the effect is ready.
  57506. * @param subMesh The submesh to be used to render the depth map of
  57507. * @param useInstances If multiple world instances should be used
  57508. * @returns if the depth renderer is ready to render the depth map
  57509. */
  57510. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57511. /**
  57512. * Gets the texture which the depth map will be written to.
  57513. * @returns The depth map texture
  57514. */
  57515. getDepthMap(): RenderTargetTexture;
  57516. /**
  57517. * Disposes of the depth renderer.
  57518. */
  57519. dispose(): void;
  57520. }
  57521. }
  57522. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57523. import { Nullable } from "babylonjs/types";
  57524. import { Scene } from "babylonjs/scene";
  57525. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57526. import { Camera } from "babylonjs/Cameras/camera";
  57527. import { ISceneComponent } from "babylonjs/sceneComponent";
  57528. module "babylonjs/scene" {
  57529. interface Scene {
  57530. /** @hidden (Backing field) */
  57531. _depthRenderer: {
  57532. [id: string]: DepthRenderer;
  57533. };
  57534. /**
  57535. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57536. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57537. * @returns the created depth renderer
  57538. */
  57539. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57540. /**
  57541. * Disables a depth renderer for a given camera
  57542. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57543. */
  57544. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57545. }
  57546. }
  57547. /**
  57548. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57549. * in several rendering techniques.
  57550. */
  57551. export class DepthRendererSceneComponent implements ISceneComponent {
  57552. /**
  57553. * The component name helpfull to identify the component in the list of scene components.
  57554. */
  57555. readonly name: string;
  57556. /**
  57557. * The scene the component belongs to.
  57558. */
  57559. scene: Scene;
  57560. /**
  57561. * Creates a new instance of the component for the given scene
  57562. * @param scene Defines the scene to register the component in
  57563. */
  57564. constructor(scene: Scene);
  57565. /**
  57566. * Registers the component in a given scene
  57567. */
  57568. register(): void;
  57569. /**
  57570. * Rebuilds the elements related to this component in case of
  57571. * context lost for instance.
  57572. */
  57573. rebuild(): void;
  57574. /**
  57575. * Disposes the component and the associated ressources
  57576. */
  57577. dispose(): void;
  57578. private _gatherRenderTargets;
  57579. private _gatherActiveCameraRenderTargets;
  57580. }
  57581. }
  57582. declare module "babylonjs/Shaders/outline.fragment" {
  57583. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57584. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57585. /** @hidden */
  57586. export var outlinePixelShader: {
  57587. name: string;
  57588. shader: string;
  57589. };
  57590. }
  57591. declare module "babylonjs/Shaders/outline.vertex" {
  57592. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57593. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57594. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57595. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57596. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57597. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57598. /** @hidden */
  57599. export var outlineVertexShader: {
  57600. name: string;
  57601. shader: string;
  57602. };
  57603. }
  57604. declare module "babylonjs/Rendering/outlineRenderer" {
  57605. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57606. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57607. import { Scene } from "babylonjs/scene";
  57608. import { ISceneComponent } from "babylonjs/sceneComponent";
  57609. import "babylonjs/Shaders/outline.fragment";
  57610. import "babylonjs/Shaders/outline.vertex";
  57611. module "babylonjs/scene" {
  57612. interface Scene {
  57613. /** @hidden */
  57614. _outlineRenderer: OutlineRenderer;
  57615. /**
  57616. * Gets the outline renderer associated with the scene
  57617. * @returns a OutlineRenderer
  57618. */
  57619. getOutlineRenderer(): OutlineRenderer;
  57620. }
  57621. }
  57622. module "babylonjs/Meshes/abstractMesh" {
  57623. interface AbstractMesh {
  57624. /** @hidden (Backing field) */
  57625. _renderOutline: boolean;
  57626. /**
  57627. * Gets or sets a boolean indicating if the outline must be rendered as well
  57628. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57629. */
  57630. renderOutline: boolean;
  57631. /** @hidden (Backing field) */
  57632. _renderOverlay: boolean;
  57633. /**
  57634. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57635. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57636. */
  57637. renderOverlay: boolean;
  57638. }
  57639. }
  57640. /**
  57641. * This class is responsible to draw bothe outline/overlay of meshes.
  57642. * It should not be used directly but through the available method on mesh.
  57643. */
  57644. export class OutlineRenderer implements ISceneComponent {
  57645. /**
  57646. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57647. */
  57648. private static _StencilReference;
  57649. /**
  57650. * The name of the component. Each component must have a unique name.
  57651. */
  57652. name: string;
  57653. /**
  57654. * The scene the component belongs to.
  57655. */
  57656. scene: Scene;
  57657. /**
  57658. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57659. */
  57660. zOffset: number;
  57661. private _engine;
  57662. private _effect;
  57663. private _cachedDefines;
  57664. private _savedDepthWrite;
  57665. /**
  57666. * Instantiates a new outline renderer. (There could be only one per scene).
  57667. * @param scene Defines the scene it belongs to
  57668. */
  57669. constructor(scene: Scene);
  57670. /**
  57671. * Register the component to one instance of a scene.
  57672. */
  57673. register(): void;
  57674. /**
  57675. * Rebuilds the elements related to this component in case of
  57676. * context lost for instance.
  57677. */
  57678. rebuild(): void;
  57679. /**
  57680. * Disposes the component and the associated ressources.
  57681. */
  57682. dispose(): void;
  57683. /**
  57684. * Renders the outline in the canvas.
  57685. * @param subMesh Defines the sumesh to render
  57686. * @param batch Defines the batch of meshes in case of instances
  57687. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57688. */
  57689. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57690. /**
  57691. * Returns whether or not the outline renderer is ready for a given submesh.
  57692. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57693. * @param subMesh Defines the submesh to check readyness for
  57694. * @param useInstances Defines wheter wee are trying to render instances or not
  57695. * @returns true if ready otherwise false
  57696. */
  57697. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57698. private _beforeRenderingMesh;
  57699. private _afterRenderingMesh;
  57700. }
  57701. }
  57702. declare module "babylonjs/Rendering/index" {
  57703. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57704. export * from "babylonjs/Rendering/depthRenderer";
  57705. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57706. export * from "babylonjs/Rendering/edgesRenderer";
  57707. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57708. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57709. export * from "babylonjs/Rendering/outlineRenderer";
  57710. export * from "babylonjs/Rendering/renderingGroup";
  57711. export * from "babylonjs/Rendering/renderingManager";
  57712. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57713. }
  57714. declare module "babylonjs/Sprites/index" {
  57715. export * from "babylonjs/Sprites/sprite";
  57716. export * from "babylonjs/Sprites/spriteManager";
  57717. export * from "babylonjs/Sprites/spriteSceneComponent";
  57718. }
  57719. declare module "babylonjs/Misc/assetsManager" {
  57720. import { Scene } from "babylonjs/scene";
  57721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57722. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57723. import { Skeleton } from "babylonjs/Bones/skeleton";
  57724. import { Observable } from "babylonjs/Misc/observable";
  57725. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57726. import { Texture } from "babylonjs/Materials/Textures/texture";
  57727. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57728. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57729. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57730. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57731. /**
  57732. * Defines the list of states available for a task inside a AssetsManager
  57733. */
  57734. export enum AssetTaskState {
  57735. /**
  57736. * Initialization
  57737. */
  57738. INIT = 0,
  57739. /**
  57740. * Running
  57741. */
  57742. RUNNING = 1,
  57743. /**
  57744. * Done
  57745. */
  57746. DONE = 2,
  57747. /**
  57748. * Error
  57749. */
  57750. ERROR = 3
  57751. }
  57752. /**
  57753. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57754. */
  57755. export abstract class AbstractAssetTask {
  57756. /**
  57757. * Task name
  57758. */ name: string;
  57759. /**
  57760. * Callback called when the task is successful
  57761. */
  57762. onSuccess: (task: any) => void;
  57763. /**
  57764. * Callback called when the task is not successful
  57765. */
  57766. onError: (task: any, message?: string, exception?: any) => void;
  57767. /**
  57768. * Creates a new AssetsManager
  57769. * @param name defines the name of the task
  57770. */
  57771. constructor(
  57772. /**
  57773. * Task name
  57774. */ name: string);
  57775. private _isCompleted;
  57776. private _taskState;
  57777. private _errorObject;
  57778. /**
  57779. * Get if the task is completed
  57780. */
  57781. readonly isCompleted: boolean;
  57782. /**
  57783. * Gets the current state of the task
  57784. */
  57785. readonly taskState: AssetTaskState;
  57786. /**
  57787. * Gets the current error object (if task is in error)
  57788. */
  57789. readonly errorObject: {
  57790. message?: string;
  57791. exception?: any;
  57792. };
  57793. /**
  57794. * Internal only
  57795. * @hidden
  57796. */
  57797. _setErrorObject(message?: string, exception?: any): void;
  57798. /**
  57799. * Execute the current task
  57800. * @param scene defines the scene where you want your assets to be loaded
  57801. * @param onSuccess is a callback called when the task is successfully executed
  57802. * @param onError is a callback called if an error occurs
  57803. */
  57804. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57805. /**
  57806. * Execute the current task
  57807. * @param scene defines the scene where you want your assets to be loaded
  57808. * @param onSuccess is a callback called when the task is successfully executed
  57809. * @param onError is a callback called if an error occurs
  57810. */
  57811. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57812. /**
  57813. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57814. * This can be used with failed tasks that have the reason for failure fixed.
  57815. */
  57816. reset(): void;
  57817. private onErrorCallback;
  57818. private onDoneCallback;
  57819. }
  57820. /**
  57821. * Define the interface used by progress events raised during assets loading
  57822. */
  57823. export interface IAssetsProgressEvent {
  57824. /**
  57825. * Defines the number of remaining tasks to process
  57826. */
  57827. remainingCount: number;
  57828. /**
  57829. * Defines the total number of tasks
  57830. */
  57831. totalCount: number;
  57832. /**
  57833. * Defines the task that was just processed
  57834. */
  57835. task: AbstractAssetTask;
  57836. }
  57837. /**
  57838. * Class used to share progress information about assets loading
  57839. */
  57840. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57841. /**
  57842. * Defines the number of remaining tasks to process
  57843. */
  57844. remainingCount: number;
  57845. /**
  57846. * Defines the total number of tasks
  57847. */
  57848. totalCount: number;
  57849. /**
  57850. * Defines the task that was just processed
  57851. */
  57852. task: AbstractAssetTask;
  57853. /**
  57854. * Creates a AssetsProgressEvent
  57855. * @param remainingCount defines the number of remaining tasks to process
  57856. * @param totalCount defines the total number of tasks
  57857. * @param task defines the task that was just processed
  57858. */
  57859. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57860. }
  57861. /**
  57862. * Define a task used by AssetsManager to load meshes
  57863. */
  57864. export class MeshAssetTask extends AbstractAssetTask {
  57865. /**
  57866. * Defines the name of the task
  57867. */
  57868. name: string;
  57869. /**
  57870. * Defines the list of mesh's names you want to load
  57871. */
  57872. meshesNames: any;
  57873. /**
  57874. * Defines the root url to use as a base to load your meshes and associated resources
  57875. */
  57876. rootUrl: string;
  57877. /**
  57878. * Defines the filename of the scene to load from
  57879. */
  57880. sceneFilename: string;
  57881. /**
  57882. * Gets the list of loaded meshes
  57883. */
  57884. loadedMeshes: Array<AbstractMesh>;
  57885. /**
  57886. * Gets the list of loaded particle systems
  57887. */
  57888. loadedParticleSystems: Array<IParticleSystem>;
  57889. /**
  57890. * Gets the list of loaded skeletons
  57891. */
  57892. loadedSkeletons: Array<Skeleton>;
  57893. /**
  57894. * Gets the list of loaded animation groups
  57895. */
  57896. loadedAnimationGroups: Array<AnimationGroup>;
  57897. /**
  57898. * Callback called when the task is successful
  57899. */
  57900. onSuccess: (task: MeshAssetTask) => void;
  57901. /**
  57902. * Callback called when the task is successful
  57903. */
  57904. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57905. /**
  57906. * Creates a new MeshAssetTask
  57907. * @param name defines the name of the task
  57908. * @param meshesNames defines the list of mesh's names you want to load
  57909. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57910. * @param sceneFilename defines the filename of the scene to load from
  57911. */
  57912. constructor(
  57913. /**
  57914. * Defines the name of the task
  57915. */
  57916. name: string,
  57917. /**
  57918. * Defines the list of mesh's names you want to load
  57919. */
  57920. meshesNames: any,
  57921. /**
  57922. * Defines the root url to use as a base to load your meshes and associated resources
  57923. */
  57924. rootUrl: string,
  57925. /**
  57926. * Defines the filename of the scene to load from
  57927. */
  57928. sceneFilename: string);
  57929. /**
  57930. * Execute the current task
  57931. * @param scene defines the scene where you want your assets to be loaded
  57932. * @param onSuccess is a callback called when the task is successfully executed
  57933. * @param onError is a callback called if an error occurs
  57934. */
  57935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57936. }
  57937. /**
  57938. * Define a task used by AssetsManager to load text content
  57939. */
  57940. export class TextFileAssetTask extends AbstractAssetTask {
  57941. /**
  57942. * Defines the name of the task
  57943. */
  57944. name: string;
  57945. /**
  57946. * Defines the location of the file to load
  57947. */
  57948. url: string;
  57949. /**
  57950. * Gets the loaded text string
  57951. */
  57952. text: string;
  57953. /**
  57954. * Callback called when the task is successful
  57955. */
  57956. onSuccess: (task: TextFileAssetTask) => void;
  57957. /**
  57958. * Callback called when the task is successful
  57959. */
  57960. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57961. /**
  57962. * Creates a new TextFileAssetTask object
  57963. * @param name defines the name of the task
  57964. * @param url defines the location of the file to load
  57965. */
  57966. constructor(
  57967. /**
  57968. * Defines the name of the task
  57969. */
  57970. name: string,
  57971. /**
  57972. * Defines the location of the file to load
  57973. */
  57974. url: 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 binary data
  57985. */
  57986. export class BinaryFileAssetTask 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 lodaded data (as an array buffer)
  57997. */
  57998. data: ArrayBuffer;
  57999. /**
  58000. * Callback called when the task is successful
  58001. */
  58002. onSuccess: (task: BinaryFileAssetTask) => void;
  58003. /**
  58004. * Callback called when the task is successful
  58005. */
  58006. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58007. /**
  58008. * Creates a new BinaryFileAssetTask object
  58009. * @param name defines the name of the new 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 images
  58031. */
  58032. export class ImageAssetTask extends AbstractAssetTask {
  58033. /**
  58034. * Defines the name of the task
  58035. */
  58036. name: string;
  58037. /**
  58038. * Defines the location of the image to load
  58039. */
  58040. url: string;
  58041. /**
  58042. * Gets the loaded images
  58043. */
  58044. image: HTMLImageElement;
  58045. /**
  58046. * Callback called when the task is successful
  58047. */
  58048. onSuccess: (task: ImageAssetTask) => void;
  58049. /**
  58050. * Callback called when the task is successful
  58051. */
  58052. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58053. /**
  58054. * Creates a new ImageAssetTask
  58055. * @param name defines the name of the task
  58056. * @param url defines the location of the image to load
  58057. */
  58058. constructor(
  58059. /**
  58060. * Defines the name of the task
  58061. */
  58062. name: string,
  58063. /**
  58064. * Defines the location of the image 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. * Defines the interface used by texture loading tasks
  58077. */
  58078. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58079. /**
  58080. * Gets the loaded texture
  58081. */
  58082. texture: TEX;
  58083. }
  58084. /**
  58085. * Define a task used by AssetsManager to load 2D textures
  58086. */
  58087. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58088. /**
  58089. * Defines the name of the task
  58090. */
  58091. name: string;
  58092. /**
  58093. * Defines the location of the file to load
  58094. */
  58095. url: string;
  58096. /**
  58097. * Defines if mipmap should not be generated (default is false)
  58098. */
  58099. noMipmap?: boolean | undefined;
  58100. /**
  58101. * Defines if texture must be inverted on Y axis (default is false)
  58102. */
  58103. invertY?: boolean | undefined;
  58104. /**
  58105. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58106. */
  58107. samplingMode: number;
  58108. /**
  58109. * Gets the loaded texture
  58110. */
  58111. texture: Texture;
  58112. /**
  58113. * Callback called when the task is successful
  58114. */
  58115. onSuccess: (task: TextureAssetTask) => void;
  58116. /**
  58117. * Callback called when the task is successful
  58118. */
  58119. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58120. /**
  58121. * Creates a new TextureAssetTask object
  58122. * @param name defines the name of the task
  58123. * @param url defines the location of the file to load
  58124. * @param noMipmap defines if mipmap should not be generated (default is false)
  58125. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58126. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58127. */
  58128. constructor(
  58129. /**
  58130. * Defines the name of the task
  58131. */
  58132. name: string,
  58133. /**
  58134. * Defines the location of the file to load
  58135. */
  58136. url: string,
  58137. /**
  58138. * Defines if mipmap should not be generated (default is false)
  58139. */
  58140. noMipmap?: boolean | undefined,
  58141. /**
  58142. * Defines if texture must be inverted on Y axis (default is false)
  58143. */
  58144. invertY?: boolean | undefined,
  58145. /**
  58146. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58147. */
  58148. samplingMode?: number);
  58149. /**
  58150. * Execute the current task
  58151. * @param scene defines the scene where you want your assets to be loaded
  58152. * @param onSuccess is a callback called when the task is successfully executed
  58153. * @param onError is a callback called if an error occurs
  58154. */
  58155. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58156. }
  58157. /**
  58158. * Define a task used by AssetsManager to load cube textures
  58159. */
  58160. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58161. /**
  58162. * Defines the name of the task
  58163. */
  58164. name: string;
  58165. /**
  58166. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58167. */
  58168. url: string;
  58169. /**
  58170. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58171. */
  58172. extensions?: string[] | undefined;
  58173. /**
  58174. * Defines if mipmaps should not be generated (default is false)
  58175. */
  58176. noMipmap?: boolean | undefined;
  58177. /**
  58178. * Defines the explicit list of files (undefined by default)
  58179. */
  58180. files?: string[] | undefined;
  58181. /**
  58182. * Gets the loaded texture
  58183. */
  58184. texture: CubeTexture;
  58185. /**
  58186. * Callback called when the task is successful
  58187. */
  58188. onSuccess: (task: CubeTextureAssetTask) => void;
  58189. /**
  58190. * Callback called when the task is successful
  58191. */
  58192. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58193. /**
  58194. * Creates a new CubeTextureAssetTask
  58195. * @param name defines the name of the task
  58196. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58197. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58198. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58199. * @param files defines the explicit list of files (undefined by default)
  58200. */
  58201. constructor(
  58202. /**
  58203. * Defines the name of the task
  58204. */
  58205. name: string,
  58206. /**
  58207. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58208. */
  58209. url: string,
  58210. /**
  58211. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58212. */
  58213. extensions?: string[] | undefined,
  58214. /**
  58215. * Defines if mipmaps should not be generated (default is false)
  58216. */
  58217. noMipmap?: boolean | undefined,
  58218. /**
  58219. * Defines the explicit list of files (undefined by default)
  58220. */
  58221. files?: string[] | undefined);
  58222. /**
  58223. * Execute the current task
  58224. * @param scene defines the scene where you want your assets to be loaded
  58225. * @param onSuccess is a callback called when the task is successfully executed
  58226. * @param onError is a callback called if an error occurs
  58227. */
  58228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58229. }
  58230. /**
  58231. * Define a task used by AssetsManager to load HDR cube textures
  58232. */
  58233. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58234. /**
  58235. * Defines the name of the task
  58236. */
  58237. name: string;
  58238. /**
  58239. * Defines the location of the file to load
  58240. */
  58241. url: string;
  58242. /**
  58243. * Defines the desired size (the more it increases the longer the generation will be)
  58244. */
  58245. size: number;
  58246. /**
  58247. * Defines if mipmaps should not be generated (default is false)
  58248. */
  58249. noMipmap: boolean;
  58250. /**
  58251. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58252. */
  58253. generateHarmonics: boolean;
  58254. /**
  58255. * 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)
  58256. */
  58257. gammaSpace: boolean;
  58258. /**
  58259. * Internal Use Only
  58260. */
  58261. reserved: boolean;
  58262. /**
  58263. * Gets the loaded texture
  58264. */
  58265. texture: HDRCubeTexture;
  58266. /**
  58267. * Callback called when the task is successful
  58268. */
  58269. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58270. /**
  58271. * Callback called when the task is successful
  58272. */
  58273. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58274. /**
  58275. * Creates a new HDRCubeTextureAssetTask object
  58276. * @param name defines the name of the task
  58277. * @param url defines the location of the file to load
  58278. * @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.
  58279. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58280. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58281. * @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)
  58282. * @param reserved Internal use only
  58283. */
  58284. constructor(
  58285. /**
  58286. * Defines the name of the task
  58287. */
  58288. name: string,
  58289. /**
  58290. * Defines the location of the file to load
  58291. */
  58292. url: string,
  58293. /**
  58294. * Defines the desired size (the more it increases the longer the generation will be)
  58295. */
  58296. size: number,
  58297. /**
  58298. * Defines if mipmaps should not be generated (default is false)
  58299. */
  58300. noMipmap?: boolean,
  58301. /**
  58302. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58303. */
  58304. generateHarmonics?: boolean,
  58305. /**
  58306. * 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)
  58307. */
  58308. gammaSpace?: boolean,
  58309. /**
  58310. * Internal Use Only
  58311. */
  58312. reserved?: boolean);
  58313. /**
  58314. * Execute the current task
  58315. * @param scene defines the scene where you want your assets to be loaded
  58316. * @param onSuccess is a callback called when the task is successfully executed
  58317. * @param onError is a callback called if an error occurs
  58318. */
  58319. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58320. }
  58321. /**
  58322. * Define a task used by AssetsManager to load Equirectangular cube textures
  58323. */
  58324. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58325. /**
  58326. * Defines the name of the task
  58327. */
  58328. name: string;
  58329. /**
  58330. * Defines the location of the file to load
  58331. */
  58332. url: string;
  58333. /**
  58334. * Defines the desired size (the more it increases the longer the generation will be)
  58335. */
  58336. size: number;
  58337. /**
  58338. * Defines if mipmaps should not be generated (default is false)
  58339. */
  58340. noMipmap: boolean;
  58341. /**
  58342. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58343. * but the standard material would require them in Gamma space) (default is true)
  58344. */
  58345. gammaSpace: boolean;
  58346. /**
  58347. * Gets the loaded texture
  58348. */
  58349. texture: EquiRectangularCubeTexture;
  58350. /**
  58351. * Callback called when the task is successful
  58352. */
  58353. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58354. /**
  58355. * Callback called when the task is successful
  58356. */
  58357. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58358. /**
  58359. * Creates a new EquiRectangularCubeTextureAssetTask object
  58360. * @param name defines the name of the task
  58361. * @param url defines the location of the file to load
  58362. * @param size defines the desired size (the more it increases the longer the generation will be)
  58363. * If the size is omitted this implies you are using a preprocessed cubemap.
  58364. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58365. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58366. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58367. * (default is true)
  58368. */
  58369. constructor(
  58370. /**
  58371. * Defines the name of the task
  58372. */
  58373. name: string,
  58374. /**
  58375. * Defines the location of the file to load
  58376. */
  58377. url: string,
  58378. /**
  58379. * Defines the desired size (the more it increases the longer the generation will be)
  58380. */
  58381. size: number,
  58382. /**
  58383. * Defines if mipmaps should not be generated (default is false)
  58384. */
  58385. noMipmap?: boolean,
  58386. /**
  58387. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58388. * but the standard material would require them in Gamma space) (default is true)
  58389. */
  58390. gammaSpace?: boolean);
  58391. /**
  58392. * Execute the current task
  58393. * @param scene defines the scene where you want your assets to be loaded
  58394. * @param onSuccess is a callback called when the task is successfully executed
  58395. * @param onError is a callback called if an error occurs
  58396. */
  58397. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58398. }
  58399. /**
  58400. * This class can be used to easily import assets into a scene
  58401. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58402. */
  58403. export class AssetsManager {
  58404. private _scene;
  58405. private _isLoading;
  58406. protected _tasks: AbstractAssetTask[];
  58407. protected _waitingTasksCount: number;
  58408. protected _totalTasksCount: number;
  58409. /**
  58410. * Callback called when all tasks are processed
  58411. */
  58412. onFinish: (tasks: AbstractAssetTask[]) => void;
  58413. /**
  58414. * Callback called when a task is successful
  58415. */
  58416. onTaskSuccess: (task: AbstractAssetTask) => void;
  58417. /**
  58418. * Callback called when a task had an error
  58419. */
  58420. onTaskError: (task: AbstractAssetTask) => void;
  58421. /**
  58422. * Callback called when a task is done (whatever the result is)
  58423. */
  58424. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58425. /**
  58426. * Observable called when all tasks are processed
  58427. */
  58428. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58429. /**
  58430. * Observable called when a task had an error
  58431. */
  58432. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58433. /**
  58434. * Observable called when all tasks were executed
  58435. */
  58436. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58437. /**
  58438. * Observable called when a task is done (whatever the result is)
  58439. */
  58440. onProgressObservable: Observable<IAssetsProgressEvent>;
  58441. /**
  58442. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58443. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58444. */
  58445. useDefaultLoadingScreen: boolean;
  58446. /**
  58447. * Creates a new AssetsManager
  58448. * @param scene defines the scene to work on
  58449. */
  58450. constructor(scene: Scene);
  58451. /**
  58452. * Add a MeshAssetTask to the list of active tasks
  58453. * @param taskName defines the name of the new task
  58454. * @param meshesNames defines the name of meshes to load
  58455. * @param rootUrl defines the root url to use to locate files
  58456. * @param sceneFilename defines the filename of the scene file
  58457. * @returns a new MeshAssetTask object
  58458. */
  58459. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58460. /**
  58461. * Add a TextFileAssetTask to the list of active tasks
  58462. * @param taskName defines the name of the new task
  58463. * @param url defines the url of the file to load
  58464. * @returns a new TextFileAssetTask object
  58465. */
  58466. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58467. /**
  58468. * Add a BinaryFileAssetTask to the list of active tasks
  58469. * @param taskName defines the name of the new task
  58470. * @param url defines the url of the file to load
  58471. * @returns a new BinaryFileAssetTask object
  58472. */
  58473. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58474. /**
  58475. * Add a ImageAssetTask to the list of active tasks
  58476. * @param taskName defines the name of the new task
  58477. * @param url defines the url of the file to load
  58478. * @returns a new ImageAssetTask object
  58479. */
  58480. addImageTask(taskName: string, url: string): ImageAssetTask;
  58481. /**
  58482. * Add a TextureAssetTask to the list of active tasks
  58483. * @param taskName defines the name of the new task
  58484. * @param url defines the url of the file to load
  58485. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58486. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58487. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58488. * @returns a new TextureAssetTask object
  58489. */
  58490. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58491. /**
  58492. * Add a CubeTextureAssetTask to the list of active tasks
  58493. * @param taskName defines the name of the new task
  58494. * @param url defines the url of the file to load
  58495. * @param extensions defines the extension to use to load the cube map (can be null)
  58496. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58497. * @param files defines the list of files to load (can be null)
  58498. * @returns a new CubeTextureAssetTask object
  58499. */
  58500. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58501. /**
  58502. *
  58503. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58504. * @param taskName defines the name of the new task
  58505. * @param url defines the url of the file to load
  58506. * @param size defines the size you want for the cubemap (can be null)
  58507. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58508. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58509. * @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)
  58510. * @param reserved Internal use only
  58511. * @returns a new HDRCubeTextureAssetTask object
  58512. */
  58513. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58514. /**
  58515. *
  58516. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58517. * @param taskName defines the name of the new task
  58518. * @param url defines the url of the file to load
  58519. * @param size defines the size you want for the cubemap (can be null)
  58520. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58521. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58522. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58523. * @returns a new EquiRectangularCubeTextureAssetTask object
  58524. */
  58525. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58526. /**
  58527. * Remove a task from the assets manager.
  58528. * @param task the task to remove
  58529. */
  58530. removeTask(task: AbstractAssetTask): void;
  58531. private _decreaseWaitingTasksCount;
  58532. private _runTask;
  58533. /**
  58534. * Reset the AssetsManager and remove all tasks
  58535. * @return the current instance of the AssetsManager
  58536. */
  58537. reset(): AssetsManager;
  58538. /**
  58539. * Start the loading process
  58540. * @return the current instance of the AssetsManager
  58541. */
  58542. load(): AssetsManager;
  58543. /**
  58544. * Start the loading process as an async operation
  58545. * @return a promise returning the list of failed tasks
  58546. */
  58547. loadAsync(): Promise<void>;
  58548. }
  58549. }
  58550. declare module "babylonjs/Misc/deferred" {
  58551. /**
  58552. * Wrapper class for promise with external resolve and reject.
  58553. */
  58554. export class Deferred<T> {
  58555. /**
  58556. * The promise associated with this deferred object.
  58557. */
  58558. readonly promise: Promise<T>;
  58559. private _resolve;
  58560. private _reject;
  58561. /**
  58562. * The resolve method of the promise associated with this deferred object.
  58563. */
  58564. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58565. /**
  58566. * The reject method of the promise associated with this deferred object.
  58567. */
  58568. readonly reject: (reason?: any) => void;
  58569. /**
  58570. * Constructor for this deferred object.
  58571. */
  58572. constructor();
  58573. }
  58574. }
  58575. declare module "babylonjs/Misc/meshExploder" {
  58576. import { Mesh } from "babylonjs/Meshes/mesh";
  58577. /**
  58578. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58579. */
  58580. export class MeshExploder {
  58581. private _centerMesh;
  58582. private _meshes;
  58583. private _meshesOrigins;
  58584. private _toCenterVectors;
  58585. private _scaledDirection;
  58586. private _newPosition;
  58587. private _centerPosition;
  58588. /**
  58589. * Explodes meshes from a center mesh.
  58590. * @param meshes The meshes to explode.
  58591. * @param centerMesh The mesh to be center of explosion.
  58592. */
  58593. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58594. private _setCenterMesh;
  58595. /**
  58596. * Get class name
  58597. * @returns "MeshExploder"
  58598. */
  58599. getClassName(): string;
  58600. /**
  58601. * "Exploded meshes"
  58602. * @returns Array of meshes with the centerMesh at index 0.
  58603. */
  58604. getMeshes(): Array<Mesh>;
  58605. /**
  58606. * Explodes meshes giving a specific direction
  58607. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58608. */
  58609. explode(direction?: number): void;
  58610. }
  58611. }
  58612. declare module "babylonjs/Misc/filesInput" {
  58613. import { Engine } from "babylonjs/Engines/engine";
  58614. import { Scene } from "babylonjs/scene";
  58615. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58616. /**
  58617. * Class used to help managing file picking and drag'n'drop
  58618. */
  58619. export class FilesInput {
  58620. /**
  58621. * List of files ready to be loaded
  58622. */
  58623. static readonly FilesToLoad: {
  58624. [key: string]: File;
  58625. };
  58626. /**
  58627. * Callback called when a file is processed
  58628. */
  58629. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58630. private _engine;
  58631. private _currentScene;
  58632. private _sceneLoadedCallback;
  58633. private _progressCallback;
  58634. private _additionalRenderLoopLogicCallback;
  58635. private _textureLoadingCallback;
  58636. private _startingProcessingFilesCallback;
  58637. private _onReloadCallback;
  58638. private _errorCallback;
  58639. private _elementToMonitor;
  58640. private _sceneFileToLoad;
  58641. private _filesToLoad;
  58642. /**
  58643. * Creates a new FilesInput
  58644. * @param engine defines the rendering engine
  58645. * @param scene defines the hosting scene
  58646. * @param sceneLoadedCallback callback called when scene is loaded
  58647. * @param progressCallback callback called to track progress
  58648. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58649. * @param textureLoadingCallback callback called when a texture is loading
  58650. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58651. * @param onReloadCallback callback called when a reload is requested
  58652. * @param errorCallback callback call if an error occurs
  58653. */
  58654. 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);
  58655. private _dragEnterHandler;
  58656. private _dragOverHandler;
  58657. private _dropHandler;
  58658. /**
  58659. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58660. * @param elementToMonitor defines the DOM element to track
  58661. */
  58662. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58663. /**
  58664. * Release all associated resources
  58665. */
  58666. dispose(): void;
  58667. private renderFunction;
  58668. private drag;
  58669. private drop;
  58670. private _traverseFolder;
  58671. private _processFiles;
  58672. /**
  58673. * Load files from a drop event
  58674. * @param event defines the drop event to use as source
  58675. */
  58676. loadFiles(event: any): void;
  58677. private _processReload;
  58678. /**
  58679. * Reload the current scene from the loaded files
  58680. */
  58681. reload(): void;
  58682. }
  58683. }
  58684. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58685. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58686. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58687. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58688. }
  58689. declare module "babylonjs/Misc/sceneOptimizer" {
  58690. import { Scene, IDisposable } from "babylonjs/scene";
  58691. import { Observable } from "babylonjs/Misc/observable";
  58692. /**
  58693. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58694. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58695. */
  58696. export class SceneOptimization {
  58697. /**
  58698. * Defines the priority of this optimization (0 by default which means first in the list)
  58699. */
  58700. priority: number;
  58701. /**
  58702. * Gets a string describing the action executed by the current optimization
  58703. * @returns description string
  58704. */
  58705. getDescription(): string;
  58706. /**
  58707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58708. * @param scene defines the current scene where to apply this optimization
  58709. * @param optimizer defines the current optimizer
  58710. * @returns true if everything that can be done was applied
  58711. */
  58712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58713. /**
  58714. * Creates the SceneOptimization object
  58715. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58716. * @param desc defines the description associated with the optimization
  58717. */
  58718. constructor(
  58719. /**
  58720. * Defines the priority of this optimization (0 by default which means first in the list)
  58721. */
  58722. priority?: number);
  58723. }
  58724. /**
  58725. * Defines an optimization used to reduce the size of render target textures
  58726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58727. */
  58728. export class TextureOptimization extends SceneOptimization {
  58729. /**
  58730. * Defines the priority of this optimization (0 by default which means first in the list)
  58731. */
  58732. priority: number;
  58733. /**
  58734. * 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
  58735. */
  58736. maximumSize: number;
  58737. /**
  58738. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58739. */
  58740. step: number;
  58741. /**
  58742. * Gets a string describing the action executed by the current optimization
  58743. * @returns description string
  58744. */
  58745. getDescription(): string;
  58746. /**
  58747. * Creates the TextureOptimization object
  58748. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58749. * @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
  58750. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58751. */
  58752. constructor(
  58753. /**
  58754. * Defines the priority of this optimization (0 by default which means first in the list)
  58755. */
  58756. priority?: number,
  58757. /**
  58758. * 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
  58759. */
  58760. maximumSize?: number,
  58761. /**
  58762. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58763. */
  58764. step?: number);
  58765. /**
  58766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58767. * @param scene defines the current scene where to apply this optimization
  58768. * @param optimizer defines the current optimizer
  58769. * @returns true if everything that can be done was applied
  58770. */
  58771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58772. }
  58773. /**
  58774. * Defines an optimization used to increase or decrease the rendering resolution
  58775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58776. */
  58777. export class HardwareScalingOptimization extends SceneOptimization {
  58778. /**
  58779. * Defines the priority of this optimization (0 by default which means first in the list)
  58780. */
  58781. priority: number;
  58782. /**
  58783. * Defines the maximum scale to use (2 by default)
  58784. */
  58785. maximumScale: number;
  58786. /**
  58787. * Defines the step to use between two passes (0.5 by default)
  58788. */
  58789. step: number;
  58790. private _currentScale;
  58791. private _directionOffset;
  58792. /**
  58793. * Gets a string describing the action executed by the current optimization
  58794. * @return description string
  58795. */
  58796. getDescription(): string;
  58797. /**
  58798. * Creates the HardwareScalingOptimization object
  58799. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58800. * @param maximumScale defines the maximum scale to use (2 by default)
  58801. * @param step defines the step to use between two passes (0.5 by default)
  58802. */
  58803. constructor(
  58804. /**
  58805. * Defines the priority of this optimization (0 by default which means first in the list)
  58806. */
  58807. priority?: number,
  58808. /**
  58809. * Defines the maximum scale to use (2 by default)
  58810. */
  58811. maximumScale?: number,
  58812. /**
  58813. * Defines the step to use between two passes (0.5 by default)
  58814. */
  58815. step?: number);
  58816. /**
  58817. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58818. * @param scene defines the current scene where to apply this optimization
  58819. * @param optimizer defines the current optimizer
  58820. * @returns true if everything that can be done was applied
  58821. */
  58822. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58823. }
  58824. /**
  58825. * Defines an optimization used to remove shadows
  58826. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58827. */
  58828. export class ShadowsOptimization extends SceneOptimization {
  58829. /**
  58830. * Gets a string describing the action executed by the current optimization
  58831. * @return description string
  58832. */
  58833. getDescription(): string;
  58834. /**
  58835. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58836. * @param scene defines the current scene where to apply this optimization
  58837. * @param optimizer defines the current optimizer
  58838. * @returns true if everything that can be done was applied
  58839. */
  58840. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58841. }
  58842. /**
  58843. * Defines an optimization used to turn post-processes off
  58844. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58845. */
  58846. export class PostProcessesOptimization extends SceneOptimization {
  58847. /**
  58848. * Gets a string describing the action executed by the current optimization
  58849. * @return description string
  58850. */
  58851. getDescription(): string;
  58852. /**
  58853. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58854. * @param scene defines the current scene where to apply this optimization
  58855. * @param optimizer defines the current optimizer
  58856. * @returns true if everything that can be done was applied
  58857. */
  58858. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58859. }
  58860. /**
  58861. * Defines an optimization used to turn lens flares off
  58862. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58863. */
  58864. export class LensFlaresOptimization extends SceneOptimization {
  58865. /**
  58866. * Gets a string describing the action executed by the current optimization
  58867. * @return description string
  58868. */
  58869. getDescription(): string;
  58870. /**
  58871. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58872. * @param scene defines the current scene where to apply this optimization
  58873. * @param optimizer defines the current optimizer
  58874. * @returns true if everything that can be done was applied
  58875. */
  58876. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58877. }
  58878. /**
  58879. * Defines an optimization based on user defined callback.
  58880. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58881. */
  58882. export class CustomOptimization extends SceneOptimization {
  58883. /**
  58884. * Callback called to apply the custom optimization.
  58885. */
  58886. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58887. /**
  58888. * Callback called to get custom description
  58889. */
  58890. onGetDescription: () => string;
  58891. /**
  58892. * Gets a string describing the action executed by the current optimization
  58893. * @returns description string
  58894. */
  58895. getDescription(): string;
  58896. /**
  58897. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58898. * @param scene defines the current scene where to apply this optimization
  58899. * @param optimizer defines the current optimizer
  58900. * @returns true if everything that can be done was applied
  58901. */
  58902. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58903. }
  58904. /**
  58905. * Defines an optimization used to turn particles off
  58906. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58907. */
  58908. export class ParticlesOptimization extends SceneOptimization {
  58909. /**
  58910. * Gets a string describing the action executed by the current optimization
  58911. * @return description string
  58912. */
  58913. getDescription(): string;
  58914. /**
  58915. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58916. * @param scene defines the current scene where to apply this optimization
  58917. * @param optimizer defines the current optimizer
  58918. * @returns true if everything that can be done was applied
  58919. */
  58920. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58921. }
  58922. /**
  58923. * Defines an optimization used to turn render targets off
  58924. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58925. */
  58926. export class RenderTargetsOptimization extends SceneOptimization {
  58927. /**
  58928. * Gets a string describing the action executed by the current optimization
  58929. * @return description string
  58930. */
  58931. getDescription(): string;
  58932. /**
  58933. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58934. * @param scene defines the current scene where to apply this optimization
  58935. * @param optimizer defines the current optimizer
  58936. * @returns true if everything that can be done was applied
  58937. */
  58938. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58939. }
  58940. /**
  58941. * Defines an optimization used to merge meshes with compatible materials
  58942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58943. */
  58944. export class MergeMeshesOptimization extends SceneOptimization {
  58945. private static _UpdateSelectionTree;
  58946. /**
  58947. * Gets or sets a boolean which defines if optimization octree has to be updated
  58948. */
  58949. /**
  58950. * Gets or sets a boolean which defines if optimization octree has to be updated
  58951. */
  58952. static UpdateSelectionTree: boolean;
  58953. /**
  58954. * Gets a string describing the action executed by the current optimization
  58955. * @return description string
  58956. */
  58957. getDescription(): string;
  58958. private _canBeMerged;
  58959. /**
  58960. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58961. * @param scene defines the current scene where to apply this optimization
  58962. * @param optimizer defines the current optimizer
  58963. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58964. * @returns true if everything that can be done was applied
  58965. */
  58966. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58967. }
  58968. /**
  58969. * Defines a list of options used by SceneOptimizer
  58970. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58971. */
  58972. export class SceneOptimizerOptions {
  58973. /**
  58974. * Defines the target frame rate to reach (60 by default)
  58975. */
  58976. targetFrameRate: number;
  58977. /**
  58978. * Defines the interval between two checkes (2000ms by default)
  58979. */
  58980. trackerDuration: number;
  58981. /**
  58982. * Gets the list of optimizations to apply
  58983. */
  58984. optimizations: SceneOptimization[];
  58985. /**
  58986. * Creates a new list of options used by SceneOptimizer
  58987. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58988. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58989. */
  58990. constructor(
  58991. /**
  58992. * Defines the target frame rate to reach (60 by default)
  58993. */
  58994. targetFrameRate?: number,
  58995. /**
  58996. * Defines the interval between two checkes (2000ms by default)
  58997. */
  58998. trackerDuration?: number);
  58999. /**
  59000. * Add a new optimization
  59001. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59002. * @returns the current SceneOptimizerOptions
  59003. */
  59004. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59005. /**
  59006. * Add a new custom optimization
  59007. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59008. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59009. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59010. * @returns the current SceneOptimizerOptions
  59011. */
  59012. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59013. /**
  59014. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59015. * @param targetFrameRate defines the target frame rate (60 by default)
  59016. * @returns a SceneOptimizerOptions object
  59017. */
  59018. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59019. /**
  59020. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59021. * @param targetFrameRate defines the target frame rate (60 by default)
  59022. * @returns a SceneOptimizerOptions object
  59023. */
  59024. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59025. /**
  59026. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59027. * @param targetFrameRate defines the target frame rate (60 by default)
  59028. * @returns a SceneOptimizerOptions object
  59029. */
  59030. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59031. }
  59032. /**
  59033. * Class used to run optimizations in order to reach a target frame rate
  59034. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59035. */
  59036. export class SceneOptimizer implements IDisposable {
  59037. private _isRunning;
  59038. private _options;
  59039. private _scene;
  59040. private _currentPriorityLevel;
  59041. private _targetFrameRate;
  59042. private _trackerDuration;
  59043. private _currentFrameRate;
  59044. private _sceneDisposeObserver;
  59045. private _improvementMode;
  59046. /**
  59047. * Defines an observable called when the optimizer reaches the target frame rate
  59048. */
  59049. onSuccessObservable: Observable<SceneOptimizer>;
  59050. /**
  59051. * Defines an observable called when the optimizer enables an optimization
  59052. */
  59053. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59054. /**
  59055. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59056. */
  59057. onFailureObservable: Observable<SceneOptimizer>;
  59058. /**
  59059. * Gets a boolean indicating if the optimizer is in improvement mode
  59060. */
  59061. readonly isInImprovementMode: boolean;
  59062. /**
  59063. * Gets the current priority level (0 at start)
  59064. */
  59065. readonly currentPriorityLevel: number;
  59066. /**
  59067. * Gets the current frame rate checked by the SceneOptimizer
  59068. */
  59069. readonly currentFrameRate: number;
  59070. /**
  59071. * Gets or sets the current target frame rate (60 by default)
  59072. */
  59073. /**
  59074. * Gets or sets the current target frame rate (60 by default)
  59075. */
  59076. targetFrameRate: number;
  59077. /**
  59078. * Gets or sets the current interval between two checks (every 2000ms by default)
  59079. */
  59080. /**
  59081. * Gets or sets the current interval between two checks (every 2000ms by default)
  59082. */
  59083. trackerDuration: number;
  59084. /**
  59085. * Gets the list of active optimizations
  59086. */
  59087. readonly optimizations: SceneOptimization[];
  59088. /**
  59089. * Creates a new SceneOptimizer
  59090. * @param scene defines the scene to work on
  59091. * @param options defines the options to use with the SceneOptimizer
  59092. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59093. * @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)
  59094. */
  59095. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59096. /**
  59097. * Stops the current optimizer
  59098. */
  59099. stop(): void;
  59100. /**
  59101. * Reset the optimizer to initial step (current priority level = 0)
  59102. */
  59103. reset(): void;
  59104. /**
  59105. * Start the optimizer. By default it will try to reach a specific framerate
  59106. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59107. */
  59108. start(): void;
  59109. private _checkCurrentState;
  59110. /**
  59111. * Release all resources
  59112. */
  59113. dispose(): void;
  59114. /**
  59115. * Helper function to create a SceneOptimizer with one single line of code
  59116. * @param scene defines the scene to work on
  59117. * @param options defines the options to use with the SceneOptimizer
  59118. * @param onSuccess defines a callback to call on success
  59119. * @param onFailure defines a callback to call on failure
  59120. * @returns the new SceneOptimizer object
  59121. */
  59122. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59123. }
  59124. }
  59125. declare module "babylonjs/Misc/sceneSerializer" {
  59126. import { Scene } from "babylonjs/scene";
  59127. /**
  59128. * Class used to serialize a scene into a string
  59129. */
  59130. export class SceneSerializer {
  59131. /**
  59132. * Clear cache used by a previous serialization
  59133. */
  59134. static ClearCache(): void;
  59135. /**
  59136. * Serialize a scene into a JSON compatible object
  59137. * @param scene defines the scene to serialize
  59138. * @returns a JSON compatible object
  59139. */
  59140. static Serialize(scene: Scene): any;
  59141. /**
  59142. * Serialize a mesh into a JSON compatible object
  59143. * @param toSerialize defines the mesh to serialize
  59144. * @param withParents defines if parents must be serialized as well
  59145. * @param withChildren defines if children must be serialized as well
  59146. * @returns a JSON compatible object
  59147. */
  59148. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59149. }
  59150. }
  59151. declare module "babylonjs/Misc/textureTools" {
  59152. import { Texture } from "babylonjs/Materials/Textures/texture";
  59153. /**
  59154. * Class used to host texture specific utilities
  59155. */
  59156. export class TextureTools {
  59157. /**
  59158. * Uses the GPU to create a copy texture rescaled at a given size
  59159. * @param texture Texture to copy from
  59160. * @param width defines the desired width
  59161. * @param height defines the desired height
  59162. * @param useBilinearMode defines if bilinear mode has to be used
  59163. * @return the generated texture
  59164. */
  59165. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59166. }
  59167. }
  59168. declare module "babylonjs/Misc/videoRecorder" {
  59169. import { Nullable } from "babylonjs/types";
  59170. import { Engine } from "babylonjs/Engines/engine";
  59171. /**
  59172. * This represents the different options avilable for the video capture.
  59173. */
  59174. export interface VideoRecorderOptions {
  59175. /** Defines the mime type of the video */
  59176. mimeType: string;
  59177. /** Defines the video the video should be recorded at */
  59178. fps: number;
  59179. /** Defines the chunk size for the recording data */
  59180. recordChunckSize: number;
  59181. /** The audio tracks to attach to the record */
  59182. audioTracks?: MediaStreamTrack[];
  59183. }
  59184. /**
  59185. * This can helps recording videos from BabylonJS.
  59186. * This is based on the available WebRTC functionalities of the browser.
  59187. *
  59188. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59189. */
  59190. export class VideoRecorder {
  59191. private static readonly _defaultOptions;
  59192. /**
  59193. * Returns wehther or not the VideoRecorder is available in your browser.
  59194. * @param engine Defines the Babylon Engine to check the support for
  59195. * @returns true if supported otherwise false
  59196. */
  59197. static IsSupported(engine: Engine): boolean;
  59198. private readonly _options;
  59199. private _canvas;
  59200. private _mediaRecorder;
  59201. private _recordedChunks;
  59202. private _fileName;
  59203. private _resolve;
  59204. private _reject;
  59205. /**
  59206. * True wether a recording is already in progress.
  59207. */
  59208. readonly isRecording: boolean;
  59209. /**
  59210. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59211. * a video file.
  59212. * @param engine Defines the BabylonJS Engine you wish to record
  59213. * @param options Defines options that can be used to customized the capture
  59214. */
  59215. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59216. /**
  59217. * Stops the current recording before the default capture timeout passed in the startRecording
  59218. * functions.
  59219. */
  59220. stopRecording(): void;
  59221. /**
  59222. * Starts recording the canvas for a max duration specified in parameters.
  59223. * @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.
  59224. * @param maxDuration Defines the maximum recording time in seconds.
  59225. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59226. * @return a promise callback at the end of the recording with the video data in Blob.
  59227. */
  59228. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59229. /**
  59230. * Releases internal resources used during the recording.
  59231. */
  59232. dispose(): void;
  59233. private _handleDataAvailable;
  59234. private _handleError;
  59235. private _handleStop;
  59236. }
  59237. }
  59238. declare module "babylonjs/Misc/screenshotTools" {
  59239. import { Camera } from "babylonjs/Cameras/camera";
  59240. import { Engine } from "babylonjs/Engines/engine";
  59241. /**
  59242. * Class containing a set of static utilities functions for screenshots
  59243. */
  59244. export class ScreenshotTools {
  59245. /**
  59246. * Captures a screenshot of the current rendering
  59247. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59248. * @param engine defines the rendering engine
  59249. * @param camera defines the source camera
  59250. * @param size This parameter can be set to a single number or to an object with the
  59251. * following (optional) properties: precision, width, height. If a single number is passed,
  59252. * it will be used for both width and height. If an object is passed, the screenshot size
  59253. * will be derived from the parameters. The precision property is a multiplier allowing
  59254. * rendering at a higher or lower resolution
  59255. * @param successCallback defines the callback receives a single parameter which contains the
  59256. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59257. * src parameter of an <img> to display it
  59258. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59259. * Check your browser for supported MIME types
  59260. */
  59261. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59262. /**
  59263. * Generates an image screenshot from the specified camera.
  59264. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59265. * @param engine The engine to use for rendering
  59266. * @param camera The camera to use for rendering
  59267. * @param size This parameter can be set to a single number or to an object with the
  59268. * following (optional) properties: precision, width, height. If a single number is passed,
  59269. * it will be used for both width and height. If an object is passed, the screenshot size
  59270. * will be derived from the parameters. The precision property is a multiplier allowing
  59271. * rendering at a higher or lower resolution
  59272. * @param successCallback The callback receives a single parameter which contains the
  59273. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59274. * src parameter of an <img> to display it
  59275. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59276. * Check your browser for supported MIME types
  59277. * @param samples Texture samples (default: 1)
  59278. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59279. * @param fileName A name for for the downloaded file.
  59280. */
  59281. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59282. }
  59283. }
  59284. declare module "babylonjs/Misc/index" {
  59285. export * from "babylonjs/Misc/andOrNotEvaluator";
  59286. export * from "babylonjs/Misc/assetsManager";
  59287. export * from "babylonjs/Misc/dds";
  59288. export * from "babylonjs/Misc/decorators";
  59289. export * from "babylonjs/Misc/deferred";
  59290. export * from "babylonjs/Misc/environmentTextureTools";
  59291. export * from "babylonjs/Misc/meshExploder";
  59292. export * from "babylonjs/Misc/filesInput";
  59293. export * from "babylonjs/Misc/HighDynamicRange/index";
  59294. export * from "babylonjs/Misc/khronosTextureContainer";
  59295. export * from "babylonjs/Misc/observable";
  59296. export * from "babylonjs/Misc/performanceMonitor";
  59297. export * from "babylonjs/Misc/promise";
  59298. export * from "babylonjs/Misc/sceneOptimizer";
  59299. export * from "babylonjs/Misc/sceneSerializer";
  59300. export * from "babylonjs/Misc/smartArray";
  59301. export * from "babylonjs/Misc/stringDictionary";
  59302. export * from "babylonjs/Misc/tags";
  59303. export * from "babylonjs/Misc/textureTools";
  59304. export * from "babylonjs/Misc/tga";
  59305. export * from "babylonjs/Misc/tools";
  59306. export * from "babylonjs/Misc/videoRecorder";
  59307. export * from "babylonjs/Misc/virtualJoystick";
  59308. export * from "babylonjs/Misc/workerPool";
  59309. export * from "babylonjs/Misc/logger";
  59310. export * from "babylonjs/Misc/typeStore";
  59311. export * from "babylonjs/Misc/filesInputStore";
  59312. export * from "babylonjs/Misc/deepCopier";
  59313. export * from "babylonjs/Misc/pivotTools";
  59314. export * from "babylonjs/Misc/precisionDate";
  59315. export * from "babylonjs/Misc/screenshotTools";
  59316. export * from "babylonjs/Misc/typeStore";
  59317. export * from "babylonjs/Misc/webRequest";
  59318. export * from "babylonjs/Misc/iInspectable";
  59319. }
  59320. declare module "babylonjs/index" {
  59321. export * from "babylonjs/abstractScene";
  59322. export * from "babylonjs/Actions/index";
  59323. export * from "babylonjs/Animations/index";
  59324. export * from "babylonjs/assetContainer";
  59325. export * from "babylonjs/Audio/index";
  59326. export * from "babylonjs/Behaviors/index";
  59327. export * from "babylonjs/Bones/index";
  59328. export * from "babylonjs/Cameras/index";
  59329. export * from "babylonjs/Collisions/index";
  59330. export * from "babylonjs/Culling/index";
  59331. export * from "babylonjs/Debug/index";
  59332. export * from "babylonjs/Engines/index";
  59333. export * from "babylonjs/Events/index";
  59334. export * from "babylonjs/Gamepads/index";
  59335. export * from "babylonjs/Gizmos/index";
  59336. export * from "babylonjs/Helpers/index";
  59337. export * from "babylonjs/Instrumentation/index";
  59338. export * from "babylonjs/Layers/index";
  59339. export * from "babylonjs/LensFlares/index";
  59340. export * from "babylonjs/Lights/index";
  59341. export * from "babylonjs/Loading/index";
  59342. export * from "babylonjs/Materials/index";
  59343. export * from "babylonjs/Maths/index";
  59344. export * from "babylonjs/Meshes/index";
  59345. export * from "babylonjs/Morph/index";
  59346. export * from "babylonjs/node";
  59347. export * from "babylonjs/Offline/index";
  59348. export * from "babylonjs/Particles/index";
  59349. export * from "babylonjs/Physics/index";
  59350. export * from "babylonjs/PostProcesses/index";
  59351. export * from "babylonjs/Probes/index";
  59352. export * from "babylonjs/Rendering/index";
  59353. export * from "babylonjs/scene";
  59354. export * from "babylonjs/sceneComponent";
  59355. export * from "babylonjs/Sprites/index";
  59356. export * from "babylonjs/States/index";
  59357. export * from "babylonjs/Misc/index";
  59358. export * from "babylonjs/types";
  59359. }
  59360. declare module "babylonjs/Animations/pathCursor" {
  59361. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59362. /**
  59363. * A cursor which tracks a point on a path
  59364. */
  59365. export class PathCursor {
  59366. private path;
  59367. /**
  59368. * Stores path cursor callbacks for when an onchange event is triggered
  59369. */
  59370. private _onchange;
  59371. /**
  59372. * The value of the path cursor
  59373. */
  59374. value: number;
  59375. /**
  59376. * The animation array of the path cursor
  59377. */
  59378. animations: Animation[];
  59379. /**
  59380. * Initializes the path cursor
  59381. * @param path The path to track
  59382. */
  59383. constructor(path: Path2);
  59384. /**
  59385. * Gets the cursor point on the path
  59386. * @returns A point on the path cursor at the cursor location
  59387. */
  59388. getPoint(): Vector3;
  59389. /**
  59390. * Moves the cursor ahead by the step amount
  59391. * @param step The amount to move the cursor forward
  59392. * @returns This path cursor
  59393. */
  59394. moveAhead(step?: number): PathCursor;
  59395. /**
  59396. * Moves the cursor behind by the step amount
  59397. * @param step The amount to move the cursor back
  59398. * @returns This path cursor
  59399. */
  59400. moveBack(step?: number): PathCursor;
  59401. /**
  59402. * Moves the cursor by the step amount
  59403. * If the step amount is greater than one, an exception is thrown
  59404. * @param step The amount to move the cursor
  59405. * @returns This path cursor
  59406. */
  59407. move(step: number): PathCursor;
  59408. /**
  59409. * Ensures that the value is limited between zero and one
  59410. * @returns This path cursor
  59411. */
  59412. private ensureLimits;
  59413. /**
  59414. * Runs onchange callbacks on change (used by the animation engine)
  59415. * @returns This path cursor
  59416. */
  59417. private raiseOnChange;
  59418. /**
  59419. * Executes a function on change
  59420. * @param f A path cursor onchange callback
  59421. * @returns This path cursor
  59422. */
  59423. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59424. }
  59425. }
  59426. declare module "babylonjs/Legacy/legacy" {
  59427. import * as Babylon from "babylonjs/index";
  59428. export * from "babylonjs/index";
  59429. }
  59430. declare module "babylonjs/Shaders/blur.fragment" {
  59431. /** @hidden */
  59432. export var blurPixelShader: {
  59433. name: string;
  59434. shader: string;
  59435. };
  59436. }
  59437. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59438. /** @hidden */
  59439. export var bones300Declaration: {
  59440. name: string;
  59441. shader: string;
  59442. };
  59443. }
  59444. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59445. /** @hidden */
  59446. export var instances300Declaration: {
  59447. name: string;
  59448. shader: string;
  59449. };
  59450. }
  59451. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59452. /** @hidden */
  59453. export var pointCloudVertexDeclaration: {
  59454. name: string;
  59455. shader: string;
  59456. };
  59457. }
  59458. // Mixins
  59459. interface Window {
  59460. mozIndexedDB: IDBFactory;
  59461. webkitIndexedDB: IDBFactory;
  59462. msIndexedDB: IDBFactory;
  59463. webkitURL: typeof URL;
  59464. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59465. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59466. WebGLRenderingContext: WebGLRenderingContext;
  59467. MSGesture: MSGesture;
  59468. CANNON: any;
  59469. AudioContext: AudioContext;
  59470. webkitAudioContext: AudioContext;
  59471. PointerEvent: any;
  59472. Math: Math;
  59473. Uint8Array: Uint8ArrayConstructor;
  59474. Float32Array: Float32ArrayConstructor;
  59475. mozURL: typeof URL;
  59476. msURL: typeof URL;
  59477. VRFrameData: any; // WebVR, from specs 1.1
  59478. DracoDecoderModule: any;
  59479. setImmediate(handler: (...args: any[]) => void): number;
  59480. }
  59481. interface HTMLCanvasElement {
  59482. requestPointerLock(): void;
  59483. msRequestPointerLock?(): void;
  59484. mozRequestPointerLock?(): void;
  59485. webkitRequestPointerLock?(): void;
  59486. /** Track wether a record is in progress */
  59487. isRecording: boolean;
  59488. /** Capture Stream method defined by some browsers */
  59489. captureStream(fps?: number): MediaStream;
  59490. }
  59491. interface CanvasRenderingContext2D {
  59492. msImageSmoothingEnabled: boolean;
  59493. }
  59494. interface MouseEvent {
  59495. mozMovementX: number;
  59496. mozMovementY: number;
  59497. webkitMovementX: number;
  59498. webkitMovementY: number;
  59499. msMovementX: number;
  59500. msMovementY: number;
  59501. }
  59502. interface Navigator {
  59503. mozGetVRDevices: (any: any) => any;
  59504. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59505. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59506. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59507. webkitGetGamepads(): Gamepad[];
  59508. msGetGamepads(): Gamepad[];
  59509. webkitGamepads(): Gamepad[];
  59510. }
  59511. interface HTMLVideoElement {
  59512. mozSrcObject: any;
  59513. }
  59514. interface Math {
  59515. fround(x: number): number;
  59516. imul(a: number, b: number): number;
  59517. }
  59518. interface WebGLRenderingContext {
  59519. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59520. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59521. vertexAttribDivisor(index: number, divisor: number): void;
  59522. createVertexArray(): any;
  59523. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59524. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59525. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59526. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59527. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59528. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59529. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59530. // Queries
  59531. createQuery(): WebGLQuery;
  59532. deleteQuery(query: WebGLQuery): void;
  59533. beginQuery(target: number, query: WebGLQuery): void;
  59534. endQuery(target: number): void;
  59535. getQueryParameter(query: WebGLQuery, pname: number): any;
  59536. getQuery(target: number, pname: number): any;
  59537. MAX_SAMPLES: number;
  59538. RGBA8: number;
  59539. READ_FRAMEBUFFER: number;
  59540. DRAW_FRAMEBUFFER: number;
  59541. UNIFORM_BUFFER: number;
  59542. HALF_FLOAT_OES: number;
  59543. RGBA16F: number;
  59544. RGBA32F: number;
  59545. R32F: number;
  59546. RG32F: number;
  59547. RGB32F: number;
  59548. R16F: number;
  59549. RG16F: number;
  59550. RGB16F: number;
  59551. RED: number;
  59552. RG: number;
  59553. R8: number;
  59554. RG8: number;
  59555. UNSIGNED_INT_24_8: number;
  59556. DEPTH24_STENCIL8: number;
  59557. /* Multiple Render Targets */
  59558. drawBuffers(buffers: number[]): void;
  59559. readBuffer(src: number): void;
  59560. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59561. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59562. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59563. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59564. // Occlusion Query
  59565. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59566. ANY_SAMPLES_PASSED: number;
  59567. QUERY_RESULT_AVAILABLE: number;
  59568. QUERY_RESULT: number;
  59569. }
  59570. interface WebGLProgram {
  59571. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59572. }
  59573. interface EXT_disjoint_timer_query {
  59574. QUERY_COUNTER_BITS_EXT: number;
  59575. TIME_ELAPSED_EXT: number;
  59576. TIMESTAMP_EXT: number;
  59577. GPU_DISJOINT_EXT: number;
  59578. QUERY_RESULT_EXT: number;
  59579. QUERY_RESULT_AVAILABLE_EXT: number;
  59580. queryCounterEXT(query: WebGLQuery, target: number): void;
  59581. createQueryEXT(): WebGLQuery;
  59582. beginQueryEXT(target: number, query: WebGLQuery): void;
  59583. endQueryEXT(target: number): void;
  59584. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59585. deleteQueryEXT(query: WebGLQuery): void;
  59586. }
  59587. interface WebGLUniformLocation {
  59588. _currentState: any;
  59589. }
  59590. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59591. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59592. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59593. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59594. interface WebGLRenderingContext {
  59595. readonly RASTERIZER_DISCARD: number;
  59596. readonly DEPTH_COMPONENT24: number;
  59597. readonly TEXTURE_3D: number;
  59598. readonly TEXTURE_2D_ARRAY: number;
  59599. readonly TEXTURE_COMPARE_FUNC: number;
  59600. readonly TEXTURE_COMPARE_MODE: number;
  59601. readonly COMPARE_REF_TO_TEXTURE: number;
  59602. readonly TEXTURE_WRAP_R: number;
  59603. readonly HALF_FLOAT: number;
  59604. readonly RGB8: number;
  59605. readonly RED_INTEGER: number;
  59606. readonly RG_INTEGER: number;
  59607. readonly RGB_INTEGER: number;
  59608. readonly RGBA_INTEGER: number;
  59609. readonly R8_SNORM: number;
  59610. readonly RG8_SNORM: number;
  59611. readonly RGB8_SNORM: number;
  59612. readonly RGBA8_SNORM: number;
  59613. readonly R8I: number;
  59614. readonly RG8I: number;
  59615. readonly RGB8I: number;
  59616. readonly RGBA8I: number;
  59617. readonly R8UI: number;
  59618. readonly RG8UI: number;
  59619. readonly RGB8UI: number;
  59620. readonly RGBA8UI: number;
  59621. readonly R16I: number;
  59622. readonly RG16I: number;
  59623. readonly RGB16I: number;
  59624. readonly RGBA16I: number;
  59625. readonly R16UI: number;
  59626. readonly RG16UI: number;
  59627. readonly RGB16UI: number;
  59628. readonly RGBA16UI: number;
  59629. readonly R32I: number;
  59630. readonly RG32I: number;
  59631. readonly RGB32I: number;
  59632. readonly RGBA32I: number;
  59633. readonly R32UI: number;
  59634. readonly RG32UI: number;
  59635. readonly RGB32UI: number;
  59636. readonly RGBA32UI: number;
  59637. readonly RGB10_A2UI: number;
  59638. readonly R11F_G11F_B10F: number;
  59639. readonly RGB9_E5: number;
  59640. readonly RGB10_A2: number;
  59641. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59642. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59643. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59644. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59645. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59646. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59647. 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;
  59648. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59649. readonly TRANSFORM_FEEDBACK: number;
  59650. readonly INTERLEAVED_ATTRIBS: number;
  59651. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59652. createTransformFeedback(): WebGLTransformFeedback;
  59653. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59654. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59655. beginTransformFeedback(primitiveMode: number): void;
  59656. endTransformFeedback(): void;
  59657. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59658. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59659. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59660. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59661. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59662. }
  59663. interface ImageBitmap {
  59664. readonly width: number;
  59665. readonly height: number;
  59666. close(): void;
  59667. }
  59668. interface WebGLQuery extends WebGLObject {
  59669. }
  59670. declare var WebGLQuery: {
  59671. prototype: WebGLQuery;
  59672. new(): WebGLQuery;
  59673. };
  59674. interface WebGLSampler extends WebGLObject {
  59675. }
  59676. declare var WebGLSampler: {
  59677. prototype: WebGLSampler;
  59678. new(): WebGLSampler;
  59679. };
  59680. interface WebGLSync extends WebGLObject {
  59681. }
  59682. declare var WebGLSync: {
  59683. prototype: WebGLSync;
  59684. new(): WebGLSync;
  59685. };
  59686. interface WebGLTransformFeedback extends WebGLObject {
  59687. }
  59688. declare var WebGLTransformFeedback: {
  59689. prototype: WebGLTransformFeedback;
  59690. new(): WebGLTransformFeedback;
  59691. };
  59692. interface WebGLVertexArrayObject extends WebGLObject {
  59693. }
  59694. declare var WebGLVertexArrayObject: {
  59695. prototype: WebGLVertexArrayObject;
  59696. new(): WebGLVertexArrayObject;
  59697. };
  59698. // Type definitions for WebVR API
  59699. // Project: https://w3c.github.io/webvr/
  59700. // Definitions by: six a <https://github.com/lostfictions>
  59701. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59702. interface VRDisplay extends EventTarget {
  59703. /**
  59704. * Dictionary of capabilities describing the VRDisplay.
  59705. */
  59706. readonly capabilities: VRDisplayCapabilities;
  59707. /**
  59708. * z-depth defining the far plane of the eye view frustum
  59709. * enables mapping of values in the render target depth
  59710. * attachment to scene coordinates. Initially set to 10000.0.
  59711. */
  59712. depthFar: number;
  59713. /**
  59714. * z-depth defining the near plane of the eye view frustum
  59715. * enables mapping of values in the render target depth
  59716. * attachment to scene coordinates. Initially set to 0.01.
  59717. */
  59718. depthNear: number;
  59719. /**
  59720. * An identifier for this distinct VRDisplay. Used as an
  59721. * association point in the Gamepad API.
  59722. */
  59723. readonly displayId: number;
  59724. /**
  59725. * A display name, a user-readable name identifying it.
  59726. */
  59727. readonly displayName: string;
  59728. readonly isConnected: boolean;
  59729. readonly isPresenting: boolean;
  59730. /**
  59731. * If this VRDisplay supports room-scale experiences, the optional
  59732. * stage attribute contains details on the room-scale parameters.
  59733. */
  59734. readonly stageParameters: VRStageParameters | null;
  59735. /**
  59736. * Passing the value returned by `requestAnimationFrame` to
  59737. * `cancelAnimationFrame` will unregister the callback.
  59738. * @param handle Define the hanle of the request to cancel
  59739. */
  59740. cancelAnimationFrame(handle: number): void;
  59741. /**
  59742. * Stops presenting to the VRDisplay.
  59743. * @returns a promise to know when it stopped
  59744. */
  59745. exitPresent(): Promise<void>;
  59746. /**
  59747. * Return the current VREyeParameters for the given eye.
  59748. * @param whichEye Define the eye we want the parameter for
  59749. * @returns the eye parameters
  59750. */
  59751. getEyeParameters(whichEye: string): VREyeParameters;
  59752. /**
  59753. * Populates the passed VRFrameData with the information required to render
  59754. * the current frame.
  59755. * @param frameData Define the data structure to populate
  59756. * @returns true if ok otherwise false
  59757. */
  59758. getFrameData(frameData: VRFrameData): boolean;
  59759. /**
  59760. * Get the layers currently being presented.
  59761. * @returns the list of VR layers
  59762. */
  59763. getLayers(): VRLayer[];
  59764. /**
  59765. * Return a VRPose containing the future predicted pose of the VRDisplay
  59766. * when the current frame will be presented. The value returned will not
  59767. * change until JavaScript has returned control to the browser.
  59768. *
  59769. * The VRPose will contain the position, orientation, velocity,
  59770. * and acceleration of each of these properties.
  59771. * @returns the pose object
  59772. */
  59773. getPose(): VRPose;
  59774. /**
  59775. * Return the current instantaneous pose of the VRDisplay, with no
  59776. * prediction applied.
  59777. * @returns the current instantaneous pose
  59778. */
  59779. getImmediatePose(): VRPose;
  59780. /**
  59781. * The callback passed to `requestAnimationFrame` will be called
  59782. * any time a new frame should be rendered. When the VRDisplay is
  59783. * presenting the callback will be called at the native refresh
  59784. * rate of the HMD. When not presenting this function acts
  59785. * identically to how window.requestAnimationFrame acts. Content should
  59786. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59787. * asynchronously from other displays and at differing refresh rates.
  59788. * @param callback Define the eaction to run next frame
  59789. * @returns the request handle it
  59790. */
  59791. requestAnimationFrame(callback: FrameRequestCallback): number;
  59792. /**
  59793. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59794. * Repeat calls while already presenting will update the VRLayers being displayed.
  59795. * @param layers Define the list of layer to present
  59796. * @returns a promise to know when the request has been fulfilled
  59797. */
  59798. requestPresent(layers: VRLayer[]): Promise<void>;
  59799. /**
  59800. * Reset the pose for this display, treating its current position and
  59801. * orientation as the "origin/zero" values. VRPose.position,
  59802. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59803. * updated when calling resetPose(). This should be called in only
  59804. * sitting-space experiences.
  59805. */
  59806. resetPose(): void;
  59807. /**
  59808. * The VRLayer provided to the VRDisplay will be captured and presented
  59809. * in the HMD. Calling this function has the same effect on the source
  59810. * canvas as any other operation that uses its source image, and canvases
  59811. * created without preserveDrawingBuffer set to true will be cleared.
  59812. * @param pose Define the pose to submit
  59813. */
  59814. submitFrame(pose?: VRPose): void;
  59815. }
  59816. declare var VRDisplay: {
  59817. prototype: VRDisplay;
  59818. new(): VRDisplay;
  59819. };
  59820. interface VRLayer {
  59821. leftBounds?: number[] | Float32Array | null;
  59822. rightBounds?: number[] | Float32Array | null;
  59823. source?: HTMLCanvasElement | null;
  59824. }
  59825. interface VRDisplayCapabilities {
  59826. readonly canPresent: boolean;
  59827. readonly hasExternalDisplay: boolean;
  59828. readonly hasOrientation: boolean;
  59829. readonly hasPosition: boolean;
  59830. readonly maxLayers: number;
  59831. }
  59832. interface VREyeParameters {
  59833. /** @deprecated */
  59834. readonly fieldOfView: VRFieldOfView;
  59835. readonly offset: Float32Array;
  59836. readonly renderHeight: number;
  59837. readonly renderWidth: number;
  59838. }
  59839. interface VRFieldOfView {
  59840. readonly downDegrees: number;
  59841. readonly leftDegrees: number;
  59842. readonly rightDegrees: number;
  59843. readonly upDegrees: number;
  59844. }
  59845. interface VRFrameData {
  59846. readonly leftProjectionMatrix: Float32Array;
  59847. readonly leftViewMatrix: Float32Array;
  59848. readonly pose: VRPose;
  59849. readonly rightProjectionMatrix: Float32Array;
  59850. readonly rightViewMatrix: Float32Array;
  59851. readonly timestamp: number;
  59852. }
  59853. interface VRPose {
  59854. readonly angularAcceleration: Float32Array | null;
  59855. readonly angularVelocity: Float32Array | null;
  59856. readonly linearAcceleration: Float32Array | null;
  59857. readonly linearVelocity: Float32Array | null;
  59858. readonly orientation: Float32Array | null;
  59859. readonly position: Float32Array | null;
  59860. readonly timestamp: number;
  59861. }
  59862. interface VRStageParameters {
  59863. sittingToStandingTransform?: Float32Array;
  59864. sizeX?: number;
  59865. sizeY?: number;
  59866. }
  59867. interface Navigator {
  59868. getVRDisplays(): Promise<VRDisplay[]>;
  59869. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59870. }
  59871. interface Window {
  59872. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59873. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59874. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59875. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59876. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59877. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59878. }
  59879. interface Gamepad {
  59880. readonly displayId: number;
  59881. }
  59882. interface XRDevice {
  59883. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59884. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59885. }
  59886. interface XRSession {
  59887. getInputSources(): Array<any>;
  59888. baseLayer: XRWebGLLayer;
  59889. requestFrameOfReference(type: string): Promise<void>;
  59890. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59891. end(): Promise<void>;
  59892. requestAnimationFrame: Function;
  59893. addEventListener: Function;
  59894. }
  59895. interface XRSessionCreationOptions {
  59896. outputContext?: WebGLRenderingContext | null;
  59897. immersive?: boolean;
  59898. environmentIntegration?: boolean;
  59899. }
  59900. interface XRLayer {
  59901. getViewport: Function;
  59902. framebufferWidth: number;
  59903. framebufferHeight: number;
  59904. }
  59905. interface XRView {
  59906. projectionMatrix: Float32Array;
  59907. }
  59908. interface XRFrame {
  59909. getDevicePose: Function;
  59910. getInputPose: Function;
  59911. views: Array<XRView>;
  59912. baseLayer: XRLayer;
  59913. }
  59914. interface XRFrameOfReference {
  59915. }
  59916. interface XRWebGLLayer extends XRLayer {
  59917. framebuffer: WebGLFramebuffer;
  59918. }
  59919. declare var XRWebGLLayer: {
  59920. prototype: XRWebGLLayer;
  59921. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59922. };
  59923. declare module "babylonjs" {
  59924. export * from "babylonjs/Legacy/legacy";
  59925. }
  59926. declare module BABYLON {
  59927. /** Alias type for value that can be null */
  59928. export type Nullable<T> = T | null;
  59929. /**
  59930. * Alias type for number that are floats
  59931. * @ignorenaming
  59932. */
  59933. export type float = number;
  59934. /**
  59935. * Alias type for number that are doubles.
  59936. * @ignorenaming
  59937. */
  59938. export type double = number;
  59939. /**
  59940. * Alias type for number that are integer
  59941. * @ignorenaming
  59942. */
  59943. export type int = number;
  59944. /** Alias type for number array or Float32Array */
  59945. export type FloatArray = number[] | Float32Array;
  59946. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59947. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59948. /**
  59949. * Alias for types that can be used by a Buffer or VertexBuffer.
  59950. */
  59951. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59952. /**
  59953. * Alias type for primitive types
  59954. * @ignorenaming
  59955. */
  59956. type Primitive = undefined | null | boolean | string | number | Function;
  59957. /**
  59958. * Type modifier to make all the properties of an object Readonly
  59959. */
  59960. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59961. /**
  59962. * Type modifier to make all the properties of an object Readonly recursively
  59963. */
  59964. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59965. /** @hidden */
  59966. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59967. }
  59968. /** @hidden */
  59969. /** @hidden */
  59970. type DeepImmutableObject<T> = {
  59971. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59972. };
  59973. }
  59974. declare module BABYLON {
  59975. /**
  59976. * Class containing a set of static utilities functions for arrays.
  59977. */
  59978. export class ArrayTools {
  59979. /**
  59980. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59981. * @param size the number of element to construct and put in the array
  59982. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59983. * @returns a new array filled with new objects
  59984. */
  59985. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59986. }
  59987. }
  59988. declare module BABYLON {
  59989. /**
  59990. * Scalar computation library
  59991. */
  59992. export class Scalar {
  59993. /**
  59994. * Two pi constants convenient for computation.
  59995. */
  59996. static TwoPi: number;
  59997. /**
  59998. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59999. * @param a number
  60000. * @param b number
  60001. * @param epsilon (default = 1.401298E-45)
  60002. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60003. */
  60004. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  60005. /**
  60006. * Returns a string : the upper case translation of the number i to hexadecimal.
  60007. * @param i number
  60008. * @returns the upper case translation of the number i to hexadecimal.
  60009. */
  60010. static ToHex(i: number): string;
  60011. /**
  60012. * Returns -1 if value is negative and +1 is value is positive.
  60013. * @param value the value
  60014. * @returns the value itself if it's equal to zero.
  60015. */
  60016. static Sign(value: number): number;
  60017. /**
  60018. * Returns the value itself if it's between min and max.
  60019. * Returns min if the value is lower than min.
  60020. * Returns max if the value is greater than max.
  60021. * @param value the value to clmap
  60022. * @param min the min value to clamp to (default: 0)
  60023. * @param max the max value to clamp to (default: 1)
  60024. * @returns the clamped value
  60025. */
  60026. static Clamp(value: number, min?: number, max?: number): number;
  60027. /**
  60028. * the log2 of value.
  60029. * @param value the value to compute log2 of
  60030. * @returns the log2 of value.
  60031. */
  60032. static Log2(value: number): number;
  60033. /**
  60034. * Loops the value, so that it is never larger than length and never smaller than 0.
  60035. *
  60036. * This is similar to the modulo operator but it works with floating point numbers.
  60037. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  60038. * With t = 5 and length = 2.5, the result would be 0.0.
  60039. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  60040. * @param value the value
  60041. * @param length the length
  60042. * @returns the looped value
  60043. */
  60044. static Repeat(value: number, length: number): number;
  60045. /**
  60046. * Normalize the value between 0.0 and 1.0 using min and max values
  60047. * @param value value to normalize
  60048. * @param min max to normalize between
  60049. * @param max min to normalize between
  60050. * @returns the normalized value
  60051. */
  60052. static Normalize(value: number, min: number, max: number): number;
  60053. /**
  60054. * Denormalize the value from 0.0 and 1.0 using min and max values
  60055. * @param normalized value to denormalize
  60056. * @param min max to denormalize between
  60057. * @param max min to denormalize between
  60058. * @returns the denormalized value
  60059. */
  60060. static Denormalize(normalized: number, min: number, max: number): number;
  60061. /**
  60062. * Calculates the shortest difference between two given angles given in degrees.
  60063. * @param current current angle in degrees
  60064. * @param target target angle in degrees
  60065. * @returns the delta
  60066. */
  60067. static DeltaAngle(current: number, target: number): number;
  60068. /**
  60069. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  60070. * @param tx value
  60071. * @param length length
  60072. * @returns The returned value will move back and forth between 0 and length
  60073. */
  60074. static PingPong(tx: number, length: number): number;
  60075. /**
  60076. * Interpolates between min and max with smoothing at the limits.
  60077. *
  60078. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  60079. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  60080. * @param from from
  60081. * @param to to
  60082. * @param tx value
  60083. * @returns the smooth stepped value
  60084. */
  60085. static SmoothStep(from: number, to: number, tx: number): number;
  60086. /**
  60087. * Moves a value current towards target.
  60088. *
  60089. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  60090. * Negative values of maxDelta pushes the value away from target.
  60091. * @param current current value
  60092. * @param target target value
  60093. * @param maxDelta max distance to move
  60094. * @returns resulting value
  60095. */
  60096. static MoveTowards(current: number, target: number, maxDelta: number): number;
  60097. /**
  60098. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60099. *
  60100. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  60101. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  60102. * @param current current value
  60103. * @param target target value
  60104. * @param maxDelta max distance to move
  60105. * @returns resulting angle
  60106. */
  60107. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  60108. /**
  60109. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  60110. * @param start start value
  60111. * @param end target value
  60112. * @param amount amount to lerp between
  60113. * @returns the lerped value
  60114. */
  60115. static Lerp(start: number, end: number, amount: number): number;
  60116. /**
  60117. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60118. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  60119. * @param start start value
  60120. * @param end target value
  60121. * @param amount amount to lerp between
  60122. * @returns the lerped value
  60123. */
  60124. static LerpAngle(start: number, end: number, amount: number): number;
  60125. /**
  60126. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  60127. * @param a start value
  60128. * @param b target value
  60129. * @param value value between a and b
  60130. * @returns the inverseLerp value
  60131. */
  60132. static InverseLerp(a: number, b: number, value: number): number;
  60133. /**
  60134. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  60135. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  60136. * @param value1 spline value
  60137. * @param tangent1 spline value
  60138. * @param value2 spline value
  60139. * @param tangent2 spline value
  60140. * @param amount input value
  60141. * @returns hermite result
  60142. */
  60143. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  60144. /**
  60145. * Returns a random float number between and min and max values
  60146. * @param min min value of random
  60147. * @param max max value of random
  60148. * @returns random value
  60149. */
  60150. static RandomRange(min: number, max: number): number;
  60151. /**
  60152. * This function returns percentage of a number in a given range.
  60153. *
  60154. * RangeToPercent(40,20,60) will return 0.5 (50%)
  60155. * RangeToPercent(34,0,100) will return 0.34 (34%)
  60156. * @param number to convert to percentage
  60157. * @param min min range
  60158. * @param max max range
  60159. * @returns the percentage
  60160. */
  60161. static RangeToPercent(number: number, min: number, max: number): number;
  60162. /**
  60163. * This function returns number that corresponds to the percentage in a given range.
  60164. *
  60165. * PercentToRange(0.34,0,100) will return 34.
  60166. * @param percent to convert to number
  60167. * @param min min range
  60168. * @param max max range
  60169. * @returns the number
  60170. */
  60171. static PercentToRange(percent: number, min: number, max: number): number;
  60172. /**
  60173. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  60174. * @param angle The angle to normalize in radian.
  60175. * @return The converted angle.
  60176. */
  60177. static NormalizeRadians(angle: number): number;
  60178. }
  60179. }
  60180. declare module BABYLON {
  60181. /**
  60182. * Constant used to convert a value to gamma space
  60183. * @ignorenaming
  60184. */
  60185. export const ToGammaSpace: number;
  60186. /**
  60187. * Constant used to convert a value to linear space
  60188. * @ignorenaming
  60189. */
  60190. export const ToLinearSpace = 2.2;
  60191. /**
  60192. * Constant used to define the minimal number value in Babylon.js
  60193. * @ignorenaming
  60194. */
  60195. let Epsilon: number;
  60196. /**
  60197. * Class used to hold a RBG color
  60198. */
  60199. export class Color3 {
  60200. /**
  60201. * Defines the red component (between 0 and 1, default is 0)
  60202. */
  60203. r: number;
  60204. /**
  60205. * Defines the green component (between 0 and 1, default is 0)
  60206. */
  60207. g: number;
  60208. /**
  60209. * Defines the blue component (between 0 and 1, default is 0)
  60210. */
  60211. b: number;
  60212. /**
  60213. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60214. * @param r defines the red component (between 0 and 1, default is 0)
  60215. * @param g defines the green component (between 0 and 1, default is 0)
  60216. * @param b defines the blue component (between 0 and 1, default is 0)
  60217. */
  60218. constructor(
  60219. /**
  60220. * Defines the red component (between 0 and 1, default is 0)
  60221. */
  60222. r?: number,
  60223. /**
  60224. * Defines the green component (between 0 and 1, default is 0)
  60225. */
  60226. g?: number,
  60227. /**
  60228. * Defines the blue component (between 0 and 1, default is 0)
  60229. */
  60230. b?: number);
  60231. /**
  60232. * Creates a string with the Color3 current values
  60233. * @returns the string representation of the Color3 object
  60234. */
  60235. toString(): string;
  60236. /**
  60237. * Returns the string "Color3"
  60238. * @returns "Color3"
  60239. */
  60240. getClassName(): string;
  60241. /**
  60242. * Compute the Color3 hash code
  60243. * @returns an unique number that can be used to hash Color3 objects
  60244. */
  60245. getHashCode(): number;
  60246. /**
  60247. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60248. * @param array defines the array where to store the r,g,b components
  60249. * @param index defines an optional index in the target array to define where to start storing values
  60250. * @returns the current Color3 object
  60251. */
  60252. toArray(array: FloatArray, index?: number): Color3;
  60253. /**
  60254. * Returns a new Color4 object from the current Color3 and the given alpha
  60255. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60256. * @returns a new Color4 object
  60257. */
  60258. toColor4(alpha?: number): Color4;
  60259. /**
  60260. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60261. * @returns the new array
  60262. */
  60263. asArray(): number[];
  60264. /**
  60265. * Returns the luminance value
  60266. * @returns a float value
  60267. */
  60268. toLuminance(): number;
  60269. /**
  60270. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60271. * @param otherColor defines the second operand
  60272. * @returns the new Color3 object
  60273. */
  60274. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60275. /**
  60276. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60277. * @param otherColor defines the second operand
  60278. * @param result defines the Color3 object where to store the result
  60279. * @returns the current Color3
  60280. */
  60281. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60282. /**
  60283. * Determines equality between Color3 objects
  60284. * @param otherColor defines the second operand
  60285. * @returns true if the rgb values are equal to the given ones
  60286. */
  60287. equals(otherColor: DeepImmutable<Color3>): boolean;
  60288. /**
  60289. * Determines equality between the current Color3 object and a set of r,b,g values
  60290. * @param r defines the red component to check
  60291. * @param g defines the green component to check
  60292. * @param b defines the blue component to check
  60293. * @returns true if the rgb values are equal to the given ones
  60294. */
  60295. equalsFloats(r: number, g: number, b: number): boolean;
  60296. /**
  60297. * Multiplies in place each rgb value by scale
  60298. * @param scale defines the scaling factor
  60299. * @returns the updated Color3
  60300. */
  60301. scale(scale: number): Color3;
  60302. /**
  60303. * Multiplies the rgb values by scale and stores the result into "result"
  60304. * @param scale defines the scaling factor
  60305. * @param result defines the Color3 object where to store the result
  60306. * @returns the unmodified current Color3
  60307. */
  60308. scaleToRef(scale: number, result: Color3): Color3;
  60309. /**
  60310. * Scale the current Color3 values by a factor and add the result to a given Color3
  60311. * @param scale defines the scale factor
  60312. * @param result defines color to store the result into
  60313. * @returns the unmodified current Color3
  60314. */
  60315. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60316. /**
  60317. * Clamps the rgb values by the min and max values and stores the result into "result"
  60318. * @param min defines minimum clamping value (default is 0)
  60319. * @param max defines maximum clamping value (default is 1)
  60320. * @param result defines color to store the result into
  60321. * @returns the original Color3
  60322. */
  60323. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60324. /**
  60325. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60326. * @param otherColor defines the second operand
  60327. * @returns the new Color3
  60328. */
  60329. add(otherColor: DeepImmutable<Color3>): Color3;
  60330. /**
  60331. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60332. * @param otherColor defines the second operand
  60333. * @param result defines Color3 object to store the result into
  60334. * @returns the unmodified current Color3
  60335. */
  60336. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60337. /**
  60338. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60339. * @param otherColor defines the second operand
  60340. * @returns the new Color3
  60341. */
  60342. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60343. /**
  60344. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60345. * @param otherColor defines the second operand
  60346. * @param result defines Color3 object to store the result into
  60347. * @returns the unmodified current Color3
  60348. */
  60349. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60350. /**
  60351. * Copy the current object
  60352. * @returns a new Color3 copied the current one
  60353. */
  60354. clone(): Color3;
  60355. /**
  60356. * Copies the rgb values from the source in the current Color3
  60357. * @param source defines the source Color3 object
  60358. * @returns the updated Color3 object
  60359. */
  60360. copyFrom(source: DeepImmutable<Color3>): Color3;
  60361. /**
  60362. * Updates the Color3 rgb values from the given floats
  60363. * @param r defines the red component to read from
  60364. * @param g defines the green component to read from
  60365. * @param b defines the blue component to read from
  60366. * @returns the current Color3 object
  60367. */
  60368. copyFromFloats(r: number, g: number, b: number): Color3;
  60369. /**
  60370. * Updates the Color3 rgb values from the given floats
  60371. * @param r defines the red component to read from
  60372. * @param g defines the green component to read from
  60373. * @param b defines the blue component to read from
  60374. * @returns the current Color3 object
  60375. */
  60376. set(r: number, g: number, b: number): Color3;
  60377. /**
  60378. * Compute the Color3 hexadecimal code as a string
  60379. * @returns a string containing the hexadecimal representation of the Color3 object
  60380. */
  60381. toHexString(): string;
  60382. /**
  60383. * Computes a new Color3 converted from the current one to linear space
  60384. * @returns a new Color3 object
  60385. */
  60386. toLinearSpace(): Color3;
  60387. /**
  60388. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60389. * @param convertedColor defines the Color3 object where to store the linear space version
  60390. * @returns the unmodified Color3
  60391. */
  60392. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60393. /**
  60394. * Computes a new Color3 converted from the current one to gamma space
  60395. * @returns a new Color3 object
  60396. */
  60397. toGammaSpace(): Color3;
  60398. /**
  60399. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60400. * @param convertedColor defines the Color3 object where to store the gamma space version
  60401. * @returns the unmodified Color3
  60402. */
  60403. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60404. private static _BlackReadOnly;
  60405. /**
  60406. * Creates a new Color3 from the string containing valid hexadecimal values
  60407. * @param hex defines a string containing valid hexadecimal values
  60408. * @returns a new Color3 object
  60409. */
  60410. static FromHexString(hex: string): Color3;
  60411. /**
  60412. * Creates a new Color3 from the starting index of the given array
  60413. * @param array defines the source array
  60414. * @param offset defines an offset in the source array
  60415. * @returns a new Color3 object
  60416. */
  60417. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60418. /**
  60419. * Creates a new Color3 from integer values (< 256)
  60420. * @param r defines the red component to read from (value between 0 and 255)
  60421. * @param g defines the green component to read from (value between 0 and 255)
  60422. * @param b defines the blue component to read from (value between 0 and 255)
  60423. * @returns a new Color3 object
  60424. */
  60425. static FromInts(r: number, g: number, b: number): Color3;
  60426. /**
  60427. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60428. * @param start defines the start Color3 value
  60429. * @param end defines the end Color3 value
  60430. * @param amount defines the gradient value between start and end
  60431. * @returns a new Color3 object
  60432. */
  60433. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60434. /**
  60435. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60436. * @param left defines the start value
  60437. * @param right defines the end value
  60438. * @param amount defines the gradient factor
  60439. * @param result defines the Color3 object where to store the result
  60440. */
  60441. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60442. /**
  60443. * Returns a Color3 value containing a red color
  60444. * @returns a new Color3 object
  60445. */
  60446. static Red(): Color3;
  60447. /**
  60448. * Returns a Color3 value containing a green color
  60449. * @returns a new Color3 object
  60450. */
  60451. static Green(): Color3;
  60452. /**
  60453. * Returns a Color3 value containing a blue color
  60454. * @returns a new Color3 object
  60455. */
  60456. static Blue(): Color3;
  60457. /**
  60458. * Returns a Color3 value containing a black color
  60459. * @returns a new Color3 object
  60460. */
  60461. static Black(): Color3;
  60462. /**
  60463. * Gets a Color3 value containing a black color that must not be updated
  60464. */
  60465. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60466. /**
  60467. * Returns a Color3 value containing a white color
  60468. * @returns a new Color3 object
  60469. */
  60470. static White(): Color3;
  60471. /**
  60472. * Returns a Color3 value containing a purple color
  60473. * @returns a new Color3 object
  60474. */
  60475. static Purple(): Color3;
  60476. /**
  60477. * Returns a Color3 value containing a magenta color
  60478. * @returns a new Color3 object
  60479. */
  60480. static Magenta(): Color3;
  60481. /**
  60482. * Returns a Color3 value containing a yellow color
  60483. * @returns a new Color3 object
  60484. */
  60485. static Yellow(): Color3;
  60486. /**
  60487. * Returns a Color3 value containing a gray color
  60488. * @returns a new Color3 object
  60489. */
  60490. static Gray(): Color3;
  60491. /**
  60492. * Returns a Color3 value containing a teal color
  60493. * @returns a new Color3 object
  60494. */
  60495. static Teal(): Color3;
  60496. /**
  60497. * Returns a Color3 value containing a random color
  60498. * @returns a new Color3 object
  60499. */
  60500. static Random(): Color3;
  60501. }
  60502. /**
  60503. * Class used to hold a RBGA color
  60504. */
  60505. export class Color4 {
  60506. /**
  60507. * Defines the red component (between 0 and 1, default is 0)
  60508. */
  60509. r: number;
  60510. /**
  60511. * Defines the green component (between 0 and 1, default is 0)
  60512. */
  60513. g: number;
  60514. /**
  60515. * Defines the blue component (between 0 and 1, default is 0)
  60516. */
  60517. b: number;
  60518. /**
  60519. * Defines the alpha component (between 0 and 1, default is 1)
  60520. */
  60521. a: number;
  60522. /**
  60523. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60524. * @param r defines the red component (between 0 and 1, default is 0)
  60525. * @param g defines the green component (between 0 and 1, default is 0)
  60526. * @param b defines the blue component (between 0 and 1, default is 0)
  60527. * @param a defines the alpha component (between 0 and 1, default is 1)
  60528. */
  60529. constructor(
  60530. /**
  60531. * Defines the red component (between 0 and 1, default is 0)
  60532. */
  60533. r?: number,
  60534. /**
  60535. * Defines the green component (between 0 and 1, default is 0)
  60536. */
  60537. g?: number,
  60538. /**
  60539. * Defines the blue component (between 0 and 1, default is 0)
  60540. */
  60541. b?: number,
  60542. /**
  60543. * Defines the alpha component (between 0 and 1, default is 1)
  60544. */
  60545. a?: number);
  60546. /**
  60547. * Adds in place the given Color4 values to the current Color4 object
  60548. * @param right defines the second operand
  60549. * @returns the current updated Color4 object
  60550. */
  60551. addInPlace(right: DeepImmutable<Color4>): Color4;
  60552. /**
  60553. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60554. * @returns the new array
  60555. */
  60556. asArray(): number[];
  60557. /**
  60558. * Stores from the starting index in the given array the Color4 successive values
  60559. * @param array defines the array where to store the r,g,b components
  60560. * @param index defines an optional index in the target array to define where to start storing values
  60561. * @returns the current Color4 object
  60562. */
  60563. toArray(array: number[], index?: number): Color4;
  60564. /**
  60565. * Determines equality between Color4 objects
  60566. * @param otherColor defines the second operand
  60567. * @returns true if the rgba values are equal to the given ones
  60568. */
  60569. equals(otherColor: DeepImmutable<Color4>): boolean;
  60570. /**
  60571. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60572. * @param right defines the second operand
  60573. * @returns a new Color4 object
  60574. */
  60575. add(right: DeepImmutable<Color4>): Color4;
  60576. /**
  60577. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60578. * @param right defines the second operand
  60579. * @returns a new Color4 object
  60580. */
  60581. subtract(right: DeepImmutable<Color4>): Color4;
  60582. /**
  60583. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60584. * @param right defines the second operand
  60585. * @param result defines the Color4 object where to store the result
  60586. * @returns the current Color4 object
  60587. */
  60588. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60589. /**
  60590. * Creates a new Color4 with the current Color4 values multiplied by scale
  60591. * @param scale defines the scaling factor to apply
  60592. * @returns a new Color4 object
  60593. */
  60594. scale(scale: number): Color4;
  60595. /**
  60596. * Multiplies the current Color4 values by scale and stores the result in "result"
  60597. * @param scale defines the scaling factor to apply
  60598. * @param result defines the Color4 object where to store the result
  60599. * @returns the current unmodified Color4
  60600. */
  60601. scaleToRef(scale: number, result: Color4): Color4;
  60602. /**
  60603. * Scale the current Color4 values by a factor and add the result to a given Color4
  60604. * @param scale defines the scale factor
  60605. * @param result defines the Color4 object where to store the result
  60606. * @returns the unmodified current Color4
  60607. */
  60608. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60609. /**
  60610. * Clamps the rgb values by the min and max values and stores the result into "result"
  60611. * @param min defines minimum clamping value (default is 0)
  60612. * @param max defines maximum clamping value (default is 1)
  60613. * @param result defines color to store the result into.
  60614. * @returns the cuurent Color4
  60615. */
  60616. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60617. /**
  60618. * Multipy an Color4 value by another and return a new Color4 object
  60619. * @param color defines the Color4 value to multiply by
  60620. * @returns a new Color4 object
  60621. */
  60622. multiply(color: Color4): Color4;
  60623. /**
  60624. * Multipy a Color4 value by another and push the result in a reference value
  60625. * @param color defines the Color4 value to multiply by
  60626. * @param result defines the Color4 to fill the result in
  60627. * @returns the result Color4
  60628. */
  60629. multiplyToRef(color: Color4, result: Color4): Color4;
  60630. /**
  60631. * Creates a string with the Color4 current values
  60632. * @returns the string representation of the Color4 object
  60633. */
  60634. toString(): string;
  60635. /**
  60636. * Returns the string "Color4"
  60637. * @returns "Color4"
  60638. */
  60639. getClassName(): string;
  60640. /**
  60641. * Compute the Color4 hash code
  60642. * @returns an unique number that can be used to hash Color4 objects
  60643. */
  60644. getHashCode(): number;
  60645. /**
  60646. * Creates a new Color4 copied from the current one
  60647. * @returns a new Color4 object
  60648. */
  60649. clone(): Color4;
  60650. /**
  60651. * Copies the given Color4 values into the current one
  60652. * @param source defines the source Color4 object
  60653. * @returns the current updated Color4 object
  60654. */
  60655. copyFrom(source: Color4): Color4;
  60656. /**
  60657. * Copies the given float values into the current one
  60658. * @param r defines the red component to read from
  60659. * @param g defines the green component to read from
  60660. * @param b defines the blue component to read from
  60661. * @param a defines the alpha component to read from
  60662. * @returns the current updated Color4 object
  60663. */
  60664. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60665. /**
  60666. * Copies the given float values into the current one
  60667. * @param r defines the red component to read from
  60668. * @param g defines the green component to read from
  60669. * @param b defines the blue component to read from
  60670. * @param a defines the alpha component to read from
  60671. * @returns the current updated Color4 object
  60672. */
  60673. set(r: number, g: number, b: number, a: number): Color4;
  60674. /**
  60675. * Compute the Color4 hexadecimal code as a string
  60676. * @returns a string containing the hexadecimal representation of the Color4 object
  60677. */
  60678. toHexString(): string;
  60679. /**
  60680. * Computes a new Color4 converted from the current one to linear space
  60681. * @returns a new Color4 object
  60682. */
  60683. toLinearSpace(): Color4;
  60684. /**
  60685. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60686. * @param convertedColor defines the Color4 object where to store the linear space version
  60687. * @returns the unmodified Color4
  60688. */
  60689. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60690. /**
  60691. * Computes a new Color4 converted from the current one to gamma space
  60692. * @returns a new Color4 object
  60693. */
  60694. toGammaSpace(): Color4;
  60695. /**
  60696. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60697. * @param convertedColor defines the Color4 object where to store the gamma space version
  60698. * @returns the unmodified Color4
  60699. */
  60700. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60701. /**
  60702. * Creates a new Color4 from the string containing valid hexadecimal values
  60703. * @param hex defines a string containing valid hexadecimal values
  60704. * @returns a new Color4 object
  60705. */
  60706. static FromHexString(hex: string): Color4;
  60707. /**
  60708. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60709. * @param left defines the start value
  60710. * @param right defines the end value
  60711. * @param amount defines the gradient factor
  60712. * @returns a new Color4 object
  60713. */
  60714. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60715. /**
  60716. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60717. * @param left defines the start value
  60718. * @param right defines the end value
  60719. * @param amount defines the gradient factor
  60720. * @param result defines the Color4 object where to store data
  60721. */
  60722. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60723. /**
  60724. * Creates a new Color4 from a Color3 and an alpha value
  60725. * @param color3 defines the source Color3 to read from
  60726. * @param alpha defines the alpha component (1.0 by default)
  60727. * @returns a new Color4 object
  60728. */
  60729. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60730. /**
  60731. * Creates a new Color4 from the starting index element of the given array
  60732. * @param array defines the source array to read from
  60733. * @param offset defines the offset in the source array
  60734. * @returns a new Color4 object
  60735. */
  60736. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60737. /**
  60738. * Creates a new Color3 from integer values (< 256)
  60739. * @param r defines the red component to read from (value between 0 and 255)
  60740. * @param g defines the green component to read from (value between 0 and 255)
  60741. * @param b defines the blue component to read from (value between 0 and 255)
  60742. * @param a defines the alpha component to read from (value between 0 and 255)
  60743. * @returns a new Color3 object
  60744. */
  60745. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60746. /**
  60747. * Check the content of a given array and convert it to an array containing RGBA data
  60748. * If the original array was already containing count * 4 values then it is returned directly
  60749. * @param colors defines the array to check
  60750. * @param count defines the number of RGBA data to expect
  60751. * @returns an array containing count * 4 values (RGBA)
  60752. */
  60753. static CheckColors4(colors: number[], count: number): number[];
  60754. }
  60755. /**
  60756. * Class representing a vector containing 2 coordinates
  60757. */
  60758. export class Vector2 {
  60759. /** defines the first coordinate */
  60760. x: number;
  60761. /** defines the second coordinate */
  60762. y: number;
  60763. /**
  60764. * Creates a new Vector2 from the given x and y coordinates
  60765. * @param x defines the first coordinate
  60766. * @param y defines the second coordinate
  60767. */
  60768. constructor(
  60769. /** defines the first coordinate */
  60770. x?: number,
  60771. /** defines the second coordinate */
  60772. y?: number);
  60773. /**
  60774. * Gets a string with the Vector2 coordinates
  60775. * @returns a string with the Vector2 coordinates
  60776. */
  60777. toString(): string;
  60778. /**
  60779. * Gets class name
  60780. * @returns the string "Vector2"
  60781. */
  60782. getClassName(): string;
  60783. /**
  60784. * Gets current vector hash code
  60785. * @returns the Vector2 hash code as a number
  60786. */
  60787. getHashCode(): number;
  60788. /**
  60789. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60790. * @param array defines the source array
  60791. * @param index defines the offset in source array
  60792. * @returns the current Vector2
  60793. */
  60794. toArray(array: FloatArray, index?: number): Vector2;
  60795. /**
  60796. * Copy the current vector to an array
  60797. * @returns a new array with 2 elements: the Vector2 coordinates.
  60798. */
  60799. asArray(): number[];
  60800. /**
  60801. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60802. * @param source defines the source Vector2
  60803. * @returns the current updated Vector2
  60804. */
  60805. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60806. /**
  60807. * Sets the Vector2 coordinates with the given floats
  60808. * @param x defines the first coordinate
  60809. * @param y defines the second coordinate
  60810. * @returns the current updated Vector2
  60811. */
  60812. copyFromFloats(x: number, y: number): Vector2;
  60813. /**
  60814. * Sets the Vector2 coordinates with the given floats
  60815. * @param x defines the first coordinate
  60816. * @param y defines the second coordinate
  60817. * @returns the current updated Vector2
  60818. */
  60819. set(x: number, y: number): Vector2;
  60820. /**
  60821. * Add another vector with the current one
  60822. * @param otherVector defines the other vector
  60823. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60824. */
  60825. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60826. /**
  60827. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60828. * @param otherVector defines the other vector
  60829. * @param result defines the target vector
  60830. * @returns the unmodified current Vector2
  60831. */
  60832. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60833. /**
  60834. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60835. * @param otherVector defines the other vector
  60836. * @returns the current updated Vector2
  60837. */
  60838. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60839. /**
  60840. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60841. * @param otherVector defines the other vector
  60842. * @returns a new Vector2
  60843. */
  60844. addVector3(otherVector: Vector3): Vector2;
  60845. /**
  60846. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60847. * @param otherVector defines the other vector
  60848. * @returns a new Vector2
  60849. */
  60850. subtract(otherVector: Vector2): Vector2;
  60851. /**
  60852. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60853. * @param otherVector defines the other vector
  60854. * @param result defines the target vector
  60855. * @returns the unmodified current Vector2
  60856. */
  60857. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60858. /**
  60859. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60860. * @param otherVector defines the other vector
  60861. * @returns the current updated Vector2
  60862. */
  60863. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60864. /**
  60865. * Multiplies in place the current Vector2 coordinates by the given ones
  60866. * @param otherVector defines the other vector
  60867. * @returns the current updated Vector2
  60868. */
  60869. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60870. /**
  60871. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60872. * @param otherVector defines the other vector
  60873. * @returns a new Vector2
  60874. */
  60875. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60876. /**
  60877. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60878. * @param otherVector defines the other vector
  60879. * @param result defines the target vector
  60880. * @returns the unmodified current Vector2
  60881. */
  60882. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60883. /**
  60884. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60885. * @param x defines the first coordinate
  60886. * @param y defines the second coordinate
  60887. * @returns a new Vector2
  60888. */
  60889. multiplyByFloats(x: number, y: number): Vector2;
  60890. /**
  60891. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60892. * @param otherVector defines the other vector
  60893. * @returns a new Vector2
  60894. */
  60895. divide(otherVector: Vector2): Vector2;
  60896. /**
  60897. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60898. * @param otherVector defines the other vector
  60899. * @param result defines the target vector
  60900. * @returns the unmodified current Vector2
  60901. */
  60902. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60903. /**
  60904. * Divides the current Vector2 coordinates by the given ones
  60905. * @param otherVector defines the other vector
  60906. * @returns the current updated Vector2
  60907. */
  60908. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60909. /**
  60910. * Gets a new Vector2 with current Vector2 negated coordinates
  60911. * @returns a new Vector2
  60912. */
  60913. negate(): Vector2;
  60914. /**
  60915. * Multiply the Vector2 coordinates by scale
  60916. * @param scale defines the scaling factor
  60917. * @returns the current updated Vector2
  60918. */
  60919. scaleInPlace(scale: number): Vector2;
  60920. /**
  60921. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60922. * @param scale defines the scaling factor
  60923. * @returns a new Vector2
  60924. */
  60925. scale(scale: number): Vector2;
  60926. /**
  60927. * Scale the current Vector2 values by a factor to a given Vector2
  60928. * @param scale defines the scale factor
  60929. * @param result defines the Vector2 object where to store the result
  60930. * @returns the unmodified current Vector2
  60931. */
  60932. scaleToRef(scale: number, result: Vector2): Vector2;
  60933. /**
  60934. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60935. * @param scale defines the scale factor
  60936. * @param result defines the Vector2 object where to store the result
  60937. * @returns the unmodified current Vector2
  60938. */
  60939. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60940. /**
  60941. * Gets a boolean if two vectors are equals
  60942. * @param otherVector defines the other vector
  60943. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60944. */
  60945. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60946. /**
  60947. * Gets a boolean if two vectors are equals (using an epsilon value)
  60948. * @param otherVector defines the other vector
  60949. * @param epsilon defines the minimal distance to consider equality
  60950. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60951. */
  60952. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60953. /**
  60954. * Gets a new Vector2 from current Vector2 floored values
  60955. * @returns a new Vector2
  60956. */
  60957. floor(): Vector2;
  60958. /**
  60959. * Gets a new Vector2 from current Vector2 floored values
  60960. * @returns a new Vector2
  60961. */
  60962. fract(): Vector2;
  60963. /**
  60964. * Gets the length of the vector
  60965. * @returns the vector length (float)
  60966. */
  60967. length(): number;
  60968. /**
  60969. * Gets the vector squared length
  60970. * @returns the vector squared length (float)
  60971. */
  60972. lengthSquared(): number;
  60973. /**
  60974. * Normalize the vector
  60975. * @returns the current updated Vector2
  60976. */
  60977. normalize(): Vector2;
  60978. /**
  60979. * Gets a new Vector2 copied from the Vector2
  60980. * @returns a new Vector2
  60981. */
  60982. clone(): Vector2;
  60983. /**
  60984. * Gets a new Vector2(0, 0)
  60985. * @returns a new Vector2
  60986. */
  60987. static Zero(): Vector2;
  60988. /**
  60989. * Gets a new Vector2(1, 1)
  60990. * @returns a new Vector2
  60991. */
  60992. static One(): Vector2;
  60993. /**
  60994. * Gets a new Vector2 set from the given index element of the given array
  60995. * @param array defines the data source
  60996. * @param offset defines the offset in the data source
  60997. * @returns a new Vector2
  60998. */
  60999. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  61000. /**
  61001. * Sets "result" from the given index element of the given array
  61002. * @param array defines the data source
  61003. * @param offset defines the offset in the data source
  61004. * @param result defines the target vector
  61005. */
  61006. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  61007. /**
  61008. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  61009. * @param value1 defines 1st point of control
  61010. * @param value2 defines 2nd point of control
  61011. * @param value3 defines 3rd point of control
  61012. * @param value4 defines 4th point of control
  61013. * @param amount defines the interpolation factor
  61014. * @returns a new Vector2
  61015. */
  61016. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  61017. /**
  61018. * 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".
  61019. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  61020. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  61021. * @param value defines the value to clamp
  61022. * @param min defines the lower limit
  61023. * @param max defines the upper limit
  61024. * @returns a new Vector2
  61025. */
  61026. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  61027. /**
  61028. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  61029. * @param value1 defines the 1st control point
  61030. * @param tangent1 defines the outgoing tangent
  61031. * @param value2 defines the 2nd control point
  61032. * @param tangent2 defines the incoming tangent
  61033. * @param amount defines the interpolation factor
  61034. * @returns a new Vector2
  61035. */
  61036. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  61037. /**
  61038. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  61039. * @param start defines the start vector
  61040. * @param end defines the end vector
  61041. * @param amount defines the interpolation factor
  61042. * @returns a new Vector2
  61043. */
  61044. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  61045. /**
  61046. * Gets the dot product of the vector "left" and the vector "right"
  61047. * @param left defines first vector
  61048. * @param right defines second vector
  61049. * @returns the dot product (float)
  61050. */
  61051. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  61052. /**
  61053. * Returns a new Vector2 equal to the normalized given vector
  61054. * @param vector defines the vector to normalize
  61055. * @returns a new Vector2
  61056. */
  61057. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  61058. /**
  61059. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  61060. * @param left defines 1st vector
  61061. * @param right defines 2nd vector
  61062. * @returns a new Vector2
  61063. */
  61064. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61065. /**
  61066. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  61067. * @param left defines 1st vector
  61068. * @param right defines 2nd vector
  61069. * @returns a new Vector2
  61070. */
  61071. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61072. /**
  61073. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  61074. * @param vector defines the vector to transform
  61075. * @param transformation defines the matrix to apply
  61076. * @returns a new Vector2
  61077. */
  61078. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  61079. /**
  61080. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  61081. * @param vector defines the vector to transform
  61082. * @param transformation defines the matrix to apply
  61083. * @param result defines the target vector
  61084. */
  61085. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  61086. /**
  61087. * Determines if a given vector is included in a triangle
  61088. * @param p defines the vector to test
  61089. * @param p0 defines 1st triangle point
  61090. * @param p1 defines 2nd triangle point
  61091. * @param p2 defines 3rd triangle point
  61092. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  61093. */
  61094. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  61095. /**
  61096. * Gets the distance between the vectors "value1" and "value2"
  61097. * @param value1 defines first vector
  61098. * @param value2 defines second vector
  61099. * @returns the distance between vectors
  61100. */
  61101. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61102. /**
  61103. * Returns the squared distance between the vectors "value1" and "value2"
  61104. * @param value1 defines first vector
  61105. * @param value2 defines second vector
  61106. * @returns the squared distance between vectors
  61107. */
  61108. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61109. /**
  61110. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  61111. * @param value1 defines first vector
  61112. * @param value2 defines second vector
  61113. * @returns a new Vector2
  61114. */
  61115. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  61116. /**
  61117. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  61118. * @param p defines the middle point
  61119. * @param segA defines one point of the segment
  61120. * @param segB defines the other point of the segment
  61121. * @returns the shortest distance
  61122. */
  61123. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  61124. }
  61125. /**
  61126. * Classed used to store (x,y,z) vector representation
  61127. * A Vector3 is the main object used in 3D geometry
  61128. * It can represent etiher the coordinates of a point the space, either a direction
  61129. * Reminder: js uses a left handed forward facing system
  61130. */
  61131. export class Vector3 {
  61132. /**
  61133. * Defines the first coordinates (on X axis)
  61134. */
  61135. x: number;
  61136. /**
  61137. * Defines the second coordinates (on Y axis)
  61138. */
  61139. y: number;
  61140. /**
  61141. * Defines the third coordinates (on Z axis)
  61142. */
  61143. z: number;
  61144. private static _UpReadOnly;
  61145. /**
  61146. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  61147. * @param x defines the first coordinates (on X axis)
  61148. * @param y defines the second coordinates (on Y axis)
  61149. * @param z defines the third coordinates (on Z axis)
  61150. */
  61151. constructor(
  61152. /**
  61153. * Defines the first coordinates (on X axis)
  61154. */
  61155. x?: number,
  61156. /**
  61157. * Defines the second coordinates (on Y axis)
  61158. */
  61159. y?: number,
  61160. /**
  61161. * Defines the third coordinates (on Z axis)
  61162. */
  61163. z?: number);
  61164. /**
  61165. * Creates a string representation of the Vector3
  61166. * @returns a string with the Vector3 coordinates.
  61167. */
  61168. toString(): string;
  61169. /**
  61170. * Gets the class name
  61171. * @returns the string "Vector3"
  61172. */
  61173. getClassName(): string;
  61174. /**
  61175. * Creates the Vector3 hash code
  61176. * @returns a number which tends to be unique between Vector3 instances
  61177. */
  61178. getHashCode(): number;
  61179. /**
  61180. * Creates an array containing three elements : the coordinates of the Vector3
  61181. * @returns a new array of numbers
  61182. */
  61183. asArray(): number[];
  61184. /**
  61185. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  61186. * @param array defines the destination array
  61187. * @param index defines the offset in the destination array
  61188. * @returns the current Vector3
  61189. */
  61190. toArray(array: FloatArray, index?: number): Vector3;
  61191. /**
  61192. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  61193. * @returns a new Quaternion object, computed from the Vector3 coordinates
  61194. */
  61195. toQuaternion(): Quaternion;
  61196. /**
  61197. * Adds the given vector to the current Vector3
  61198. * @param otherVector defines the second operand
  61199. * @returns the current updated Vector3
  61200. */
  61201. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61202. /**
  61203. * Adds the given coordinates to the current Vector3
  61204. * @param x defines the x coordinate of the operand
  61205. * @param y defines the y coordinate of the operand
  61206. * @param z defines the z coordinate of the operand
  61207. * @returns the current updated Vector3
  61208. */
  61209. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61210. /**
  61211. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61212. * @param otherVector defines the second operand
  61213. * @returns the resulting Vector3
  61214. */
  61215. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61216. /**
  61217. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61218. * @param otherVector defines the second operand
  61219. * @param result defines the Vector3 object where to store the result
  61220. * @returns the current Vector3
  61221. */
  61222. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61223. /**
  61224. * Subtract the given vector from the current Vector3
  61225. * @param otherVector defines the second operand
  61226. * @returns the current updated Vector3
  61227. */
  61228. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61229. /**
  61230. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61231. * @param otherVector defines the second operand
  61232. * @returns the resulting Vector3
  61233. */
  61234. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61235. /**
  61236. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61237. * @param otherVector defines the second operand
  61238. * @param result defines the Vector3 object where to store the result
  61239. * @returns the current Vector3
  61240. */
  61241. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61242. /**
  61243. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61244. * @param x defines the x coordinate of the operand
  61245. * @param y defines the y coordinate of the operand
  61246. * @param z defines the z coordinate of the operand
  61247. * @returns the resulting Vector3
  61248. */
  61249. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61250. /**
  61251. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61252. * @param x defines the x coordinate of the operand
  61253. * @param y defines the y coordinate of the operand
  61254. * @param z defines the z coordinate of the operand
  61255. * @param result defines the Vector3 object where to store the result
  61256. * @returns the current Vector3
  61257. */
  61258. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61259. /**
  61260. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61261. * @returns a new Vector3
  61262. */
  61263. negate(): Vector3;
  61264. /**
  61265. * Multiplies the Vector3 coordinates by the float "scale"
  61266. * @param scale defines the multiplier factor
  61267. * @returns the current updated Vector3
  61268. */
  61269. scaleInPlace(scale: number): Vector3;
  61270. /**
  61271. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61272. * @param scale defines the multiplier factor
  61273. * @returns a new Vector3
  61274. */
  61275. scale(scale: number): Vector3;
  61276. /**
  61277. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61278. * @param scale defines the multiplier factor
  61279. * @param result defines the Vector3 object where to store the result
  61280. * @returns the current Vector3
  61281. */
  61282. scaleToRef(scale: number, result: Vector3): Vector3;
  61283. /**
  61284. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61285. * @param scale defines the scale factor
  61286. * @param result defines the Vector3 object where to store the result
  61287. * @returns the unmodified current Vector3
  61288. */
  61289. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61290. /**
  61291. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61292. * @param otherVector defines the second operand
  61293. * @returns true if both vectors are equals
  61294. */
  61295. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61296. /**
  61297. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61298. * @param otherVector defines the second operand
  61299. * @param epsilon defines the minimal distance to define values as equals
  61300. * @returns true if both vectors are distant less than epsilon
  61301. */
  61302. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61303. /**
  61304. * Returns true if the current Vector3 coordinates equals the given floats
  61305. * @param x defines the x coordinate of the operand
  61306. * @param y defines the y coordinate of the operand
  61307. * @param z defines the z coordinate of the operand
  61308. * @returns true if both vectors are equals
  61309. */
  61310. equalsToFloats(x: number, y: number, z: number): boolean;
  61311. /**
  61312. * Multiplies the current Vector3 coordinates by the given ones
  61313. * @param otherVector defines the second operand
  61314. * @returns the current updated Vector3
  61315. */
  61316. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61317. /**
  61318. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61319. * @param otherVector defines the second operand
  61320. * @returns the new Vector3
  61321. */
  61322. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61323. /**
  61324. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61325. * @param otherVector defines the second operand
  61326. * @param result defines the Vector3 object where to store the result
  61327. * @returns the current Vector3
  61328. */
  61329. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61330. /**
  61331. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61332. * @param x defines the x coordinate of the operand
  61333. * @param y defines the y coordinate of the operand
  61334. * @param z defines the z coordinate of the operand
  61335. * @returns the new Vector3
  61336. */
  61337. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61338. /**
  61339. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61340. * @param otherVector defines the second operand
  61341. * @returns the new Vector3
  61342. */
  61343. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61344. /**
  61345. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61346. * @param otherVector defines the second operand
  61347. * @param result defines the Vector3 object where to store the result
  61348. * @returns the current Vector3
  61349. */
  61350. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61351. /**
  61352. * Divides the current Vector3 coordinates by the given ones.
  61353. * @param otherVector defines the second operand
  61354. * @returns the current updated Vector3
  61355. */
  61356. divideInPlace(otherVector: Vector3): Vector3;
  61357. /**
  61358. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61359. * @param other defines the second operand
  61360. * @returns the current updated Vector3
  61361. */
  61362. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61363. /**
  61364. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61365. * @param other defines the second operand
  61366. * @returns the current updated Vector3
  61367. */
  61368. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61369. /**
  61370. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61371. * @param x defines the x coordinate of the operand
  61372. * @param y defines the y coordinate of the operand
  61373. * @param z defines the z coordinate of the operand
  61374. * @returns the current updated Vector3
  61375. */
  61376. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61377. /**
  61378. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61379. * @param x defines the x coordinate of the operand
  61380. * @param y defines the y coordinate of the operand
  61381. * @param z defines the z coordinate of the operand
  61382. * @returns the current updated Vector3
  61383. */
  61384. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61385. /**
  61386. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61387. * Check if is non uniform within a certain amount of decimal places to account for this
  61388. * @param epsilon the amount the values can differ
  61389. * @returns if the the vector is non uniform to a certain number of decimal places
  61390. */
  61391. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61392. /**
  61393. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61394. */
  61395. readonly isNonUniform: boolean;
  61396. /**
  61397. * Gets a new Vector3 from current Vector3 floored values
  61398. * @returns a new Vector3
  61399. */
  61400. floor(): Vector3;
  61401. /**
  61402. * Gets a new Vector3 from current Vector3 floored values
  61403. * @returns a new Vector3
  61404. */
  61405. fract(): Vector3;
  61406. /**
  61407. * Gets the length of the Vector3
  61408. * @returns the length of the Vecto3
  61409. */
  61410. length(): number;
  61411. /**
  61412. * Gets the squared length of the Vector3
  61413. * @returns squared length of the Vector3
  61414. */
  61415. lengthSquared(): number;
  61416. /**
  61417. * Normalize the current Vector3.
  61418. * Please note that this is an in place operation.
  61419. * @returns the current updated Vector3
  61420. */
  61421. normalize(): Vector3;
  61422. /**
  61423. * Reorders the x y z properties of the vector in place
  61424. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61425. * @returns the current updated vector
  61426. */
  61427. reorderInPlace(order: string): this;
  61428. /**
  61429. * Rotates the vector around 0,0,0 by a quaternion
  61430. * @param quaternion the rotation quaternion
  61431. * @param result vector to store the result
  61432. * @returns the resulting vector
  61433. */
  61434. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61435. /**
  61436. * Rotates a vector around a given point
  61437. * @param quaternion the rotation quaternion
  61438. * @param point the point to rotate around
  61439. * @param result vector to store the result
  61440. * @returns the resulting vector
  61441. */
  61442. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61443. /**
  61444. * Normalize the current Vector3 with the given input length.
  61445. * Please note that this is an in place operation.
  61446. * @param len the length of the vector
  61447. * @returns the current updated Vector3
  61448. */
  61449. normalizeFromLength(len: number): Vector3;
  61450. /**
  61451. * Normalize the current Vector3 to a new vector
  61452. * @returns the new Vector3
  61453. */
  61454. normalizeToNew(): Vector3;
  61455. /**
  61456. * Normalize the current Vector3 to the reference
  61457. * @param reference define the Vector3 to update
  61458. * @returns the updated Vector3
  61459. */
  61460. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61461. /**
  61462. * Creates a new Vector3 copied from the current Vector3
  61463. * @returns the new Vector3
  61464. */
  61465. clone(): Vector3;
  61466. /**
  61467. * Copies the given vector coordinates to the current Vector3 ones
  61468. * @param source defines the source Vector3
  61469. * @returns the current updated Vector3
  61470. */
  61471. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61472. /**
  61473. * Copies the given floats to the current Vector3 coordinates
  61474. * @param x defines the x coordinate of the operand
  61475. * @param y defines the y coordinate of the operand
  61476. * @param z defines the z coordinate of the operand
  61477. * @returns the current updated Vector3
  61478. */
  61479. copyFromFloats(x: number, y: number, z: number): Vector3;
  61480. /**
  61481. * Copies the given floats to the current Vector3 coordinates
  61482. * @param x defines the x coordinate of the operand
  61483. * @param y defines the y coordinate of the operand
  61484. * @param z defines the z coordinate of the operand
  61485. * @returns the current updated Vector3
  61486. */
  61487. set(x: number, y: number, z: number): Vector3;
  61488. /**
  61489. * Copies the given float to the current Vector3 coordinates
  61490. * @param v defines the x, y and z coordinates of the operand
  61491. * @returns the current updated Vector3
  61492. */
  61493. setAll(v: number): Vector3;
  61494. /**
  61495. * Get the clip factor between two vectors
  61496. * @param vector0 defines the first operand
  61497. * @param vector1 defines the second operand
  61498. * @param axis defines the axis to use
  61499. * @param size defines the size along the axis
  61500. * @returns the clip factor
  61501. */
  61502. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61503. /**
  61504. * Get angle between two vectors
  61505. * @param vector0 angle between vector0 and vector1
  61506. * @param vector1 angle between vector0 and vector1
  61507. * @param normal direction of the normal
  61508. * @return the angle between vector0 and vector1
  61509. */
  61510. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61511. /**
  61512. * Returns a new Vector3 set from the index "offset" of the given array
  61513. * @param array defines the source array
  61514. * @param offset defines the offset in the source array
  61515. * @returns the new Vector3
  61516. */
  61517. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61518. /**
  61519. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61520. * This function is deprecated. Use FromArray instead
  61521. * @param array defines the source array
  61522. * @param offset defines the offset in the source array
  61523. * @returns the new Vector3
  61524. */
  61525. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61526. /**
  61527. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61528. * @param array defines the source array
  61529. * @param offset defines the offset in the source array
  61530. * @param result defines the Vector3 where to store the result
  61531. */
  61532. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61533. /**
  61534. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61535. * This function is deprecated. Use FromArrayToRef instead.
  61536. * @param array defines the source array
  61537. * @param offset defines the offset in the source array
  61538. * @param result defines the Vector3 where to store the result
  61539. */
  61540. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61541. /**
  61542. * Sets the given vector "result" with the given floats.
  61543. * @param x defines the x coordinate of the source
  61544. * @param y defines the y coordinate of the source
  61545. * @param z defines the z coordinate of the source
  61546. * @param result defines the Vector3 where to store the result
  61547. */
  61548. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61549. /**
  61550. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61551. * @returns a new empty Vector3
  61552. */
  61553. static Zero(): Vector3;
  61554. /**
  61555. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61556. * @returns a new unit Vector3
  61557. */
  61558. static One(): Vector3;
  61559. /**
  61560. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61561. * @returns a new up Vector3
  61562. */
  61563. static Up(): Vector3;
  61564. /**
  61565. * Gets a up Vector3 that must not be updated
  61566. */
  61567. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61568. /**
  61569. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61570. * @returns a new down Vector3
  61571. */
  61572. static Down(): Vector3;
  61573. /**
  61574. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61575. * @returns a new forward Vector3
  61576. */
  61577. static Forward(): Vector3;
  61578. /**
  61579. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61580. * @returns a new forward Vector3
  61581. */
  61582. static Backward(): Vector3;
  61583. /**
  61584. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61585. * @returns a new right Vector3
  61586. */
  61587. static Right(): Vector3;
  61588. /**
  61589. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61590. * @returns a new left Vector3
  61591. */
  61592. static Left(): Vector3;
  61593. /**
  61594. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61595. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61596. * @param vector defines the Vector3 to transform
  61597. * @param transformation defines the transformation matrix
  61598. * @returns the transformed Vector3
  61599. */
  61600. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61601. /**
  61602. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61603. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61604. * @param vector defines the Vector3 to transform
  61605. * @param transformation defines the transformation matrix
  61606. * @param result defines the Vector3 where to store the result
  61607. */
  61608. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61609. /**
  61610. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61611. * This method computes tranformed coordinates only, not transformed direction vectors
  61612. * @param x define the x coordinate of the source vector
  61613. * @param y define the y coordinate of the source vector
  61614. * @param z define the z coordinate of the source vector
  61615. * @param transformation defines the transformation matrix
  61616. * @param result defines the Vector3 where to store the result
  61617. */
  61618. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61619. /**
  61620. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61621. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61622. * @param vector defines the Vector3 to transform
  61623. * @param transformation defines the transformation matrix
  61624. * @returns the new Vector3
  61625. */
  61626. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61627. /**
  61628. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61629. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61630. * @param vector defines the Vector3 to transform
  61631. * @param transformation defines the transformation matrix
  61632. * @param result defines the Vector3 where to store the result
  61633. */
  61634. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61635. /**
  61636. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61637. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61638. * @param x define the x coordinate of the source vector
  61639. * @param y define the y coordinate of the source vector
  61640. * @param z define the z coordinate of the source vector
  61641. * @param transformation defines the transformation matrix
  61642. * @param result defines the Vector3 where to store the result
  61643. */
  61644. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61645. /**
  61646. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61647. * @param value1 defines the first control point
  61648. * @param value2 defines the second control point
  61649. * @param value3 defines the third control point
  61650. * @param value4 defines the fourth control point
  61651. * @param amount defines the amount on the spline to use
  61652. * @returns the new Vector3
  61653. */
  61654. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61655. /**
  61656. * 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"
  61657. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61658. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61659. * @param value defines the current value
  61660. * @param min defines the lower range value
  61661. * @param max defines the upper range value
  61662. * @returns the new Vector3
  61663. */
  61664. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61665. /**
  61666. * 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"
  61667. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61668. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61669. * @param value defines the current value
  61670. * @param min defines the lower range value
  61671. * @param max defines the upper range value
  61672. * @param result defines the Vector3 where to store the result
  61673. */
  61674. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61675. /**
  61676. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61677. * @param value1 defines the first control point
  61678. * @param tangent1 defines the first tangent vector
  61679. * @param value2 defines the second control point
  61680. * @param tangent2 defines the second tangent vector
  61681. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61682. * @returns the new Vector3
  61683. */
  61684. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61685. /**
  61686. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61687. * @param start defines the start value
  61688. * @param end defines the end value
  61689. * @param amount max defines amount between both (between 0 and 1)
  61690. * @returns the new Vector3
  61691. */
  61692. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61693. /**
  61694. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61695. * @param start defines the start value
  61696. * @param end defines the end value
  61697. * @param amount max defines amount between both (between 0 and 1)
  61698. * @param result defines the Vector3 where to store the result
  61699. */
  61700. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61701. /**
  61702. * Returns the dot product (float) between the vectors "left" and "right"
  61703. * @param left defines the left operand
  61704. * @param right defines the right operand
  61705. * @returns the dot product
  61706. */
  61707. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61708. /**
  61709. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61710. * The cross product is then orthogonal to both "left" and "right"
  61711. * @param left defines the left operand
  61712. * @param right defines the right operand
  61713. * @returns the cross product
  61714. */
  61715. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61716. /**
  61717. * Sets the given vector "result" with the cross product of "left" and "right"
  61718. * The cross product is then orthogonal to both "left" and "right"
  61719. * @param left defines the left operand
  61720. * @param right defines the right operand
  61721. * @param result defines the Vector3 where to store the result
  61722. */
  61723. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61724. /**
  61725. * Returns a new Vector3 as the normalization of the given vector
  61726. * @param vector defines the Vector3 to normalize
  61727. * @returns the new Vector3
  61728. */
  61729. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61730. /**
  61731. * Sets the given vector "result" with the normalization of the given first vector
  61732. * @param vector defines the Vector3 to normalize
  61733. * @param result defines the Vector3 where to store the result
  61734. */
  61735. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61736. /**
  61737. * Project a Vector3 onto screen space
  61738. * @param vector defines the Vector3 to project
  61739. * @param world defines the world matrix to use
  61740. * @param transform defines the transform (view x projection) matrix to use
  61741. * @param viewport defines the screen viewport to use
  61742. * @returns the new Vector3
  61743. */
  61744. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61745. /** @hidden */
  61746. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61747. /**
  61748. * Unproject from screen space to object space
  61749. * @param source defines the screen space Vector3 to use
  61750. * @param viewportWidth defines the current width of the viewport
  61751. * @param viewportHeight defines the current height of the viewport
  61752. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61753. * @param transform defines the transform (view x projection) matrix to use
  61754. * @returns the new Vector3
  61755. */
  61756. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61757. /**
  61758. * Unproject from screen space to object space
  61759. * @param source defines the screen space Vector3 to use
  61760. * @param viewportWidth defines the current width of the viewport
  61761. * @param viewportHeight defines the current height of the viewport
  61762. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61763. * @param view defines the view matrix to use
  61764. * @param projection defines the projection matrix to use
  61765. * @returns the new Vector3
  61766. */
  61767. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61768. /**
  61769. * Unproject from screen space to object space
  61770. * @param source defines the screen space Vector3 to use
  61771. * @param viewportWidth defines the current width of the viewport
  61772. * @param viewportHeight defines the current height of the viewport
  61773. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61774. * @param view defines the view matrix to use
  61775. * @param projection defines the projection matrix to use
  61776. * @param result defines the Vector3 where to store the result
  61777. */
  61778. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61779. /**
  61780. * Unproject from screen space to object space
  61781. * @param sourceX defines the screen space x coordinate to use
  61782. * @param sourceY defines the screen space y coordinate to use
  61783. * @param sourceZ defines the screen space z coordinate to use
  61784. * @param viewportWidth defines the current width of the viewport
  61785. * @param viewportHeight defines the current height of the viewport
  61786. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61787. * @param view defines the view matrix to use
  61788. * @param projection defines the projection matrix to use
  61789. * @param result defines the Vector3 where to store the result
  61790. */
  61791. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61792. /**
  61793. * Gets the minimal coordinate values between two Vector3
  61794. * @param left defines the first operand
  61795. * @param right defines the second operand
  61796. * @returns the new Vector3
  61797. */
  61798. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61799. /**
  61800. * Gets the maximal coordinate values between two Vector3
  61801. * @param left defines the first operand
  61802. * @param right defines the second operand
  61803. * @returns the new Vector3
  61804. */
  61805. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61806. /**
  61807. * Returns the distance between the vectors "value1" and "value2"
  61808. * @param value1 defines the first operand
  61809. * @param value2 defines the second operand
  61810. * @returns the distance
  61811. */
  61812. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61813. /**
  61814. * Returns the squared distance between the vectors "value1" and "value2"
  61815. * @param value1 defines the first operand
  61816. * @param value2 defines the second operand
  61817. * @returns the squared distance
  61818. */
  61819. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61820. /**
  61821. * Returns a new Vector3 located at the center between "value1" and "value2"
  61822. * @param value1 defines the first operand
  61823. * @param value2 defines the second operand
  61824. * @returns the new Vector3
  61825. */
  61826. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61827. /**
  61828. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61829. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61830. * to something in order to rotate it from its local system to the given target system
  61831. * Note: axis1, axis2 and axis3 are normalized during this operation
  61832. * @param axis1 defines the first axis
  61833. * @param axis2 defines the second axis
  61834. * @param axis3 defines the third axis
  61835. * @returns a new Vector3
  61836. */
  61837. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61838. /**
  61839. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61840. * @param axis1 defines the first axis
  61841. * @param axis2 defines the second axis
  61842. * @param axis3 defines the third axis
  61843. * @param ref defines the Vector3 where to store the result
  61844. */
  61845. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61846. }
  61847. /**
  61848. * Vector4 class created for EulerAngle class conversion to Quaternion
  61849. */
  61850. export class Vector4 {
  61851. /** x value of the vector */
  61852. x: number;
  61853. /** y value of the vector */
  61854. y: number;
  61855. /** z value of the vector */
  61856. z: number;
  61857. /** w value of the vector */
  61858. w: number;
  61859. /**
  61860. * Creates a Vector4 object from the given floats.
  61861. * @param x x value of the vector
  61862. * @param y y value of the vector
  61863. * @param z z value of the vector
  61864. * @param w w value of the vector
  61865. */
  61866. constructor(
  61867. /** x value of the vector */
  61868. x: number,
  61869. /** y value of the vector */
  61870. y: number,
  61871. /** z value of the vector */
  61872. z: number,
  61873. /** w value of the vector */
  61874. w: number);
  61875. /**
  61876. * Returns the string with the Vector4 coordinates.
  61877. * @returns a string containing all the vector values
  61878. */
  61879. toString(): string;
  61880. /**
  61881. * Returns the string "Vector4".
  61882. * @returns "Vector4"
  61883. */
  61884. getClassName(): string;
  61885. /**
  61886. * Returns the Vector4 hash code.
  61887. * @returns a unique hash code
  61888. */
  61889. getHashCode(): number;
  61890. /**
  61891. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61892. * @returns the resulting array
  61893. */
  61894. asArray(): number[];
  61895. /**
  61896. * Populates the given array from the given index with the Vector4 coordinates.
  61897. * @param array array to populate
  61898. * @param index index of the array to start at (default: 0)
  61899. * @returns the Vector4.
  61900. */
  61901. toArray(array: FloatArray, index?: number): Vector4;
  61902. /**
  61903. * Adds the given vector to the current Vector4.
  61904. * @param otherVector the vector to add
  61905. * @returns the updated Vector4.
  61906. */
  61907. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61908. /**
  61909. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61910. * @param otherVector the vector to add
  61911. * @returns the resulting vector
  61912. */
  61913. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61914. /**
  61915. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61916. * @param otherVector the vector to add
  61917. * @param result the vector to store the result
  61918. * @returns the current Vector4.
  61919. */
  61920. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61921. /**
  61922. * Subtract in place the given vector from the current Vector4.
  61923. * @param otherVector the vector to subtract
  61924. * @returns the updated Vector4.
  61925. */
  61926. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61927. /**
  61928. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61929. * @param otherVector the vector to add
  61930. * @returns the new vector with the result
  61931. */
  61932. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61933. /**
  61934. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61935. * @param otherVector the vector to subtract
  61936. * @param result the vector to store the result
  61937. * @returns the current Vector4.
  61938. */
  61939. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61940. /**
  61941. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61942. */
  61943. /**
  61944. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61945. * @param x value to subtract
  61946. * @param y value to subtract
  61947. * @param z value to subtract
  61948. * @param w value to subtract
  61949. * @returns new vector containing the result
  61950. */
  61951. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61952. /**
  61953. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61954. * @param x value to subtract
  61955. * @param y value to subtract
  61956. * @param z value to subtract
  61957. * @param w value to subtract
  61958. * @param result the vector to store the result in
  61959. * @returns the current Vector4.
  61960. */
  61961. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61962. /**
  61963. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61964. * @returns a new vector with the negated values
  61965. */
  61966. negate(): Vector4;
  61967. /**
  61968. * Multiplies the current Vector4 coordinates by scale (float).
  61969. * @param scale the number to scale with
  61970. * @returns the updated Vector4.
  61971. */
  61972. scaleInPlace(scale: number): Vector4;
  61973. /**
  61974. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61975. * @param scale the number to scale with
  61976. * @returns a new vector with the result
  61977. */
  61978. scale(scale: number): Vector4;
  61979. /**
  61980. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61981. * @param scale the number to scale with
  61982. * @param result a vector to store the result in
  61983. * @returns the current Vector4.
  61984. */
  61985. scaleToRef(scale: number, result: Vector4): Vector4;
  61986. /**
  61987. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61988. * @param scale defines the scale factor
  61989. * @param result defines the Vector4 object where to store the result
  61990. * @returns the unmodified current Vector4
  61991. */
  61992. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61993. /**
  61994. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61995. * @param otherVector the vector to compare against
  61996. * @returns true if they are equal
  61997. */
  61998. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61999. /**
  62000. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  62001. * @param otherVector vector to compare against
  62002. * @param epsilon (Default: very small number)
  62003. * @returns true if they are equal
  62004. */
  62005. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  62006. /**
  62007. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  62008. * @param x x value to compare against
  62009. * @param y y value to compare against
  62010. * @param z z value to compare against
  62011. * @param w w value to compare against
  62012. * @returns true if equal
  62013. */
  62014. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  62015. /**
  62016. * Multiplies in place the current Vector4 by the given one.
  62017. * @param otherVector vector to multiple with
  62018. * @returns the updated Vector4.
  62019. */
  62020. multiplyInPlace(otherVector: Vector4): Vector4;
  62021. /**
  62022. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  62023. * @param otherVector vector to multiple with
  62024. * @returns resulting new vector
  62025. */
  62026. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  62027. /**
  62028. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  62029. * @param otherVector vector to multiple with
  62030. * @param result vector to store the result
  62031. * @returns the current Vector4.
  62032. */
  62033. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62034. /**
  62035. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  62036. * @param x x value multiply with
  62037. * @param y y value multiply with
  62038. * @param z z value multiply with
  62039. * @param w w value multiply with
  62040. * @returns resulting new vector
  62041. */
  62042. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  62043. /**
  62044. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  62045. * @param otherVector vector to devide with
  62046. * @returns resulting new vector
  62047. */
  62048. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  62049. /**
  62050. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  62051. * @param otherVector vector to devide with
  62052. * @param result vector to store the result
  62053. * @returns the current Vector4.
  62054. */
  62055. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62056. /**
  62057. * Divides the current Vector3 coordinates by the given ones.
  62058. * @param otherVector vector to devide with
  62059. * @returns the updated Vector3.
  62060. */
  62061. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62062. /**
  62063. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  62064. * @param other defines the second operand
  62065. * @returns the current updated Vector4
  62066. */
  62067. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62068. /**
  62069. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  62070. * @param other defines the second operand
  62071. * @returns the current updated Vector4
  62072. */
  62073. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62074. /**
  62075. * Gets a new Vector4 from current Vector4 floored values
  62076. * @returns a new Vector4
  62077. */
  62078. floor(): Vector4;
  62079. /**
  62080. * Gets a new Vector4 from current Vector3 floored values
  62081. * @returns a new Vector4
  62082. */
  62083. fract(): Vector4;
  62084. /**
  62085. * Returns the Vector4 length (float).
  62086. * @returns the length
  62087. */
  62088. length(): number;
  62089. /**
  62090. * Returns the Vector4 squared length (float).
  62091. * @returns the length squared
  62092. */
  62093. lengthSquared(): number;
  62094. /**
  62095. * Normalizes in place the Vector4.
  62096. * @returns the updated Vector4.
  62097. */
  62098. normalize(): Vector4;
  62099. /**
  62100. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  62101. * @returns this converted to a new vector3
  62102. */
  62103. toVector3(): Vector3;
  62104. /**
  62105. * Returns a new Vector4 copied from the current one.
  62106. * @returns the new cloned vector
  62107. */
  62108. clone(): Vector4;
  62109. /**
  62110. * Updates the current Vector4 with the given one coordinates.
  62111. * @param source the source vector to copy from
  62112. * @returns the updated Vector4.
  62113. */
  62114. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  62115. /**
  62116. * Updates the current Vector4 coordinates with the given floats.
  62117. * @param x float to copy from
  62118. * @param y float to copy from
  62119. * @param z float to copy from
  62120. * @param w float to copy from
  62121. * @returns the updated Vector4.
  62122. */
  62123. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62124. /**
  62125. * Updates the current Vector4 coordinates with the given floats.
  62126. * @param x float to set from
  62127. * @param y float to set from
  62128. * @param z float to set from
  62129. * @param w float to set from
  62130. * @returns the updated Vector4.
  62131. */
  62132. set(x: number, y: number, z: number, w: number): Vector4;
  62133. /**
  62134. * Copies the given float to the current Vector3 coordinates
  62135. * @param v defines the x, y, z and w coordinates of the operand
  62136. * @returns the current updated Vector3
  62137. */
  62138. setAll(v: number): Vector4;
  62139. /**
  62140. * Returns a new Vector4 set from the starting index of the given array.
  62141. * @param array the array to pull values from
  62142. * @param offset the offset into the array to start at
  62143. * @returns the new vector
  62144. */
  62145. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  62146. /**
  62147. * Updates the given vector "result" from the starting index of the given array.
  62148. * @param array the array to pull values from
  62149. * @param offset the offset into the array to start at
  62150. * @param result the vector to store the result in
  62151. */
  62152. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  62153. /**
  62154. * Updates the given vector "result" from the starting index of the given Float32Array.
  62155. * @param array the array to pull values from
  62156. * @param offset the offset into the array to start at
  62157. * @param result the vector to store the result in
  62158. */
  62159. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  62160. /**
  62161. * Updates the given vector "result" coordinates from the given floats.
  62162. * @param x float to set from
  62163. * @param y float to set from
  62164. * @param z float to set from
  62165. * @param w float to set from
  62166. * @param result the vector to the floats in
  62167. */
  62168. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  62169. /**
  62170. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  62171. * @returns the new vector
  62172. */
  62173. static Zero(): Vector4;
  62174. /**
  62175. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  62176. * @returns the new vector
  62177. */
  62178. static One(): Vector4;
  62179. /**
  62180. * Returns a new normalized Vector4 from the given one.
  62181. * @param vector the vector to normalize
  62182. * @returns the vector
  62183. */
  62184. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  62185. /**
  62186. * Updates the given vector "result" from the normalization of the given one.
  62187. * @param vector the vector to normalize
  62188. * @param result the vector to store the result in
  62189. */
  62190. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  62191. /**
  62192. * Returns a vector with the minimum values from the left and right vectors
  62193. * @param left left vector to minimize
  62194. * @param right right vector to minimize
  62195. * @returns a new vector with the minimum of the left and right vector values
  62196. */
  62197. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62198. /**
  62199. * Returns a vector with the maximum values from the left and right vectors
  62200. * @param left left vector to maximize
  62201. * @param right right vector to maximize
  62202. * @returns a new vector with the maximum of the left and right vector values
  62203. */
  62204. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62205. /**
  62206. * Returns the distance (float) between the vectors "value1" and "value2".
  62207. * @param value1 value to calulate the distance between
  62208. * @param value2 value to calulate the distance between
  62209. * @return the distance between the two vectors
  62210. */
  62211. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62212. /**
  62213. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62214. * @param value1 value to calulate the distance between
  62215. * @param value2 value to calulate the distance between
  62216. * @return the distance between the two vectors squared
  62217. */
  62218. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62219. /**
  62220. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62221. * @param value1 value to calulate the center between
  62222. * @param value2 value to calulate the center between
  62223. * @return the center between the two vectors
  62224. */
  62225. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62226. /**
  62227. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62228. * This methods computes transformed normalized direction vectors only.
  62229. * @param vector the vector to transform
  62230. * @param transformation the transformation matrix to apply
  62231. * @returns the new vector
  62232. */
  62233. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62234. /**
  62235. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62236. * This methods computes transformed normalized direction vectors only.
  62237. * @param vector the vector to transform
  62238. * @param transformation the transformation matrix to apply
  62239. * @param result the vector to store the result in
  62240. */
  62241. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62242. /**
  62243. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62244. * This methods computes transformed normalized direction vectors only.
  62245. * @param x value to transform
  62246. * @param y value to transform
  62247. * @param z value to transform
  62248. * @param w value to transform
  62249. * @param transformation the transformation matrix to apply
  62250. * @param result the vector to store the results in
  62251. */
  62252. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62253. /**
  62254. * Creates a new Vector4 from a Vector3
  62255. * @param source defines the source data
  62256. * @param w defines the 4th component (default is 0)
  62257. * @returns a new Vector4
  62258. */
  62259. static FromVector3(source: Vector3, w?: number): Vector4;
  62260. }
  62261. /**
  62262. * Interface for the size containing width and height
  62263. */
  62264. export interface ISize {
  62265. /**
  62266. * Width
  62267. */
  62268. width: number;
  62269. /**
  62270. * Heighht
  62271. */
  62272. height: number;
  62273. }
  62274. /**
  62275. * Size containing widht and height
  62276. */
  62277. export class Size implements ISize {
  62278. /**
  62279. * Width
  62280. */
  62281. width: number;
  62282. /**
  62283. * Height
  62284. */
  62285. height: number;
  62286. /**
  62287. * Creates a Size object from the given width and height (floats).
  62288. * @param width width of the new size
  62289. * @param height height of the new size
  62290. */
  62291. constructor(width: number, height: number);
  62292. /**
  62293. * Returns a string with the Size width and height
  62294. * @returns a string with the Size width and height
  62295. */
  62296. toString(): string;
  62297. /**
  62298. * "Size"
  62299. * @returns the string "Size"
  62300. */
  62301. getClassName(): string;
  62302. /**
  62303. * Returns the Size hash code.
  62304. * @returns a hash code for a unique width and height
  62305. */
  62306. getHashCode(): number;
  62307. /**
  62308. * Updates the current size from the given one.
  62309. * @param src the given size
  62310. */
  62311. copyFrom(src: Size): void;
  62312. /**
  62313. * Updates in place the current Size from the given floats.
  62314. * @param width width of the new size
  62315. * @param height height of the new size
  62316. * @returns the updated Size.
  62317. */
  62318. copyFromFloats(width: number, height: number): Size;
  62319. /**
  62320. * Updates in place the current Size from the given floats.
  62321. * @param width width to set
  62322. * @param height height to set
  62323. * @returns the updated Size.
  62324. */
  62325. set(width: number, height: number): Size;
  62326. /**
  62327. * Multiplies the width and height by numbers
  62328. * @param w factor to multiple the width by
  62329. * @param h factor to multiple the height by
  62330. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62331. */
  62332. multiplyByFloats(w: number, h: number): Size;
  62333. /**
  62334. * Clones the size
  62335. * @returns a new Size copied from the given one.
  62336. */
  62337. clone(): Size;
  62338. /**
  62339. * True if the current Size and the given one width and height are strictly equal.
  62340. * @param other the other size to compare against
  62341. * @returns True if the current Size and the given one width and height are strictly equal.
  62342. */
  62343. equals(other: Size): boolean;
  62344. /**
  62345. * The surface of the Size : width * height (float).
  62346. */
  62347. readonly surface: number;
  62348. /**
  62349. * Create a new size of zero
  62350. * @returns a new Size set to (0.0, 0.0)
  62351. */
  62352. static Zero(): Size;
  62353. /**
  62354. * Sums the width and height of two sizes
  62355. * @param otherSize size to add to this size
  62356. * @returns a new Size set as the addition result of the current Size and the given one.
  62357. */
  62358. add(otherSize: Size): Size;
  62359. /**
  62360. * Subtracts the width and height of two
  62361. * @param otherSize size to subtract to this size
  62362. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62363. */
  62364. subtract(otherSize: Size): Size;
  62365. /**
  62366. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62367. * @param start starting size to lerp between
  62368. * @param end end size to lerp between
  62369. * @param amount amount to lerp between the start and end values
  62370. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62371. */
  62372. static Lerp(start: Size, end: Size, amount: number): Size;
  62373. }
  62374. /**
  62375. * Class used to store quaternion data
  62376. * @see https://en.wikipedia.org/wiki/Quaternion
  62377. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62378. */
  62379. export class Quaternion {
  62380. /** defines the first component (0 by default) */
  62381. x: number;
  62382. /** defines the second component (0 by default) */
  62383. y: number;
  62384. /** defines the third component (0 by default) */
  62385. z: number;
  62386. /** defines the fourth component (1.0 by default) */
  62387. w: number;
  62388. /**
  62389. * Creates a new Quaternion from the given floats
  62390. * @param x defines the first component (0 by default)
  62391. * @param y defines the second component (0 by default)
  62392. * @param z defines the third component (0 by default)
  62393. * @param w defines the fourth component (1.0 by default)
  62394. */
  62395. constructor(
  62396. /** defines the first component (0 by default) */
  62397. x?: number,
  62398. /** defines the second component (0 by default) */
  62399. y?: number,
  62400. /** defines the third component (0 by default) */
  62401. z?: number,
  62402. /** defines the fourth component (1.0 by default) */
  62403. w?: number);
  62404. /**
  62405. * Gets a string representation for the current quaternion
  62406. * @returns a string with the Quaternion coordinates
  62407. */
  62408. toString(): string;
  62409. /**
  62410. * Gets the class name of the quaternion
  62411. * @returns the string "Quaternion"
  62412. */
  62413. getClassName(): string;
  62414. /**
  62415. * Gets a hash code for this quaternion
  62416. * @returns the quaternion hash code
  62417. */
  62418. getHashCode(): number;
  62419. /**
  62420. * Copy the quaternion to an array
  62421. * @returns a new array populated with 4 elements from the quaternion coordinates
  62422. */
  62423. asArray(): number[];
  62424. /**
  62425. * Check if two quaternions are equals
  62426. * @param otherQuaternion defines the second operand
  62427. * @return true if the current quaternion and the given one coordinates are strictly equals
  62428. */
  62429. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62430. /**
  62431. * Clone the current quaternion
  62432. * @returns a new quaternion copied from the current one
  62433. */
  62434. clone(): Quaternion;
  62435. /**
  62436. * Copy a quaternion to the current one
  62437. * @param other defines the other quaternion
  62438. * @returns the updated current quaternion
  62439. */
  62440. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62441. /**
  62442. * Updates the current quaternion with the given float coordinates
  62443. * @param x defines the x coordinate
  62444. * @param y defines the y coordinate
  62445. * @param z defines the z coordinate
  62446. * @param w defines the w coordinate
  62447. * @returns the updated current quaternion
  62448. */
  62449. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62450. /**
  62451. * Updates the current quaternion from the given float coordinates
  62452. * @param x defines the x coordinate
  62453. * @param y defines the y coordinate
  62454. * @param z defines the z coordinate
  62455. * @param w defines the w coordinate
  62456. * @returns the updated current quaternion
  62457. */
  62458. set(x: number, y: number, z: number, w: number): Quaternion;
  62459. /**
  62460. * Adds two quaternions
  62461. * @param other defines the second operand
  62462. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62463. */
  62464. add(other: DeepImmutable<Quaternion>): Quaternion;
  62465. /**
  62466. * Add a quaternion to the current one
  62467. * @param other defines the quaternion to add
  62468. * @returns the current quaternion
  62469. */
  62470. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62471. /**
  62472. * Subtract two quaternions
  62473. * @param other defines the second operand
  62474. * @returns a new quaternion as the subtraction result of the given one from the current one
  62475. */
  62476. subtract(other: Quaternion): Quaternion;
  62477. /**
  62478. * Multiplies the current quaternion by a scale factor
  62479. * @param value defines the scale factor
  62480. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62481. */
  62482. scale(value: number): Quaternion;
  62483. /**
  62484. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62485. * @param scale defines the scale factor
  62486. * @param result defines the Quaternion object where to store the result
  62487. * @returns the unmodified current quaternion
  62488. */
  62489. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62490. /**
  62491. * Multiplies in place the current quaternion by a scale factor
  62492. * @param value defines the scale factor
  62493. * @returns the current modified quaternion
  62494. */
  62495. scaleInPlace(value: number): Quaternion;
  62496. /**
  62497. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62498. * @param scale defines the scale factor
  62499. * @param result defines the Quaternion object where to store the result
  62500. * @returns the unmodified current quaternion
  62501. */
  62502. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62503. /**
  62504. * Multiplies two quaternions
  62505. * @param q1 defines the second operand
  62506. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62507. */
  62508. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62509. /**
  62510. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62511. * @param q1 defines the second operand
  62512. * @param result defines the target quaternion
  62513. * @returns the current quaternion
  62514. */
  62515. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62516. /**
  62517. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62518. * @param q1 defines the second operand
  62519. * @returns the currentupdated quaternion
  62520. */
  62521. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62522. /**
  62523. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62524. * @param ref defines the target quaternion
  62525. * @returns the current quaternion
  62526. */
  62527. conjugateToRef(ref: Quaternion): Quaternion;
  62528. /**
  62529. * Conjugates in place (1-q) the current quaternion
  62530. * @returns the current updated quaternion
  62531. */
  62532. conjugateInPlace(): Quaternion;
  62533. /**
  62534. * Conjugates in place (1-q) the current quaternion
  62535. * @returns a new quaternion
  62536. */
  62537. conjugate(): Quaternion;
  62538. /**
  62539. * Gets length of current quaternion
  62540. * @returns the quaternion length (float)
  62541. */
  62542. length(): number;
  62543. /**
  62544. * Normalize in place the current quaternion
  62545. * @returns the current updated quaternion
  62546. */
  62547. normalize(): Quaternion;
  62548. /**
  62549. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62550. * @param order is a reserved parameter and is ignore for now
  62551. * @returns a new Vector3 containing the Euler angles
  62552. */
  62553. toEulerAngles(order?: string): Vector3;
  62554. /**
  62555. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62556. * @param result defines the vector which will be filled with the Euler angles
  62557. * @param order is a reserved parameter and is ignore for now
  62558. * @returns the current unchanged quaternion
  62559. */
  62560. toEulerAnglesToRef(result: Vector3): Quaternion;
  62561. /**
  62562. * Updates the given rotation matrix with the current quaternion values
  62563. * @param result defines the target matrix
  62564. * @returns the current unchanged quaternion
  62565. */
  62566. toRotationMatrix(result: Matrix): Quaternion;
  62567. /**
  62568. * Updates the current quaternion from the given rotation matrix values
  62569. * @param matrix defines the source matrix
  62570. * @returns the current updated quaternion
  62571. */
  62572. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62573. /**
  62574. * Creates a new quaternion from a rotation matrix
  62575. * @param matrix defines the source matrix
  62576. * @returns a new quaternion created from the given rotation matrix values
  62577. */
  62578. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62579. /**
  62580. * Updates the given quaternion with the given rotation matrix values
  62581. * @param matrix defines the source matrix
  62582. * @param result defines the target quaternion
  62583. */
  62584. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62585. /**
  62586. * Returns the dot product (float) between the quaternions "left" and "right"
  62587. * @param left defines the left operand
  62588. * @param right defines the right operand
  62589. * @returns the dot product
  62590. */
  62591. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62592. /**
  62593. * Checks if the two quaternions are close to each other
  62594. * @param quat0 defines the first quaternion to check
  62595. * @param quat1 defines the second quaternion to check
  62596. * @returns true if the two quaternions are close to each other
  62597. */
  62598. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62599. /**
  62600. * Creates an empty quaternion
  62601. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62602. */
  62603. static Zero(): Quaternion;
  62604. /**
  62605. * Inverse a given quaternion
  62606. * @param q defines the source quaternion
  62607. * @returns a new quaternion as the inverted current quaternion
  62608. */
  62609. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62610. /**
  62611. * Inverse a given quaternion
  62612. * @param q defines the source quaternion
  62613. * @param result the quaternion the result will be stored in
  62614. * @returns the result quaternion
  62615. */
  62616. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62617. /**
  62618. * Creates an identity quaternion
  62619. * @returns the identity quaternion
  62620. */
  62621. static Identity(): Quaternion;
  62622. /**
  62623. * Gets a boolean indicating if the given quaternion is identity
  62624. * @param quaternion defines the quaternion to check
  62625. * @returns true if the quaternion is identity
  62626. */
  62627. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62628. /**
  62629. * Creates a quaternion from a rotation around an axis
  62630. * @param axis defines the axis to use
  62631. * @param angle defines the angle to use
  62632. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62633. */
  62634. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62635. /**
  62636. * Creates a rotation around an axis and stores it into the given quaternion
  62637. * @param axis defines the axis to use
  62638. * @param angle defines the angle to use
  62639. * @param result defines the target quaternion
  62640. * @returns the target quaternion
  62641. */
  62642. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62643. /**
  62644. * Creates a new quaternion from data stored into an array
  62645. * @param array defines the data source
  62646. * @param offset defines the offset in the source array where the data starts
  62647. * @returns a new quaternion
  62648. */
  62649. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62650. /**
  62651. * Create a quaternion from Euler rotation angles
  62652. * @param x Pitch
  62653. * @param y Yaw
  62654. * @param z Roll
  62655. * @returns the new Quaternion
  62656. */
  62657. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62658. /**
  62659. * Updates a quaternion from Euler rotation angles
  62660. * @param x Pitch
  62661. * @param y Yaw
  62662. * @param z Roll
  62663. * @param result the quaternion to store the result
  62664. * @returns the updated quaternion
  62665. */
  62666. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62667. /**
  62668. * Create a quaternion from Euler rotation vector
  62669. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62670. * @returns the new Quaternion
  62671. */
  62672. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62673. /**
  62674. * Updates a quaternion from Euler rotation vector
  62675. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62676. * @param result the quaternion to store the result
  62677. * @returns the updated quaternion
  62678. */
  62679. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62680. /**
  62681. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62682. * @param yaw defines the rotation around Y axis
  62683. * @param pitch defines the rotation around X axis
  62684. * @param roll defines the rotation around Z axis
  62685. * @returns the new quaternion
  62686. */
  62687. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62688. /**
  62689. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62690. * @param yaw defines the rotation around Y axis
  62691. * @param pitch defines the rotation around X axis
  62692. * @param roll defines the rotation around Z axis
  62693. * @param result defines the target quaternion
  62694. */
  62695. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62696. /**
  62697. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62698. * @param alpha defines the rotation around first axis
  62699. * @param beta defines the rotation around second axis
  62700. * @param gamma defines the rotation around third axis
  62701. * @returns the new quaternion
  62702. */
  62703. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62704. /**
  62705. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62706. * @param alpha defines the rotation around first axis
  62707. * @param beta defines the rotation around second axis
  62708. * @param gamma defines the rotation around third axis
  62709. * @param result defines the target quaternion
  62710. */
  62711. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62712. /**
  62713. * 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)
  62714. * @param axis1 defines the first axis
  62715. * @param axis2 defines the second axis
  62716. * @param axis3 defines the third axis
  62717. * @returns the new quaternion
  62718. */
  62719. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62720. /**
  62721. * 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
  62722. * @param axis1 defines the first axis
  62723. * @param axis2 defines the second axis
  62724. * @param axis3 defines the third axis
  62725. * @param ref defines the target quaternion
  62726. */
  62727. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62728. /**
  62729. * Interpolates between two quaternions
  62730. * @param left defines first quaternion
  62731. * @param right defines second quaternion
  62732. * @param amount defines the gradient to use
  62733. * @returns the new interpolated quaternion
  62734. */
  62735. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62736. /**
  62737. * Interpolates between two quaternions and stores it into a target quaternion
  62738. * @param left defines first quaternion
  62739. * @param right defines second quaternion
  62740. * @param amount defines the gradient to use
  62741. * @param result defines the target quaternion
  62742. */
  62743. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62744. /**
  62745. * Interpolate between two quaternions using Hermite interpolation
  62746. * @param value1 defines first quaternion
  62747. * @param tangent1 defines the incoming tangent
  62748. * @param value2 defines second quaternion
  62749. * @param tangent2 defines the outgoing tangent
  62750. * @param amount defines the target quaternion
  62751. * @returns the new interpolated quaternion
  62752. */
  62753. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62754. }
  62755. /**
  62756. * Class used to store matrix data (4x4)
  62757. */
  62758. export class Matrix {
  62759. private static _updateFlagSeed;
  62760. private static _identityReadOnly;
  62761. private _isIdentity;
  62762. private _isIdentityDirty;
  62763. private _isIdentity3x2;
  62764. private _isIdentity3x2Dirty;
  62765. /**
  62766. * Gets the update flag of the matrix which is an unique number for the matrix.
  62767. * It will be incremented every time the matrix data change.
  62768. * You can use it to speed the comparison between two versions of the same matrix.
  62769. */
  62770. updateFlag: number;
  62771. private readonly _m;
  62772. /**
  62773. * Gets the internal data of the matrix
  62774. */
  62775. readonly m: DeepImmutable<Float32Array>;
  62776. /** @hidden */
  62777. _markAsUpdated(): void;
  62778. /** @hidden */
  62779. private _updateIdentityStatus;
  62780. /**
  62781. * Creates an empty matrix (filled with zeros)
  62782. */
  62783. constructor();
  62784. /**
  62785. * Check if the current matrix is identity
  62786. * @returns true is the matrix is the identity matrix
  62787. */
  62788. isIdentity(): boolean;
  62789. /**
  62790. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62791. * @returns true is the matrix is the identity matrix
  62792. */
  62793. isIdentityAs3x2(): boolean;
  62794. /**
  62795. * Gets the determinant of the matrix
  62796. * @returns the matrix determinant
  62797. */
  62798. determinant(): number;
  62799. /**
  62800. * Returns the matrix as a Float32Array
  62801. * @returns the matrix underlying array
  62802. */
  62803. toArray(): DeepImmutable<Float32Array>;
  62804. /**
  62805. * Returns the matrix as a Float32Array
  62806. * @returns the matrix underlying array.
  62807. */
  62808. asArray(): DeepImmutable<Float32Array>;
  62809. /**
  62810. * Inverts the current matrix in place
  62811. * @returns the current inverted matrix
  62812. */
  62813. invert(): Matrix;
  62814. /**
  62815. * Sets all the matrix elements to zero
  62816. * @returns the current matrix
  62817. */
  62818. reset(): Matrix;
  62819. /**
  62820. * Adds the current matrix with a second one
  62821. * @param other defines the matrix to add
  62822. * @returns a new matrix as the addition of the current matrix and the given one
  62823. */
  62824. add(other: DeepImmutable<Matrix>): Matrix;
  62825. /**
  62826. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62827. * @param other defines the matrix to add
  62828. * @param result defines the target matrix
  62829. * @returns the current matrix
  62830. */
  62831. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62832. /**
  62833. * Adds in place the given matrix to the current matrix
  62834. * @param other defines the second operand
  62835. * @returns the current updated matrix
  62836. */
  62837. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62838. /**
  62839. * Sets the given matrix to the current inverted Matrix
  62840. * @param other defines the target matrix
  62841. * @returns the unmodified current matrix
  62842. */
  62843. invertToRef(other: Matrix): Matrix;
  62844. /**
  62845. * add a value at the specified position in the current Matrix
  62846. * @param index the index of the value within the matrix. between 0 and 15.
  62847. * @param value the value to be added
  62848. * @returns the current updated matrix
  62849. */
  62850. addAtIndex(index: number, value: number): Matrix;
  62851. /**
  62852. * mutiply the specified position in the current Matrix by a value
  62853. * @param index the index of the value within the matrix. between 0 and 15.
  62854. * @param value the value to be added
  62855. * @returns the current updated matrix
  62856. */
  62857. multiplyAtIndex(index: number, value: number): Matrix;
  62858. /**
  62859. * Inserts the translation vector (using 3 floats) in the current matrix
  62860. * @param x defines the 1st component of the translation
  62861. * @param y defines the 2nd component of the translation
  62862. * @param z defines the 3rd component of the translation
  62863. * @returns the current updated matrix
  62864. */
  62865. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62866. /**
  62867. * Adds the translation vector (using 3 floats) in the current matrix
  62868. * @param x defines the 1st component of the translation
  62869. * @param y defines the 2nd component of the translation
  62870. * @param z defines the 3rd component of the translation
  62871. * @returns the current updated matrix
  62872. */
  62873. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62874. /**
  62875. * Inserts the translation vector in the current matrix
  62876. * @param vector3 defines the translation to insert
  62877. * @returns the current updated matrix
  62878. */
  62879. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62880. /**
  62881. * Gets the translation value of the current matrix
  62882. * @returns a new Vector3 as the extracted translation from the matrix
  62883. */
  62884. getTranslation(): Vector3;
  62885. /**
  62886. * Fill a Vector3 with the extracted translation from the matrix
  62887. * @param result defines the Vector3 where to store the translation
  62888. * @returns the current matrix
  62889. */
  62890. getTranslationToRef(result: Vector3): Matrix;
  62891. /**
  62892. * Remove rotation and scaling part from the matrix
  62893. * @returns the updated matrix
  62894. */
  62895. removeRotationAndScaling(): Matrix;
  62896. /**
  62897. * Multiply two matrices
  62898. * @param other defines the second operand
  62899. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62900. */
  62901. multiply(other: DeepImmutable<Matrix>): Matrix;
  62902. /**
  62903. * Copy the current matrix from the given one
  62904. * @param other defines the source matrix
  62905. * @returns the current updated matrix
  62906. */
  62907. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62908. /**
  62909. * Populates the given array from the starting index with the current matrix values
  62910. * @param array defines the target array
  62911. * @param offset defines the offset in the target array where to start storing values
  62912. * @returns the current matrix
  62913. */
  62914. copyToArray(array: Float32Array, offset?: number): Matrix;
  62915. /**
  62916. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62917. * @param other defines the second operand
  62918. * @param result defines the matrix where to store the multiplication
  62919. * @returns the current matrix
  62920. */
  62921. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62922. /**
  62923. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62924. * @param other defines the second operand
  62925. * @param result defines the array where to store the multiplication
  62926. * @param offset defines the offset in the target array where to start storing values
  62927. * @returns the current matrix
  62928. */
  62929. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62930. /**
  62931. * Check equality between this matrix and a second one
  62932. * @param value defines the second matrix to compare
  62933. * @returns true is the current matrix and the given one values are strictly equal
  62934. */
  62935. equals(value: DeepImmutable<Matrix>): boolean;
  62936. /**
  62937. * Clone the current matrix
  62938. * @returns a new matrix from the current matrix
  62939. */
  62940. clone(): Matrix;
  62941. /**
  62942. * Returns the name of the current matrix class
  62943. * @returns the string "Matrix"
  62944. */
  62945. getClassName(): string;
  62946. /**
  62947. * Gets the hash code of the current matrix
  62948. * @returns the hash code
  62949. */
  62950. getHashCode(): number;
  62951. /**
  62952. * Decomposes the current Matrix into a translation, rotation and scaling components
  62953. * @param scale defines the scale vector3 given as a reference to update
  62954. * @param rotation defines the rotation quaternion given as a reference to update
  62955. * @param translation defines the translation vector3 given as a reference to update
  62956. * @returns true if operation was successful
  62957. */
  62958. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62959. /**
  62960. * Gets specific row of the matrix
  62961. * @param index defines the number of the row to get
  62962. * @returns the index-th row of the current matrix as a new Vector4
  62963. */
  62964. getRow(index: number): Nullable<Vector4>;
  62965. /**
  62966. * Sets the index-th row of the current matrix to the vector4 values
  62967. * @param index defines the number of the row to set
  62968. * @param row defines the target vector4
  62969. * @returns the updated current matrix
  62970. */
  62971. setRow(index: number, row: Vector4): Matrix;
  62972. /**
  62973. * Compute the transpose of the matrix
  62974. * @returns the new transposed matrix
  62975. */
  62976. transpose(): Matrix;
  62977. /**
  62978. * Compute the transpose of the matrix and store it in a given matrix
  62979. * @param result defines the target matrix
  62980. * @returns the current matrix
  62981. */
  62982. transposeToRef(result: Matrix): Matrix;
  62983. /**
  62984. * Sets the index-th row of the current matrix with the given 4 x float values
  62985. * @param index defines the row index
  62986. * @param x defines the x component to set
  62987. * @param y defines the y component to set
  62988. * @param z defines the z component to set
  62989. * @param w defines the w component to set
  62990. * @returns the updated current matrix
  62991. */
  62992. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62993. /**
  62994. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62995. * @param scale defines the scale factor
  62996. * @returns a new matrix
  62997. */
  62998. scale(scale: number): Matrix;
  62999. /**
  63000. * Scale the current matrix values by a factor to a given result matrix
  63001. * @param scale defines the scale factor
  63002. * @param result defines the matrix to store the result
  63003. * @returns the current matrix
  63004. */
  63005. scaleToRef(scale: number, result: Matrix): Matrix;
  63006. /**
  63007. * Scale the current matrix values by a factor and add the result to a given matrix
  63008. * @param scale defines the scale factor
  63009. * @param result defines the Matrix to store the result
  63010. * @returns the current matrix
  63011. */
  63012. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  63013. /**
  63014. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  63015. * @param ref matrix to store the result
  63016. */
  63017. toNormalMatrix(ref: Matrix): void;
  63018. /**
  63019. * Gets only rotation part of the current matrix
  63020. * @returns a new matrix sets to the extracted rotation matrix from the current one
  63021. */
  63022. getRotationMatrix(): Matrix;
  63023. /**
  63024. * Extracts the rotation matrix from the current one and sets it as the given "result"
  63025. * @param result defines the target matrix to store data to
  63026. * @returns the current matrix
  63027. */
  63028. getRotationMatrixToRef(result: Matrix): Matrix;
  63029. /**
  63030. * Toggles model matrix from being right handed to left handed in place and vice versa
  63031. */
  63032. toggleModelMatrixHandInPlace(): void;
  63033. /**
  63034. * Toggles projection matrix from being right handed to left handed in place and vice versa
  63035. */
  63036. toggleProjectionMatrixHandInPlace(): void;
  63037. /**
  63038. * Creates a matrix from an array
  63039. * @param array defines the source array
  63040. * @param offset defines an offset in the source array
  63041. * @returns a new Matrix set from the starting index of the given array
  63042. */
  63043. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  63044. /**
  63045. * Copy the content of an array into a given matrix
  63046. * @param array defines the source array
  63047. * @param offset defines an offset in the source array
  63048. * @param result defines the target matrix
  63049. */
  63050. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  63051. /**
  63052. * Stores an array into a matrix after having multiplied each component by a given factor
  63053. * @param array defines the source array
  63054. * @param offset defines the offset in the source array
  63055. * @param scale defines the scaling factor
  63056. * @param result defines the target matrix
  63057. */
  63058. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  63059. /**
  63060. * Gets an identity matrix that must not be updated
  63061. */
  63062. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  63063. /**
  63064. * Stores a list of values (16) inside a given matrix
  63065. * @param initialM11 defines 1st value of 1st row
  63066. * @param initialM12 defines 2nd value of 1st row
  63067. * @param initialM13 defines 3rd value of 1st row
  63068. * @param initialM14 defines 4th value of 1st row
  63069. * @param initialM21 defines 1st value of 2nd row
  63070. * @param initialM22 defines 2nd value of 2nd row
  63071. * @param initialM23 defines 3rd value of 2nd row
  63072. * @param initialM24 defines 4th value of 2nd row
  63073. * @param initialM31 defines 1st value of 3rd row
  63074. * @param initialM32 defines 2nd value of 3rd row
  63075. * @param initialM33 defines 3rd value of 3rd row
  63076. * @param initialM34 defines 4th value of 3rd row
  63077. * @param initialM41 defines 1st value of 4th row
  63078. * @param initialM42 defines 2nd value of 4th row
  63079. * @param initialM43 defines 3rd value of 4th row
  63080. * @param initialM44 defines 4th value of 4th row
  63081. * @param result defines the target matrix
  63082. */
  63083. 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;
  63084. /**
  63085. * Creates new matrix from a list of values (16)
  63086. * @param initialM11 defines 1st value of 1st row
  63087. * @param initialM12 defines 2nd value of 1st row
  63088. * @param initialM13 defines 3rd value of 1st row
  63089. * @param initialM14 defines 4th value of 1st row
  63090. * @param initialM21 defines 1st value of 2nd row
  63091. * @param initialM22 defines 2nd value of 2nd row
  63092. * @param initialM23 defines 3rd value of 2nd row
  63093. * @param initialM24 defines 4th value of 2nd row
  63094. * @param initialM31 defines 1st value of 3rd row
  63095. * @param initialM32 defines 2nd value of 3rd row
  63096. * @param initialM33 defines 3rd value of 3rd row
  63097. * @param initialM34 defines 4th value of 3rd row
  63098. * @param initialM41 defines 1st value of 4th row
  63099. * @param initialM42 defines 2nd value of 4th row
  63100. * @param initialM43 defines 3rd value of 4th row
  63101. * @param initialM44 defines 4th value of 4th row
  63102. * @returns the new matrix
  63103. */
  63104. 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;
  63105. /**
  63106. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63107. * @param scale defines the scale vector3
  63108. * @param rotation defines the rotation quaternion
  63109. * @param translation defines the translation vector3
  63110. * @returns a new matrix
  63111. */
  63112. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  63113. /**
  63114. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63115. * @param scale defines the scale vector3
  63116. * @param rotation defines the rotation quaternion
  63117. * @param translation defines the translation vector3
  63118. * @param result defines the target matrix
  63119. */
  63120. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  63121. /**
  63122. * Creates a new identity matrix
  63123. * @returns a new identity matrix
  63124. */
  63125. static Identity(): Matrix;
  63126. /**
  63127. * Creates a new identity matrix and stores the result in a given matrix
  63128. * @param result defines the target matrix
  63129. */
  63130. static IdentityToRef(result: Matrix): void;
  63131. /**
  63132. * Creates a new zero matrix
  63133. * @returns a new zero matrix
  63134. */
  63135. static Zero(): Matrix;
  63136. /**
  63137. * Creates a new rotation matrix for "angle" radians around the X axis
  63138. * @param angle defines the angle (in radians) to use
  63139. * @return the new matrix
  63140. */
  63141. static RotationX(angle: number): Matrix;
  63142. /**
  63143. * Creates a new matrix as the invert of a given matrix
  63144. * @param source defines the source matrix
  63145. * @returns the new matrix
  63146. */
  63147. static Invert(source: DeepImmutable<Matrix>): Matrix;
  63148. /**
  63149. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  63150. * @param angle defines the angle (in radians) to use
  63151. * @param result defines the target matrix
  63152. */
  63153. static RotationXToRef(angle: number, result: Matrix): void;
  63154. /**
  63155. * Creates a new rotation matrix for "angle" radians around the Y axis
  63156. * @param angle defines the angle (in radians) to use
  63157. * @return the new matrix
  63158. */
  63159. static RotationY(angle: number): Matrix;
  63160. /**
  63161. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  63162. * @param angle defines the angle (in radians) to use
  63163. * @param result defines the target matrix
  63164. */
  63165. static RotationYToRef(angle: number, result: Matrix): void;
  63166. /**
  63167. * Creates a new rotation matrix for "angle" radians around the Z axis
  63168. * @param angle defines the angle (in radians) to use
  63169. * @return the new matrix
  63170. */
  63171. static RotationZ(angle: number): Matrix;
  63172. /**
  63173. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  63174. * @param angle defines the angle (in radians) to use
  63175. * @param result defines the target matrix
  63176. */
  63177. static RotationZToRef(angle: number, result: Matrix): void;
  63178. /**
  63179. * Creates a new rotation matrix for "angle" radians around the given axis
  63180. * @param axis defines the axis to use
  63181. * @param angle defines the angle (in radians) to use
  63182. * @return the new matrix
  63183. */
  63184. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  63185. /**
  63186. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  63187. * @param axis defines the axis to use
  63188. * @param angle defines the angle (in radians) to use
  63189. * @param result defines the target matrix
  63190. */
  63191. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  63192. /**
  63193. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  63194. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  63195. * @param from defines the vector to align
  63196. * @param to defines the vector to align to
  63197. * @param result defines the target matrix
  63198. */
  63199. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  63200. /**
  63201. * Creates a rotation matrix
  63202. * @param yaw defines the yaw angle in radians (Y axis)
  63203. * @param pitch defines the pitch angle in radians (X axis)
  63204. * @param roll defines the roll angle in radians (X axis)
  63205. * @returns the new rotation matrix
  63206. */
  63207. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63208. /**
  63209. * Creates a rotation matrix and stores it in a given matrix
  63210. * @param yaw defines the yaw angle in radians (Y axis)
  63211. * @param pitch defines the pitch angle in radians (X axis)
  63212. * @param roll defines the roll angle in radians (X axis)
  63213. * @param result defines the target matrix
  63214. */
  63215. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63216. /**
  63217. * Creates a scaling matrix
  63218. * @param x defines the scale factor on X axis
  63219. * @param y defines the scale factor on Y axis
  63220. * @param z defines the scale factor on Z axis
  63221. * @returns the new matrix
  63222. */
  63223. static Scaling(x: number, y: number, z: number): Matrix;
  63224. /**
  63225. * Creates a scaling matrix and stores it in a given matrix
  63226. * @param x defines the scale factor on X axis
  63227. * @param y defines the scale factor on Y axis
  63228. * @param z defines the scale factor on Z axis
  63229. * @param result defines the target matrix
  63230. */
  63231. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63232. /**
  63233. * Creates a translation matrix
  63234. * @param x defines the translation on X axis
  63235. * @param y defines the translation on Y axis
  63236. * @param z defines the translationon Z axis
  63237. * @returns the new matrix
  63238. */
  63239. static Translation(x: number, y: number, z: number): Matrix;
  63240. /**
  63241. * Creates a translation matrix and stores it in a given matrix
  63242. * @param x defines the translation on X axis
  63243. * @param y defines the translation on Y axis
  63244. * @param z defines the translationon Z axis
  63245. * @param result defines the target matrix
  63246. */
  63247. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63248. /**
  63249. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63250. * @param startValue defines the start value
  63251. * @param endValue defines the end value
  63252. * @param gradient defines the gradient factor
  63253. * @returns the new matrix
  63254. */
  63255. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63256. /**
  63257. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63258. * @param startValue defines the start value
  63259. * @param endValue defines the end value
  63260. * @param gradient defines the gradient factor
  63261. * @param result defines the Matrix object where to store data
  63262. */
  63263. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63264. /**
  63265. * Builds a new matrix whose values are computed by:
  63266. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63267. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63268. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63269. * @param startValue defines the first matrix
  63270. * @param endValue defines the second matrix
  63271. * @param gradient defines the gradient between the two matrices
  63272. * @returns the new matrix
  63273. */
  63274. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63275. /**
  63276. * Update a matrix to values which are computed by:
  63277. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63278. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63279. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63280. * @param startValue defines the first matrix
  63281. * @param endValue defines the second matrix
  63282. * @param gradient defines the gradient between the two matrices
  63283. * @param result defines the target matrix
  63284. */
  63285. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63286. /**
  63287. * 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"
  63288. * This function works in left handed mode
  63289. * @param eye defines the final position of the entity
  63290. * @param target defines where the entity should look at
  63291. * @param up defines the up vector for the entity
  63292. * @returns the new matrix
  63293. */
  63294. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63295. /**
  63296. * 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".
  63297. * This function works in left handed mode
  63298. * @param eye defines the final position of the entity
  63299. * @param target defines where the entity should look at
  63300. * @param up defines the up vector for the entity
  63301. * @param result defines the target matrix
  63302. */
  63303. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63304. /**
  63305. * 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"
  63306. * This function works in right handed mode
  63307. * @param eye defines the final position of the entity
  63308. * @param target defines where the entity should look at
  63309. * @param up defines the up vector for the entity
  63310. * @returns the new matrix
  63311. */
  63312. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63313. /**
  63314. * 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".
  63315. * This function works in right handed mode
  63316. * @param eye defines the final position of the entity
  63317. * @param target defines where the entity should look at
  63318. * @param up defines the up vector for the entity
  63319. * @param result defines the target matrix
  63320. */
  63321. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63322. /**
  63323. * Create a left-handed orthographic projection matrix
  63324. * @param width defines the viewport width
  63325. * @param height defines the viewport height
  63326. * @param znear defines the near clip plane
  63327. * @param zfar defines the far clip plane
  63328. * @returns a new matrix as a left-handed orthographic projection matrix
  63329. */
  63330. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63331. /**
  63332. * Store a left-handed orthographic projection to a given matrix
  63333. * @param width defines the viewport width
  63334. * @param height defines the viewport height
  63335. * @param znear defines the near clip plane
  63336. * @param zfar defines the far clip plane
  63337. * @param result defines the target matrix
  63338. */
  63339. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63340. /**
  63341. * Create a left-handed orthographic projection matrix
  63342. * @param left defines the viewport left coordinate
  63343. * @param right defines the viewport right coordinate
  63344. * @param bottom defines the viewport bottom coordinate
  63345. * @param top defines the viewport top coordinate
  63346. * @param znear defines the near clip plane
  63347. * @param zfar defines the far clip plane
  63348. * @returns a new matrix as a left-handed orthographic projection matrix
  63349. */
  63350. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63351. /**
  63352. * Stores a left-handed orthographic projection into a given matrix
  63353. * @param left defines the viewport left coordinate
  63354. * @param right defines the viewport right coordinate
  63355. * @param bottom defines the viewport bottom coordinate
  63356. * @param top defines the viewport top coordinate
  63357. * @param znear defines the near clip plane
  63358. * @param zfar defines the far clip plane
  63359. * @param result defines the target matrix
  63360. */
  63361. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63362. /**
  63363. * Creates a right-handed orthographic projection matrix
  63364. * @param left defines the viewport left coordinate
  63365. * @param right defines the viewport right coordinate
  63366. * @param bottom defines the viewport bottom coordinate
  63367. * @param top defines the viewport top coordinate
  63368. * @param znear defines the near clip plane
  63369. * @param zfar defines the far clip plane
  63370. * @returns a new matrix as a right-handed orthographic projection matrix
  63371. */
  63372. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63373. /**
  63374. * Stores a right-handed orthographic projection into a given matrix
  63375. * @param left defines the viewport left coordinate
  63376. * @param right defines the viewport right coordinate
  63377. * @param bottom defines the viewport bottom coordinate
  63378. * @param top defines the viewport top coordinate
  63379. * @param znear defines the near clip plane
  63380. * @param zfar defines the far clip plane
  63381. * @param result defines the target matrix
  63382. */
  63383. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63384. /**
  63385. * Creates a left-handed perspective projection matrix
  63386. * @param width defines the viewport width
  63387. * @param height defines the viewport height
  63388. * @param znear defines the near clip plane
  63389. * @param zfar defines the far clip plane
  63390. * @returns a new matrix as a left-handed perspective projection matrix
  63391. */
  63392. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63393. /**
  63394. * Creates a left-handed perspective projection matrix
  63395. * @param fov defines the horizontal field of view
  63396. * @param aspect defines the aspect ratio
  63397. * @param znear defines the near clip plane
  63398. * @param zfar defines the far clip plane
  63399. * @returns a new matrix as a left-handed perspective projection matrix
  63400. */
  63401. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63402. /**
  63403. * Stores a left-handed perspective projection into a given matrix
  63404. * @param fov defines the horizontal field of view
  63405. * @param aspect defines the aspect ratio
  63406. * @param znear defines the near clip plane
  63407. * @param zfar defines the far clip plane
  63408. * @param result defines the target matrix
  63409. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63410. */
  63411. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63412. /**
  63413. * Creates a right-handed perspective projection matrix
  63414. * @param fov defines the horizontal field of view
  63415. * @param aspect defines the aspect ratio
  63416. * @param znear defines the near clip plane
  63417. * @param zfar defines the far clip plane
  63418. * @returns a new matrix as a right-handed perspective projection matrix
  63419. */
  63420. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63421. /**
  63422. * Stores a right-handed perspective projection into a given matrix
  63423. * @param fov defines the horizontal field of view
  63424. * @param aspect defines the aspect ratio
  63425. * @param znear defines the near clip plane
  63426. * @param zfar defines the far clip plane
  63427. * @param result defines the target matrix
  63428. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63429. */
  63430. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63431. /**
  63432. * Stores a perspective projection for WebVR info a given matrix
  63433. * @param fov defines the field of view
  63434. * @param znear defines the near clip plane
  63435. * @param zfar defines the far clip plane
  63436. * @param result defines the target matrix
  63437. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63438. */
  63439. static PerspectiveFovWebVRToRef(fov: {
  63440. upDegrees: number;
  63441. downDegrees: number;
  63442. leftDegrees: number;
  63443. rightDegrees: number;
  63444. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63445. /**
  63446. * Computes a complete transformation matrix
  63447. * @param viewport defines the viewport to use
  63448. * @param world defines the world matrix
  63449. * @param view defines the view matrix
  63450. * @param projection defines the projection matrix
  63451. * @param zmin defines the near clip plane
  63452. * @param zmax defines the far clip plane
  63453. * @returns the transformation matrix
  63454. */
  63455. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63456. /**
  63457. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63458. * @param matrix defines the matrix to use
  63459. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63460. */
  63461. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63462. /**
  63463. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63464. * @param matrix defines the matrix to use
  63465. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63466. */
  63467. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63468. /**
  63469. * Compute the transpose of a given matrix
  63470. * @param matrix defines the matrix to transpose
  63471. * @returns the new matrix
  63472. */
  63473. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63474. /**
  63475. * Compute the transpose of a matrix and store it in a target matrix
  63476. * @param matrix defines the matrix to transpose
  63477. * @param result defines the target matrix
  63478. */
  63479. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63480. /**
  63481. * Computes a reflection matrix from a plane
  63482. * @param plane defines the reflection plane
  63483. * @returns a new matrix
  63484. */
  63485. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63486. /**
  63487. * Computes a reflection matrix from a plane
  63488. * @param plane defines the reflection plane
  63489. * @param result defines the target matrix
  63490. */
  63491. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63492. /**
  63493. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63494. * @param xaxis defines the value of the 1st axis
  63495. * @param yaxis defines the value of the 2nd axis
  63496. * @param zaxis defines the value of the 3rd axis
  63497. * @param result defines the target matrix
  63498. */
  63499. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63500. /**
  63501. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63502. * @param quat defines the quaternion to use
  63503. * @param result defines the target matrix
  63504. */
  63505. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63506. }
  63507. /**
  63508. * Represens a plane by the equation ax + by + cz + d = 0
  63509. */
  63510. export class Plane {
  63511. /**
  63512. * Normal of the plane (a,b,c)
  63513. */
  63514. normal: Vector3;
  63515. /**
  63516. * d component of the plane
  63517. */
  63518. d: number;
  63519. /**
  63520. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63521. * @param a a component of the plane
  63522. * @param b b component of the plane
  63523. * @param c c component of the plane
  63524. * @param d d component of the plane
  63525. */
  63526. constructor(a: number, b: number, c: number, d: number);
  63527. /**
  63528. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63529. */
  63530. asArray(): number[];
  63531. /**
  63532. * @returns a new plane copied from the current Plane.
  63533. */
  63534. clone(): Plane;
  63535. /**
  63536. * @returns the string "Plane".
  63537. */
  63538. getClassName(): string;
  63539. /**
  63540. * @returns the Plane hash code.
  63541. */
  63542. getHashCode(): number;
  63543. /**
  63544. * Normalize the current Plane in place.
  63545. * @returns the updated Plane.
  63546. */
  63547. normalize(): Plane;
  63548. /**
  63549. * Applies a transformation the plane and returns the result
  63550. * @param transformation the transformation matrix to be applied to the plane
  63551. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63552. */
  63553. transform(transformation: DeepImmutable<Matrix>): Plane;
  63554. /**
  63555. * Calcualtte the dot product between the point and the plane normal
  63556. * @param point point to calculate the dot product with
  63557. * @returns the dot product (float) of the point coordinates and the plane normal.
  63558. */
  63559. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63560. /**
  63561. * Updates the current Plane from the plane defined by the three given points.
  63562. * @param point1 one of the points used to contruct the plane
  63563. * @param point2 one of the points used to contruct the plane
  63564. * @param point3 one of the points used to contruct the plane
  63565. * @returns the updated Plane.
  63566. */
  63567. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63568. /**
  63569. * Checks if the plane is facing a given direction
  63570. * @param direction the direction to check if the plane is facing
  63571. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63572. * @returns True is the vector "direction" is the same side than the plane normal.
  63573. */
  63574. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63575. /**
  63576. * Calculates the distance to a point
  63577. * @param point point to calculate distance to
  63578. * @returns the signed distance (float) from the given point to the Plane.
  63579. */
  63580. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63581. /**
  63582. * Creates a plane from an array
  63583. * @param array the array to create a plane from
  63584. * @returns a new Plane from the given array.
  63585. */
  63586. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63587. /**
  63588. * Creates a plane from three points
  63589. * @param point1 point used to create the plane
  63590. * @param point2 point used to create the plane
  63591. * @param point3 point used to create the plane
  63592. * @returns a new Plane defined by the three given points.
  63593. */
  63594. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63595. /**
  63596. * Creates a plane from an origin point and a normal
  63597. * @param origin origin of the plane to be constructed
  63598. * @param normal normal of the plane to be constructed
  63599. * @returns a new Plane the normal vector to this plane at the given origin point.
  63600. * Note : the vector "normal" is updated because normalized.
  63601. */
  63602. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63603. /**
  63604. * Calculates the distance from a plane and a point
  63605. * @param origin origin of the plane to be constructed
  63606. * @param normal normal of the plane to be constructed
  63607. * @param point point to calculate distance to
  63608. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63609. */
  63610. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63611. }
  63612. /**
  63613. * Class used to represent a viewport on screen
  63614. */
  63615. export class Viewport {
  63616. /** viewport left coordinate */
  63617. x: number;
  63618. /** viewport top coordinate */
  63619. y: number;
  63620. /**viewport width */
  63621. width: number;
  63622. /** viewport height */
  63623. height: number;
  63624. /**
  63625. * Creates a Viewport object located at (x, y) and sized (width, height)
  63626. * @param x defines viewport left coordinate
  63627. * @param y defines viewport top coordinate
  63628. * @param width defines the viewport width
  63629. * @param height defines the viewport height
  63630. */
  63631. constructor(
  63632. /** viewport left coordinate */
  63633. x: number,
  63634. /** viewport top coordinate */
  63635. y: number,
  63636. /**viewport width */
  63637. width: number,
  63638. /** viewport height */
  63639. height: number);
  63640. /**
  63641. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63642. * @param renderWidth defines the rendering width
  63643. * @param renderHeight defines the rendering height
  63644. * @returns a new Viewport
  63645. */
  63646. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63647. /**
  63648. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63649. * @param renderWidth defines the rendering width
  63650. * @param renderHeight defines the rendering height
  63651. * @param ref defines the target viewport
  63652. * @returns the current viewport
  63653. */
  63654. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63655. /**
  63656. * Returns a new Viewport copied from the current one
  63657. * @returns a new Viewport
  63658. */
  63659. clone(): Viewport;
  63660. }
  63661. /**
  63662. * Reprasents a camera frustum
  63663. */
  63664. export class Frustum {
  63665. /**
  63666. * Gets the planes representing the frustum
  63667. * @param transform matrix to be applied to the returned planes
  63668. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63669. */
  63670. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63671. /**
  63672. * Gets the near frustum plane transformed by the transform matrix
  63673. * @param transform transformation matrix to be applied to the resulting frustum plane
  63674. * @param frustumPlane the resuling frustum plane
  63675. */
  63676. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63677. /**
  63678. * Gets the far frustum plane transformed by the transform matrix
  63679. * @param transform transformation matrix to be applied to the resulting frustum plane
  63680. * @param frustumPlane the resuling frustum plane
  63681. */
  63682. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63683. /**
  63684. * Gets the left frustum plane transformed by the transform matrix
  63685. * @param transform transformation matrix to be applied to the resulting frustum plane
  63686. * @param frustumPlane the resuling frustum plane
  63687. */
  63688. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63689. /**
  63690. * Gets the right frustum plane transformed by the transform matrix
  63691. * @param transform transformation matrix to be applied to the resulting frustum plane
  63692. * @param frustumPlane the resuling frustum plane
  63693. */
  63694. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63695. /**
  63696. * Gets the top frustum plane transformed by the transform matrix
  63697. * @param transform transformation matrix to be applied to the resulting frustum plane
  63698. * @param frustumPlane the resuling frustum plane
  63699. */
  63700. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63701. /**
  63702. * Gets the bottom frustum plane transformed by the transform matrix
  63703. * @param transform transformation matrix to be applied to the resulting frustum plane
  63704. * @param frustumPlane the resuling frustum plane
  63705. */
  63706. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63707. /**
  63708. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63709. * @param transform transformation matrix to be applied to the resulting frustum planes
  63710. * @param frustumPlanes the resuling frustum planes
  63711. */
  63712. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63713. }
  63714. /** Defines supported spaces */
  63715. export enum Space {
  63716. /** Local (object) space */
  63717. LOCAL = 0,
  63718. /** World space */
  63719. WORLD = 1,
  63720. /** Bone space */
  63721. BONE = 2
  63722. }
  63723. /** Defines the 3 main axes */
  63724. export class Axis {
  63725. /** X axis */
  63726. static X: Vector3;
  63727. /** Y axis */
  63728. static Y: Vector3;
  63729. /** Z axis */
  63730. static Z: Vector3;
  63731. }
  63732. /** Class used to represent a Bezier curve */
  63733. export class BezierCurve {
  63734. /**
  63735. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63736. * @param t defines the time
  63737. * @param x1 defines the left coordinate on X axis
  63738. * @param y1 defines the left coordinate on Y axis
  63739. * @param x2 defines the right coordinate on X axis
  63740. * @param y2 defines the right coordinate on Y axis
  63741. * @returns the interpolated value
  63742. */
  63743. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63744. }
  63745. /**
  63746. * Defines potential orientation for back face culling
  63747. */
  63748. export enum Orientation {
  63749. /**
  63750. * Clockwise
  63751. */
  63752. CW = 0,
  63753. /** Counter clockwise */
  63754. CCW = 1
  63755. }
  63756. /**
  63757. * Defines angle representation
  63758. */
  63759. export class Angle {
  63760. private _radians;
  63761. /**
  63762. * Creates an Angle object of "radians" radians (float).
  63763. * @param radians the angle in radians
  63764. */
  63765. constructor(radians: number);
  63766. /**
  63767. * Get value in degrees
  63768. * @returns the Angle value in degrees (float)
  63769. */
  63770. degrees(): number;
  63771. /**
  63772. * Get value in radians
  63773. * @returns the Angle value in radians (float)
  63774. */
  63775. radians(): number;
  63776. /**
  63777. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63778. * @param a defines first vector
  63779. * @param b defines second vector
  63780. * @returns a new Angle
  63781. */
  63782. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63783. /**
  63784. * Gets a new Angle object from the given float in radians
  63785. * @param radians defines the angle value in radians
  63786. * @returns a new Angle
  63787. */
  63788. static FromRadians(radians: number): Angle;
  63789. /**
  63790. * Gets a new Angle object from the given float in degrees
  63791. * @param degrees defines the angle value in degrees
  63792. * @returns a new Angle
  63793. */
  63794. static FromDegrees(degrees: number): Angle;
  63795. }
  63796. /**
  63797. * This represents an arc in a 2d space.
  63798. */
  63799. export class Arc2 {
  63800. /** Defines the start point of the arc */
  63801. startPoint: Vector2;
  63802. /** Defines the mid point of the arc */
  63803. midPoint: Vector2;
  63804. /** Defines the end point of the arc */
  63805. endPoint: Vector2;
  63806. /**
  63807. * Defines the center point of the arc.
  63808. */
  63809. centerPoint: Vector2;
  63810. /**
  63811. * Defines the radius of the arc.
  63812. */
  63813. radius: number;
  63814. /**
  63815. * Defines the angle of the arc (from mid point to end point).
  63816. */
  63817. angle: Angle;
  63818. /**
  63819. * Defines the start angle of the arc (from start point to middle point).
  63820. */
  63821. startAngle: Angle;
  63822. /**
  63823. * Defines the orientation of the arc (clock wise/counter clock wise).
  63824. */
  63825. orientation: Orientation;
  63826. /**
  63827. * Creates an Arc object from the three given points : start, middle and end.
  63828. * @param startPoint Defines the start point of the arc
  63829. * @param midPoint Defines the midlle point of the arc
  63830. * @param endPoint Defines the end point of the arc
  63831. */
  63832. constructor(
  63833. /** Defines the start point of the arc */
  63834. startPoint: Vector2,
  63835. /** Defines the mid point of the arc */
  63836. midPoint: Vector2,
  63837. /** Defines the end point of the arc */
  63838. endPoint: Vector2);
  63839. }
  63840. /**
  63841. * Represents a 2D path made up of multiple 2D points
  63842. */
  63843. export class Path2 {
  63844. private _points;
  63845. private _length;
  63846. /**
  63847. * If the path start and end point are the same
  63848. */
  63849. closed: boolean;
  63850. /**
  63851. * Creates a Path2 object from the starting 2D coordinates x and y.
  63852. * @param x the starting points x value
  63853. * @param y the starting points y value
  63854. */
  63855. constructor(x: number, y: number);
  63856. /**
  63857. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63858. * @param x the added points x value
  63859. * @param y the added points y value
  63860. * @returns the updated Path2.
  63861. */
  63862. addLineTo(x: number, y: number): Path2;
  63863. /**
  63864. * 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.
  63865. * @param midX middle point x value
  63866. * @param midY middle point y value
  63867. * @param endX end point x value
  63868. * @param endY end point y value
  63869. * @param numberOfSegments (default: 36)
  63870. * @returns the updated Path2.
  63871. */
  63872. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63873. /**
  63874. * Closes the Path2.
  63875. * @returns the Path2.
  63876. */
  63877. close(): Path2;
  63878. /**
  63879. * Gets the sum of the distance between each sequential point in the path
  63880. * @returns the Path2 total length (float).
  63881. */
  63882. length(): number;
  63883. /**
  63884. * Gets the points which construct the path
  63885. * @returns the Path2 internal array of points.
  63886. */
  63887. getPoints(): Vector2[];
  63888. /**
  63889. * Retreives the point at the distance aways from the starting point
  63890. * @param normalizedLengthPosition the length along the path to retreive the point from
  63891. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63892. */
  63893. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63894. /**
  63895. * Creates a new path starting from an x and y position
  63896. * @param x starting x value
  63897. * @param y starting y value
  63898. * @returns a new Path2 starting at the coordinates (x, y).
  63899. */
  63900. static StartingAt(x: number, y: number): Path2;
  63901. }
  63902. /**
  63903. * Represents a 3D path made up of multiple 3D points
  63904. */
  63905. export class Path3D {
  63906. /**
  63907. * an array of Vector3, the curve axis of the Path3D
  63908. */
  63909. path: Vector3[];
  63910. private _curve;
  63911. private _distances;
  63912. private _tangents;
  63913. private _normals;
  63914. private _binormals;
  63915. private _raw;
  63916. /**
  63917. * new Path3D(path, normal, raw)
  63918. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63919. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63920. * @param path an array of Vector3, the curve axis of the Path3D
  63921. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63922. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63923. */
  63924. constructor(
  63925. /**
  63926. * an array of Vector3, the curve axis of the Path3D
  63927. */
  63928. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63929. /**
  63930. * Returns the Path3D array of successive Vector3 designing its curve.
  63931. * @returns the Path3D array of successive Vector3 designing its curve.
  63932. */
  63933. getCurve(): Vector3[];
  63934. /**
  63935. * Returns an array populated with tangent vectors on each Path3D curve point.
  63936. * @returns an array populated with tangent vectors on each Path3D curve point.
  63937. */
  63938. getTangents(): Vector3[];
  63939. /**
  63940. * Returns an array populated with normal vectors on each Path3D curve point.
  63941. * @returns an array populated with normal vectors on each Path3D curve point.
  63942. */
  63943. getNormals(): Vector3[];
  63944. /**
  63945. * Returns an array populated with binormal vectors on each Path3D curve point.
  63946. * @returns an array populated with binormal vectors on each Path3D curve point.
  63947. */
  63948. getBinormals(): Vector3[];
  63949. /**
  63950. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63951. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63952. */
  63953. getDistances(): number[];
  63954. /**
  63955. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63956. * @param path path which all values are copied into the curves points
  63957. * @param firstNormal which should be projected onto the curve
  63958. * @returns the same object updated.
  63959. */
  63960. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63961. private _compute;
  63962. private _getFirstNonNullVector;
  63963. private _getLastNonNullVector;
  63964. private _normalVector;
  63965. }
  63966. /**
  63967. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63968. * A Curve3 is designed from a series of successive Vector3.
  63969. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63970. */
  63971. export class Curve3 {
  63972. private _points;
  63973. private _length;
  63974. /**
  63975. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63976. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63977. * @param v1 (Vector3) the control point
  63978. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63979. * @param nbPoints (integer) the wanted number of points in the curve
  63980. * @returns the created Curve3
  63981. */
  63982. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63983. /**
  63984. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63985. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63986. * @param v1 (Vector3) the first control point
  63987. * @param v2 (Vector3) the second control point
  63988. * @param v3 (Vector3) the end point of the Cubic Bezier
  63989. * @param nbPoints (integer) the wanted number of points in the curve
  63990. * @returns the created Curve3
  63991. */
  63992. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63993. /**
  63994. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63995. * @param p1 (Vector3) the origin point of the Hermite Spline
  63996. * @param t1 (Vector3) the tangent vector at the origin point
  63997. * @param p2 (Vector3) the end point of the Hermite Spline
  63998. * @param t2 (Vector3) the tangent vector at the end point
  63999. * @param nbPoints (integer) the wanted number of points in the curve
  64000. * @returns the created Curve3
  64001. */
  64002. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64003. /**
  64004. * Returns a Curve3 object along a CatmullRom Spline curve :
  64005. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  64006. * @param nbPoints (integer) the wanted number of points between each curve control points
  64007. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  64008. * @returns the created Curve3
  64009. */
  64010. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  64011. /**
  64012. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64013. * A Curve3 is designed from a series of successive Vector3.
  64014. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  64015. * @param points points which make up the curve
  64016. */
  64017. constructor(points: Vector3[]);
  64018. /**
  64019. * @returns the Curve3 stored array of successive Vector3
  64020. */
  64021. getPoints(): Vector3[];
  64022. /**
  64023. * @returns the computed length (float) of the curve.
  64024. */
  64025. length(): number;
  64026. /**
  64027. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  64028. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  64029. * curveA and curveB keep unchanged.
  64030. * @param curve the curve to continue from this curve
  64031. * @returns the newly constructed curve
  64032. */
  64033. continue(curve: DeepImmutable<Curve3>): Curve3;
  64034. private _computeLength;
  64035. }
  64036. /**
  64037. * Contains position and normal vectors for a vertex
  64038. */
  64039. export class PositionNormalVertex {
  64040. /** the position of the vertex (defaut: 0,0,0) */
  64041. position: Vector3;
  64042. /** the normal of the vertex (defaut: 0,1,0) */
  64043. normal: Vector3;
  64044. /**
  64045. * Creates a PositionNormalVertex
  64046. * @param position the position of the vertex (defaut: 0,0,0)
  64047. * @param normal the normal of the vertex (defaut: 0,1,0)
  64048. */
  64049. constructor(
  64050. /** the position of the vertex (defaut: 0,0,0) */
  64051. position?: Vector3,
  64052. /** the normal of the vertex (defaut: 0,1,0) */
  64053. normal?: Vector3);
  64054. /**
  64055. * Clones the PositionNormalVertex
  64056. * @returns the cloned PositionNormalVertex
  64057. */
  64058. clone(): PositionNormalVertex;
  64059. }
  64060. /**
  64061. * Contains position, normal and uv vectors for a vertex
  64062. */
  64063. export class PositionNormalTextureVertex {
  64064. /** the position of the vertex (defaut: 0,0,0) */
  64065. position: Vector3;
  64066. /** the normal of the vertex (defaut: 0,1,0) */
  64067. normal: Vector3;
  64068. /** the uv of the vertex (default: 0,0) */
  64069. uv: Vector2;
  64070. /**
  64071. * Creates a PositionNormalTextureVertex
  64072. * @param position the position of the vertex (defaut: 0,0,0)
  64073. * @param normal the normal of the vertex (defaut: 0,1,0)
  64074. * @param uv the uv of the vertex (default: 0,0)
  64075. */
  64076. constructor(
  64077. /** the position of the vertex (defaut: 0,0,0) */
  64078. position?: Vector3,
  64079. /** the normal of the vertex (defaut: 0,1,0) */
  64080. normal?: Vector3,
  64081. /** the uv of the vertex (default: 0,0) */
  64082. uv?: Vector2);
  64083. /**
  64084. * Clones the PositionNormalTextureVertex
  64085. * @returns the cloned PositionNormalTextureVertex
  64086. */
  64087. clone(): PositionNormalTextureVertex;
  64088. }
  64089. /**
  64090. * @hidden
  64091. */
  64092. export class Tmp {
  64093. static Color3: Color3[];
  64094. static Color4: Color4[];
  64095. static Vector2: Vector2[];
  64096. static Vector3: Vector3[];
  64097. static Vector4: Vector4[];
  64098. static Quaternion: Quaternion[];
  64099. static Matrix: Matrix[];
  64100. }
  64101. }
  64102. declare module BABYLON {
  64103. /**
  64104. * Class used to enable access to offline support
  64105. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64106. */
  64107. export interface IOfflineProvider {
  64108. /**
  64109. * Gets a boolean indicating if scene must be saved in the database
  64110. */
  64111. enableSceneOffline: boolean;
  64112. /**
  64113. * Gets a boolean indicating if textures must be saved in the database
  64114. */
  64115. enableTexturesOffline: boolean;
  64116. /**
  64117. * Open the offline support and make it available
  64118. * @param successCallback defines the callback to call on success
  64119. * @param errorCallback defines the callback to call on error
  64120. */
  64121. open(successCallback: () => void, errorCallback: () => void): void;
  64122. /**
  64123. * Loads an image from the offline support
  64124. * @param url defines the url to load from
  64125. * @param image defines the target DOM image
  64126. */
  64127. loadImage(url: string, image: HTMLImageElement): void;
  64128. /**
  64129. * Loads a file from offline support
  64130. * @param url defines the URL to load from
  64131. * @param sceneLoaded defines a callback to call on success
  64132. * @param progressCallBack defines a callback to call when progress changed
  64133. * @param errorCallback defines a callback to call on error
  64134. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64135. */
  64136. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64137. }
  64138. }
  64139. declare module BABYLON {
  64140. /**
  64141. * A class serves as a medium between the observable and its observers
  64142. */
  64143. export class EventState {
  64144. /**
  64145. * Create a new EventState
  64146. * @param mask defines the mask associated with this state
  64147. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64148. * @param target defines the original target of the state
  64149. * @param currentTarget defines the current target of the state
  64150. */
  64151. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64152. /**
  64153. * Initialize the current event state
  64154. * @param mask defines the mask associated with this state
  64155. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64156. * @param target defines the original target of the state
  64157. * @param currentTarget defines the current target of the state
  64158. * @returns the current event state
  64159. */
  64160. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64161. /**
  64162. * An Observer can set this property to true to prevent subsequent observers of being notified
  64163. */
  64164. skipNextObservers: boolean;
  64165. /**
  64166. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64167. */
  64168. mask: number;
  64169. /**
  64170. * The object that originally notified the event
  64171. */
  64172. target?: any;
  64173. /**
  64174. * The current object in the bubbling phase
  64175. */
  64176. currentTarget?: any;
  64177. /**
  64178. * This will be populated with the return value of the last function that was executed.
  64179. * If it is the first function in the callback chain it will be the event data.
  64180. */
  64181. lastReturnValue?: any;
  64182. }
  64183. /**
  64184. * Represent an Observer registered to a given Observable object.
  64185. */
  64186. export class Observer<T> {
  64187. /**
  64188. * Defines the callback to call when the observer is notified
  64189. */
  64190. callback: (eventData: T, eventState: EventState) => void;
  64191. /**
  64192. * Defines the mask of the observer (used to filter notifications)
  64193. */
  64194. mask: number;
  64195. /**
  64196. * Defines the current scope used to restore the JS context
  64197. */
  64198. scope: any;
  64199. /** @hidden */
  64200. _willBeUnregistered: boolean;
  64201. /**
  64202. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64203. */
  64204. unregisterOnNextCall: boolean;
  64205. /**
  64206. * Creates a new observer
  64207. * @param callback defines the callback to call when the observer is notified
  64208. * @param mask defines the mask of the observer (used to filter notifications)
  64209. * @param scope defines the current scope used to restore the JS context
  64210. */
  64211. constructor(
  64212. /**
  64213. * Defines the callback to call when the observer is notified
  64214. */
  64215. callback: (eventData: T, eventState: EventState) => void,
  64216. /**
  64217. * Defines the mask of the observer (used to filter notifications)
  64218. */
  64219. mask: number,
  64220. /**
  64221. * Defines the current scope used to restore the JS context
  64222. */
  64223. scope?: any);
  64224. }
  64225. /**
  64226. * Represent a list of observers registered to multiple Observables object.
  64227. */
  64228. export class MultiObserver<T> {
  64229. private _observers;
  64230. private _observables;
  64231. /**
  64232. * Release associated resources
  64233. */
  64234. dispose(): void;
  64235. /**
  64236. * Raise a callback when one of the observable will notify
  64237. * @param observables defines a list of observables to watch
  64238. * @param callback defines the callback to call on notification
  64239. * @param mask defines the mask used to filter notifications
  64240. * @param scope defines the current scope used to restore the JS context
  64241. * @returns the new MultiObserver
  64242. */
  64243. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64244. }
  64245. /**
  64246. * The Observable class is a simple implementation of the Observable pattern.
  64247. *
  64248. * 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.
  64249. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64250. * 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).
  64251. * 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.
  64252. */
  64253. export class Observable<T> {
  64254. private _observers;
  64255. private _eventState;
  64256. private _onObserverAdded;
  64257. /**
  64258. * Creates a new observable
  64259. * @param onObserverAdded defines a callback to call when a new observer is added
  64260. */
  64261. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64262. /**
  64263. * Create a new Observer with the specified callback
  64264. * @param callback the callback that will be executed for that Observer
  64265. * @param mask the mask used to filter observers
  64266. * @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.
  64267. * @param scope optional scope for the callback to be called from
  64268. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64269. * @returns the new observer created for the callback
  64270. */
  64271. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64272. /**
  64273. * Create a new Observer with the specified callback and unregisters after the next notification
  64274. * @param callback the callback that will be executed for that Observer
  64275. * @returns the new observer created for the callback
  64276. */
  64277. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64278. /**
  64279. * Remove an Observer from the Observable object
  64280. * @param observer the instance of the Observer to remove
  64281. * @returns false if it doesn't belong to this Observable
  64282. */
  64283. remove(observer: Nullable<Observer<T>>): boolean;
  64284. /**
  64285. * Remove a callback from the Observable object
  64286. * @param callback the callback to remove
  64287. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64288. * @returns false if it doesn't belong to this Observable
  64289. */
  64290. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64291. private _deferUnregister;
  64292. private _remove;
  64293. /**
  64294. * Moves the observable to the top of the observer list making it get called first when notified
  64295. * @param observer the observer to move
  64296. */
  64297. makeObserverTopPriority(observer: Observer<T>): void;
  64298. /**
  64299. * Moves the observable to the bottom of the observer list making it get called last when notified
  64300. * @param observer the observer to move
  64301. */
  64302. makeObserverBottomPriority(observer: Observer<T>): void;
  64303. /**
  64304. * Notify all Observers by calling their respective callback with the given data
  64305. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64306. * @param eventData defines the data to send to all observers
  64307. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64308. * @param target defines the original target of the state
  64309. * @param currentTarget defines the current target of the state
  64310. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64311. */
  64312. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64313. /**
  64314. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64315. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64316. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64317. * and it is crucial that all callbacks will be executed.
  64318. * The order of the callbacks is kept, callbacks are not executed parallel.
  64319. *
  64320. * @param eventData The data to be sent to each callback
  64321. * @param mask is used to filter observers defaults to -1
  64322. * @param target defines the callback target (see EventState)
  64323. * @param currentTarget defines he current object in the bubbling phase
  64324. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64325. */
  64326. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64327. /**
  64328. * Notify a specific observer
  64329. * @param observer defines the observer to notify
  64330. * @param eventData defines the data to be sent to each callback
  64331. * @param mask is used to filter observers defaults to -1
  64332. */
  64333. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64334. /**
  64335. * Gets a boolean indicating if the observable has at least one observer
  64336. * @returns true is the Observable has at least one Observer registered
  64337. */
  64338. hasObservers(): boolean;
  64339. /**
  64340. * Clear the list of observers
  64341. */
  64342. clear(): void;
  64343. /**
  64344. * Clone the current observable
  64345. * @returns a new observable
  64346. */
  64347. clone(): Observable<T>;
  64348. /**
  64349. * Does this observable handles observer registered with a given mask
  64350. * @param mask defines the mask to be tested
  64351. * @return whether or not one observer registered with the given mask is handeled
  64352. **/
  64353. hasSpecificMask(mask?: number): boolean;
  64354. }
  64355. }
  64356. declare module BABYLON {
  64357. /**
  64358. * Class used to help managing file picking and drag'n'drop
  64359. * File Storage
  64360. */
  64361. export class FilesInputStore {
  64362. /**
  64363. * List of files ready to be loaded
  64364. */
  64365. static FilesToLoad: {
  64366. [key: string]: File;
  64367. };
  64368. }
  64369. }
  64370. declare module BABYLON {
  64371. /** Defines the cross module used constants to avoid circular dependncies */
  64372. export class Constants {
  64373. /** Defines that alpha blending is disabled */
  64374. static readonly ALPHA_DISABLE: number;
  64375. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64376. static readonly ALPHA_ADD: number;
  64377. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64378. static readonly ALPHA_COMBINE: number;
  64379. /** Defines that alpha blending to DEST - SRC * DEST */
  64380. static readonly ALPHA_SUBTRACT: number;
  64381. /** Defines that alpha blending to SRC * DEST */
  64382. static readonly ALPHA_MULTIPLY: number;
  64383. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64384. static readonly ALPHA_MAXIMIZED: number;
  64385. /** Defines that alpha blending to SRC + DEST */
  64386. static readonly ALPHA_ONEONE: number;
  64387. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64388. static readonly ALPHA_PREMULTIPLIED: number;
  64389. /**
  64390. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64391. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64392. */
  64393. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64394. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64395. static readonly ALPHA_INTERPOLATE: number;
  64396. /**
  64397. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64398. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64399. */
  64400. static readonly ALPHA_SCREENMODE: number;
  64401. /** Defines that the ressource is not delayed*/
  64402. static readonly DELAYLOADSTATE_NONE: number;
  64403. /** Defines that the ressource was successfully delay loaded */
  64404. static readonly DELAYLOADSTATE_LOADED: number;
  64405. /** Defines that the ressource is currently delay loading */
  64406. static readonly DELAYLOADSTATE_LOADING: number;
  64407. /** Defines that the ressource is delayed and has not started loading */
  64408. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64409. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64410. static readonly NEVER: number;
  64411. /** 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 */
  64412. static readonly ALWAYS: number;
  64413. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64414. static readonly LESS: number;
  64415. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64416. static readonly EQUAL: number;
  64417. /** 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 */
  64418. static readonly LEQUAL: number;
  64419. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64420. static readonly GREATER: number;
  64421. /** 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 */
  64422. static readonly GEQUAL: number;
  64423. /** 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 */
  64424. static readonly NOTEQUAL: number;
  64425. /** Passed to stencilOperation to specify that stencil value must be kept */
  64426. static readonly KEEP: number;
  64427. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64428. static readonly REPLACE: number;
  64429. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64430. static readonly INCR: number;
  64431. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64432. static readonly DECR: number;
  64433. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64434. static readonly INVERT: number;
  64435. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64436. static readonly INCR_WRAP: number;
  64437. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64438. static readonly DECR_WRAP: number;
  64439. /** Texture is not repeating outside of 0..1 UVs */
  64440. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64441. /** Texture is repeating outside of 0..1 UVs */
  64442. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64443. /** Texture is repeating and mirrored */
  64444. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64445. /** ALPHA */
  64446. static readonly TEXTUREFORMAT_ALPHA: number;
  64447. /** LUMINANCE */
  64448. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64449. /** LUMINANCE_ALPHA */
  64450. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64451. /** RGB */
  64452. static readonly TEXTUREFORMAT_RGB: number;
  64453. /** RGBA */
  64454. static readonly TEXTUREFORMAT_RGBA: number;
  64455. /** RED */
  64456. static readonly TEXTUREFORMAT_RED: number;
  64457. /** RED (2nd reference) */
  64458. static readonly TEXTUREFORMAT_R: number;
  64459. /** RG */
  64460. static readonly TEXTUREFORMAT_RG: number;
  64461. /** RED_INTEGER */
  64462. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64463. /** RED_INTEGER (2nd reference) */
  64464. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64465. /** RG_INTEGER */
  64466. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64467. /** RGB_INTEGER */
  64468. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64469. /** RGBA_INTEGER */
  64470. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64471. /** UNSIGNED_BYTE */
  64472. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64473. /** UNSIGNED_BYTE (2nd reference) */
  64474. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64475. /** FLOAT */
  64476. static readonly TEXTURETYPE_FLOAT: number;
  64477. /** HALF_FLOAT */
  64478. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64479. /** BYTE */
  64480. static readonly TEXTURETYPE_BYTE: number;
  64481. /** SHORT */
  64482. static readonly TEXTURETYPE_SHORT: number;
  64483. /** UNSIGNED_SHORT */
  64484. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64485. /** INT */
  64486. static readonly TEXTURETYPE_INT: number;
  64487. /** UNSIGNED_INT */
  64488. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64489. /** UNSIGNED_SHORT_4_4_4_4 */
  64490. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64491. /** UNSIGNED_SHORT_5_5_5_1 */
  64492. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64493. /** UNSIGNED_SHORT_5_6_5 */
  64494. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64495. /** UNSIGNED_INT_2_10_10_10_REV */
  64496. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64497. /** UNSIGNED_INT_24_8 */
  64498. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64499. /** UNSIGNED_INT_10F_11F_11F_REV */
  64500. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64501. /** UNSIGNED_INT_5_9_9_9_REV */
  64502. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64503. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64504. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64505. /** nearest is mag = nearest and min = nearest and mip = linear */
  64506. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64507. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64508. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64509. /** Trilinear is mag = linear and min = linear and mip = linear */
  64510. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64511. /** nearest is mag = nearest and min = nearest and mip = linear */
  64512. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64513. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64514. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64515. /** Trilinear is mag = linear and min = linear and mip = linear */
  64516. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64517. /** mag = nearest and min = nearest and mip = nearest */
  64518. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64519. /** mag = nearest and min = linear and mip = nearest */
  64520. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64521. /** mag = nearest and min = linear and mip = linear */
  64522. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64523. /** mag = nearest and min = linear and mip = none */
  64524. static readonly TEXTURE_NEAREST_LINEAR: number;
  64525. /** mag = nearest and min = nearest and mip = none */
  64526. static readonly TEXTURE_NEAREST_NEAREST: number;
  64527. /** mag = linear and min = nearest and mip = nearest */
  64528. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64529. /** mag = linear and min = nearest and mip = linear */
  64530. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64531. /** mag = linear and min = linear and mip = none */
  64532. static readonly TEXTURE_LINEAR_LINEAR: number;
  64533. /** mag = linear and min = nearest and mip = none */
  64534. static readonly TEXTURE_LINEAR_NEAREST: number;
  64535. /** Explicit coordinates mode */
  64536. static readonly TEXTURE_EXPLICIT_MODE: number;
  64537. /** Spherical coordinates mode */
  64538. static readonly TEXTURE_SPHERICAL_MODE: number;
  64539. /** Planar coordinates mode */
  64540. static readonly TEXTURE_PLANAR_MODE: number;
  64541. /** Cubic coordinates mode */
  64542. static readonly TEXTURE_CUBIC_MODE: number;
  64543. /** Projection coordinates mode */
  64544. static readonly TEXTURE_PROJECTION_MODE: number;
  64545. /** Skybox coordinates mode */
  64546. static readonly TEXTURE_SKYBOX_MODE: number;
  64547. /** Inverse Cubic coordinates mode */
  64548. static readonly TEXTURE_INVCUBIC_MODE: number;
  64549. /** Equirectangular coordinates mode */
  64550. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64551. /** Equirectangular Fixed coordinates mode */
  64552. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64553. /** Equirectangular Fixed Mirrored coordinates mode */
  64554. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64555. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64556. static readonly SCALEMODE_FLOOR: number;
  64557. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64558. static readonly SCALEMODE_NEAREST: number;
  64559. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64560. static readonly SCALEMODE_CEILING: number;
  64561. /**
  64562. * The dirty texture flag value
  64563. */
  64564. static readonly MATERIAL_TextureDirtyFlag: number;
  64565. /**
  64566. * The dirty light flag value
  64567. */
  64568. static readonly MATERIAL_LightDirtyFlag: number;
  64569. /**
  64570. * The dirty fresnel flag value
  64571. */
  64572. static readonly MATERIAL_FresnelDirtyFlag: number;
  64573. /**
  64574. * The dirty attribute flag value
  64575. */
  64576. static readonly MATERIAL_AttributesDirtyFlag: number;
  64577. /**
  64578. * The dirty misc flag value
  64579. */
  64580. static readonly MATERIAL_MiscDirtyFlag: number;
  64581. /**
  64582. * The all dirty flag value
  64583. */
  64584. static readonly MATERIAL_AllDirtyFlag: number;
  64585. /**
  64586. * Returns the triangle fill mode
  64587. */
  64588. static readonly MATERIAL_TriangleFillMode: number;
  64589. /**
  64590. * Returns the wireframe mode
  64591. */
  64592. static readonly MATERIAL_WireFrameFillMode: number;
  64593. /**
  64594. * Returns the point fill mode
  64595. */
  64596. static readonly MATERIAL_PointFillMode: number;
  64597. /**
  64598. * Returns the point list draw mode
  64599. */
  64600. static readonly MATERIAL_PointListDrawMode: number;
  64601. /**
  64602. * Returns the line list draw mode
  64603. */
  64604. static readonly MATERIAL_LineListDrawMode: number;
  64605. /**
  64606. * Returns the line loop draw mode
  64607. */
  64608. static readonly MATERIAL_LineLoopDrawMode: number;
  64609. /**
  64610. * Returns the line strip draw mode
  64611. */
  64612. static readonly MATERIAL_LineStripDrawMode: number;
  64613. /**
  64614. * Returns the triangle strip draw mode
  64615. */
  64616. static readonly MATERIAL_TriangleStripDrawMode: number;
  64617. /**
  64618. * Returns the triangle fan draw mode
  64619. */
  64620. static readonly MATERIAL_TriangleFanDrawMode: number;
  64621. /**
  64622. * Stores the clock-wise side orientation
  64623. */
  64624. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64625. /**
  64626. * Stores the counter clock-wise side orientation
  64627. */
  64628. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64629. /**
  64630. * Nothing
  64631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64632. */
  64633. static readonly ACTION_NothingTrigger: number;
  64634. /**
  64635. * On pick
  64636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64637. */
  64638. static readonly ACTION_OnPickTrigger: number;
  64639. /**
  64640. * On left pick
  64641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64642. */
  64643. static readonly ACTION_OnLeftPickTrigger: number;
  64644. /**
  64645. * On right pick
  64646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64647. */
  64648. static readonly ACTION_OnRightPickTrigger: number;
  64649. /**
  64650. * On center pick
  64651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64652. */
  64653. static readonly ACTION_OnCenterPickTrigger: number;
  64654. /**
  64655. * On pick down
  64656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64657. */
  64658. static readonly ACTION_OnPickDownTrigger: number;
  64659. /**
  64660. * On double pick
  64661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64662. */
  64663. static readonly ACTION_OnDoublePickTrigger: number;
  64664. /**
  64665. * On pick up
  64666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64667. */
  64668. static readonly ACTION_OnPickUpTrigger: number;
  64669. /**
  64670. * On pick out.
  64671. * This trigger will only be raised if you also declared a OnPickDown
  64672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64673. */
  64674. static readonly ACTION_OnPickOutTrigger: number;
  64675. /**
  64676. * On long press
  64677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64678. */
  64679. static readonly ACTION_OnLongPressTrigger: number;
  64680. /**
  64681. * On pointer over
  64682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64683. */
  64684. static readonly ACTION_OnPointerOverTrigger: number;
  64685. /**
  64686. * On pointer out
  64687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64688. */
  64689. static readonly ACTION_OnPointerOutTrigger: number;
  64690. /**
  64691. * On every frame
  64692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64693. */
  64694. static readonly ACTION_OnEveryFrameTrigger: number;
  64695. /**
  64696. * On intersection enter
  64697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64698. */
  64699. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64700. /**
  64701. * On intersection exit
  64702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64703. */
  64704. static readonly ACTION_OnIntersectionExitTrigger: number;
  64705. /**
  64706. * On key down
  64707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64708. */
  64709. static readonly ACTION_OnKeyDownTrigger: number;
  64710. /**
  64711. * On key up
  64712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64713. */
  64714. static readonly ACTION_OnKeyUpTrigger: number;
  64715. /**
  64716. * Billboard mode will only apply to Y axis
  64717. */
  64718. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64719. /**
  64720. * Billboard mode will apply to all axes
  64721. */
  64722. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64723. /**
  64724. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64725. */
  64726. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64727. /**
  64728. * Gets or sets base Assets URL
  64729. */
  64730. static readonly PARTICLES_BaseAssetsUrl: string;
  64731. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64732. * Test order :
  64733. * Is the bounding sphere outside the frustum ?
  64734. * If not, are the bounding box vertices outside the frustum ?
  64735. * It not, then the cullable object is in the frustum.
  64736. */
  64737. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64738. /** Culling strategy : Bounding Sphere Only.
  64739. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64740. * It's also less accurate than the standard because some not visible objects can still be selected.
  64741. * Test : is the bounding sphere outside the frustum ?
  64742. * If not, then the cullable object is in the frustum.
  64743. */
  64744. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64745. /** Culling strategy : Optimistic Inclusion.
  64746. * This in an inclusion test first, then the standard exclusion test.
  64747. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64748. * 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.
  64749. * Anyway, it's as accurate as the standard strategy.
  64750. * Test :
  64751. * Is the cullable object bounding sphere center in the frustum ?
  64752. * If not, apply the default culling strategy.
  64753. */
  64754. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64755. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64756. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64757. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64758. * 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.
  64759. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64760. * Test :
  64761. * Is the cullable object bounding sphere center in the frustum ?
  64762. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64763. */
  64764. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64765. /**
  64766. * No logging while loading
  64767. */
  64768. static readonly SCENELOADER_NO_LOGGING: number;
  64769. /**
  64770. * Minimal logging while loading
  64771. */
  64772. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64773. /**
  64774. * Summary logging while loading
  64775. */
  64776. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64777. /**
  64778. * Detailled logging while loading
  64779. */
  64780. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64781. }
  64782. }
  64783. declare module BABYLON {
  64784. /**
  64785. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64786. * Babylon.js
  64787. */
  64788. export class DomManagement {
  64789. /**
  64790. * Checks if the window object exists
  64791. * @returns true if the window object exists
  64792. */
  64793. static IsWindowObjectExist(): boolean;
  64794. /**
  64795. * Extracts text content from a DOM element hierarchy
  64796. * @param element defines the root element
  64797. * @returns a string
  64798. */
  64799. static GetDOMTextContent(element: HTMLElement): string;
  64800. }
  64801. }
  64802. declare module BABYLON {
  64803. /**
  64804. * Logger used througouht the application to allow configuration of
  64805. * the log level required for the messages.
  64806. */
  64807. export class Logger {
  64808. /**
  64809. * No log
  64810. */
  64811. static readonly NoneLogLevel: number;
  64812. /**
  64813. * Only message logs
  64814. */
  64815. static readonly MessageLogLevel: number;
  64816. /**
  64817. * Only warning logs
  64818. */
  64819. static readonly WarningLogLevel: number;
  64820. /**
  64821. * Only error logs
  64822. */
  64823. static readonly ErrorLogLevel: number;
  64824. /**
  64825. * All logs
  64826. */
  64827. static readonly AllLogLevel: number;
  64828. private static _LogCache;
  64829. /**
  64830. * Gets a value indicating the number of loading errors
  64831. * @ignorenaming
  64832. */
  64833. static errorsCount: number;
  64834. /**
  64835. * Callback called when a new log is added
  64836. */
  64837. static OnNewCacheEntry: (entry: string) => void;
  64838. private static _AddLogEntry;
  64839. private static _FormatMessage;
  64840. private static _LogDisabled;
  64841. private static _LogEnabled;
  64842. private static _WarnDisabled;
  64843. private static _WarnEnabled;
  64844. private static _ErrorDisabled;
  64845. private static _ErrorEnabled;
  64846. /**
  64847. * Log a message to the console
  64848. */
  64849. static Log: (message: string) => void;
  64850. /**
  64851. * Write a warning message to the console
  64852. */
  64853. static Warn: (message: string) => void;
  64854. /**
  64855. * Write an error message to the console
  64856. */
  64857. static Error: (message: string) => void;
  64858. /**
  64859. * Gets current log cache (list of logs)
  64860. */
  64861. static readonly LogCache: string;
  64862. /**
  64863. * Clears the log cache
  64864. */
  64865. static ClearLogCache(): void;
  64866. /**
  64867. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64868. */
  64869. static LogLevels: number;
  64870. }
  64871. }
  64872. declare module BABYLON {
  64873. /** @hidden */
  64874. export class _TypeStore {
  64875. /** @hidden */
  64876. static RegisteredTypes: {
  64877. [key: string]: Object;
  64878. };
  64879. /** @hidden */
  64880. static GetClass(fqdn: string): any;
  64881. }
  64882. }
  64883. declare module BABYLON {
  64884. /**
  64885. * Class containing a set of static utilities functions for deep copy.
  64886. */
  64887. export class DeepCopier {
  64888. /**
  64889. * Tries to copy an object by duplicating every property
  64890. * @param source defines the source object
  64891. * @param destination defines the target object
  64892. * @param doNotCopyList defines a list of properties to avoid
  64893. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64894. */
  64895. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64896. }
  64897. }
  64898. declare module BABYLON {
  64899. /**
  64900. * Class containing a set of static utilities functions for precision date
  64901. */
  64902. export class PrecisionDate {
  64903. /**
  64904. * Gets either window.performance.now() if supported or Date.now() else
  64905. */
  64906. static readonly Now: number;
  64907. }
  64908. }
  64909. declare module BABYLON {
  64910. /** @hidden */
  64911. export class _DevTools {
  64912. static WarnImport(name: string): string;
  64913. }
  64914. }
  64915. declare module BABYLON {
  64916. /**
  64917. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64918. */
  64919. export class WebRequest {
  64920. private _xhr;
  64921. /**
  64922. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64923. * i.e. when loading files, where the server/service expects an Authorization header
  64924. */
  64925. static CustomRequestHeaders: {
  64926. [key: string]: string;
  64927. };
  64928. /**
  64929. * Add callback functions in this array to update all the requests before they get sent to the network
  64930. */
  64931. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64932. private _injectCustomRequestHeaders;
  64933. /**
  64934. * Gets or sets a function to be called when loading progress changes
  64935. */
  64936. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64937. /**
  64938. * Returns client's state
  64939. */
  64940. readonly readyState: number;
  64941. /**
  64942. * Returns client's status
  64943. */
  64944. readonly status: number;
  64945. /**
  64946. * Returns client's status as a text
  64947. */
  64948. readonly statusText: string;
  64949. /**
  64950. * Returns client's response
  64951. */
  64952. readonly response: any;
  64953. /**
  64954. * Returns client's response url
  64955. */
  64956. readonly responseURL: string;
  64957. /**
  64958. * Returns client's response as text
  64959. */
  64960. readonly responseText: string;
  64961. /**
  64962. * Gets or sets the expected response type
  64963. */
  64964. responseType: XMLHttpRequestResponseType;
  64965. /** @hidden */
  64966. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64967. /** @hidden */
  64968. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64969. /**
  64970. * Cancels any network activity
  64971. */
  64972. abort(): void;
  64973. /**
  64974. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64975. * @param body defines an optional request body
  64976. */
  64977. send(body?: Document | BodyInit | null): void;
  64978. /**
  64979. * Sets the request method, request URL
  64980. * @param method defines the method to use (GET, POST, etc..)
  64981. * @param url defines the url to connect with
  64982. */
  64983. open(method: string, url: string): void;
  64984. }
  64985. }
  64986. declare module BABYLON {
  64987. /**
  64988. * Class used to evalaute queries containing `and` and `or` operators
  64989. */
  64990. export class AndOrNotEvaluator {
  64991. /**
  64992. * Evaluate a query
  64993. * @param query defines the query to evaluate
  64994. * @param evaluateCallback defines the callback used to filter result
  64995. * @returns true if the query matches
  64996. */
  64997. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64998. private static _HandleParenthesisContent;
  64999. private static _SimplifyNegation;
  65000. }
  65001. }
  65002. declare module BABYLON {
  65003. /**
  65004. * Class used to store custom tags
  65005. */
  65006. export class Tags {
  65007. /**
  65008. * Adds support for tags on the given object
  65009. * @param obj defines the object to use
  65010. */
  65011. static EnableFor(obj: any): void;
  65012. /**
  65013. * Removes tags support
  65014. * @param obj defines the object to use
  65015. */
  65016. static DisableFor(obj: any): void;
  65017. /**
  65018. * Gets a boolean indicating if the given object has tags
  65019. * @param obj defines the object to use
  65020. * @returns a boolean
  65021. */
  65022. static HasTags(obj: any): boolean;
  65023. /**
  65024. * Gets the tags available on a given object
  65025. * @param obj defines the object to use
  65026. * @param asString defines if the tags must be returned as a string instead of an array of strings
  65027. * @returns the tags
  65028. */
  65029. static GetTags(obj: any, asString?: boolean): any;
  65030. /**
  65031. * Adds tags to an object
  65032. * @param obj defines the object to use
  65033. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  65034. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  65035. */
  65036. static AddTagsTo(obj: any, tagsString: string): void;
  65037. /**
  65038. * @hidden
  65039. */
  65040. static _AddTagTo(obj: any, tag: string): void;
  65041. /**
  65042. * Removes specific tags from a specific object
  65043. * @param obj defines the object to use
  65044. * @param tagsString defines the tags to remove
  65045. */
  65046. static RemoveTagsFrom(obj: any, tagsString: string): void;
  65047. /**
  65048. * @hidden
  65049. */
  65050. static _RemoveTagFrom(obj: any, tag: string): void;
  65051. /**
  65052. * Defines if tags hosted on an object match a given query
  65053. * @param obj defines the object to use
  65054. * @param tagsQuery defines the tag query
  65055. * @returns a boolean
  65056. */
  65057. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  65058. }
  65059. }
  65060. declare module BABYLON {
  65061. /**
  65062. * Manages the defines for the Material
  65063. */
  65064. export class MaterialDefines {
  65065. private _keys;
  65066. private _isDirty;
  65067. /** @hidden */
  65068. _renderId: number;
  65069. /** @hidden */
  65070. _areLightsDirty: boolean;
  65071. /** @hidden */
  65072. _areAttributesDirty: boolean;
  65073. /** @hidden */
  65074. _areTexturesDirty: boolean;
  65075. /** @hidden */
  65076. _areFresnelDirty: boolean;
  65077. /** @hidden */
  65078. _areMiscDirty: boolean;
  65079. /** @hidden */
  65080. _areImageProcessingDirty: boolean;
  65081. /** @hidden */
  65082. _normals: boolean;
  65083. /** @hidden */
  65084. _uvs: boolean;
  65085. /** @hidden */
  65086. _needNormals: boolean;
  65087. /** @hidden */
  65088. _needUVs: boolean;
  65089. /**
  65090. * Specifies if the material needs to be re-calculated
  65091. */
  65092. readonly isDirty: boolean;
  65093. /**
  65094. * Marks the material to indicate that it has been re-calculated
  65095. */
  65096. markAsProcessed(): void;
  65097. /**
  65098. * Marks the material to indicate that it needs to be re-calculated
  65099. */
  65100. markAsUnprocessed(): void;
  65101. /**
  65102. * Marks the material to indicate all of its defines need to be re-calculated
  65103. */
  65104. markAllAsDirty(): void;
  65105. /**
  65106. * Marks the material to indicate that image processing needs to be re-calculated
  65107. */
  65108. markAsImageProcessingDirty(): void;
  65109. /**
  65110. * Marks the material to indicate the lights need to be re-calculated
  65111. */
  65112. markAsLightDirty(): void;
  65113. /**
  65114. * Marks the attribute state as changed
  65115. */
  65116. markAsAttributesDirty(): void;
  65117. /**
  65118. * Marks the texture state as changed
  65119. */
  65120. markAsTexturesDirty(): void;
  65121. /**
  65122. * Marks the fresnel state as changed
  65123. */
  65124. markAsFresnelDirty(): void;
  65125. /**
  65126. * Marks the misc state as changed
  65127. */
  65128. markAsMiscDirty(): void;
  65129. /**
  65130. * Rebuilds the material defines
  65131. */
  65132. rebuild(): void;
  65133. /**
  65134. * Specifies if two material defines are equal
  65135. * @param other - A material define instance to compare to
  65136. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65137. */
  65138. isEqual(other: MaterialDefines): boolean;
  65139. /**
  65140. * Clones this instance's defines to another instance
  65141. * @param other - material defines to clone values to
  65142. */
  65143. cloneTo(other: MaterialDefines): void;
  65144. /**
  65145. * Resets the material define values
  65146. */
  65147. reset(): void;
  65148. /**
  65149. * Converts the material define values to a string
  65150. * @returns - String of material define information
  65151. */
  65152. toString(): string;
  65153. }
  65154. }
  65155. declare module BABYLON {
  65156. /**
  65157. * Class used to store and describe the pipeline context associated with an effect
  65158. */
  65159. export interface IPipelineContext {
  65160. /**
  65161. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  65162. */
  65163. isAsync: boolean;
  65164. /**
  65165. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  65166. */
  65167. isReady: boolean;
  65168. /** @hidden */
  65169. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  65170. }
  65171. }
  65172. declare module BABYLON {
  65173. /**
  65174. * Class used to store gfx data (like WebGLBuffer)
  65175. */
  65176. export class DataBuffer {
  65177. /**
  65178. * Gets or sets the number of objects referencing this buffer
  65179. */
  65180. references: number;
  65181. /** Gets or sets the size of the underlying buffer */
  65182. capacity: number;
  65183. /**
  65184. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65185. */
  65186. is32Bits: boolean;
  65187. /**
  65188. * Gets the underlying buffer
  65189. */
  65190. readonly underlyingResource: any;
  65191. }
  65192. }
  65193. declare module BABYLON {
  65194. /**
  65195. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65196. */
  65197. export class PerformanceMonitor {
  65198. private _enabled;
  65199. private _rollingFrameTime;
  65200. private _lastFrameTimeMs;
  65201. /**
  65202. * constructor
  65203. * @param frameSampleSize The number of samples required to saturate the sliding window
  65204. */
  65205. constructor(frameSampleSize?: number);
  65206. /**
  65207. * Samples current frame
  65208. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65209. */
  65210. sampleFrame(timeMs?: number): void;
  65211. /**
  65212. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65213. */
  65214. readonly averageFrameTime: number;
  65215. /**
  65216. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65217. */
  65218. readonly averageFrameTimeVariance: number;
  65219. /**
  65220. * Returns the frame time of the most recent frame
  65221. */
  65222. readonly instantaneousFrameTime: number;
  65223. /**
  65224. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65225. */
  65226. readonly averageFPS: number;
  65227. /**
  65228. * Returns the average framerate in frames per second using the most recent frame time
  65229. */
  65230. readonly instantaneousFPS: number;
  65231. /**
  65232. * Returns true if enough samples have been taken to completely fill the sliding window
  65233. */
  65234. readonly isSaturated: boolean;
  65235. /**
  65236. * Enables contributions to the sliding window sample set
  65237. */
  65238. enable(): void;
  65239. /**
  65240. * Disables contributions to the sliding window sample set
  65241. * Samples will not be interpolated over the disabled period
  65242. */
  65243. disable(): void;
  65244. /**
  65245. * Returns true if sampling is enabled
  65246. */
  65247. readonly isEnabled: boolean;
  65248. /**
  65249. * Resets performance monitor
  65250. */
  65251. reset(): void;
  65252. }
  65253. /**
  65254. * RollingAverage
  65255. *
  65256. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65257. */
  65258. export class RollingAverage {
  65259. /**
  65260. * Current average
  65261. */
  65262. average: number;
  65263. /**
  65264. * Current variance
  65265. */
  65266. variance: number;
  65267. protected _samples: Array<number>;
  65268. protected _sampleCount: number;
  65269. protected _pos: number;
  65270. protected _m2: number;
  65271. /**
  65272. * constructor
  65273. * @param length The number of samples required to saturate the sliding window
  65274. */
  65275. constructor(length: number);
  65276. /**
  65277. * Adds a sample to the sample set
  65278. * @param v The sample value
  65279. */
  65280. add(v: number): void;
  65281. /**
  65282. * Returns previously added values or null if outside of history or outside the sliding window domain
  65283. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65284. * @return Value previously recorded with add() or null if outside of range
  65285. */
  65286. history(i: number): number;
  65287. /**
  65288. * Returns true if enough samples have been taken to completely fill the sliding window
  65289. * @return true if sample-set saturated
  65290. */
  65291. isSaturated(): boolean;
  65292. /**
  65293. * Resets the rolling average (equivalent to 0 samples taken so far)
  65294. */
  65295. reset(): void;
  65296. /**
  65297. * Wraps a value around the sample range boundaries
  65298. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65299. * @return Wrapped position in sample range
  65300. */
  65301. protected _wrapPosition(i: number): number;
  65302. }
  65303. }
  65304. declare module BABYLON {
  65305. /**
  65306. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65307. * The underlying implementation relies on an associative array to ensure the best performances.
  65308. * The value can be anything including 'null' but except 'undefined'
  65309. */
  65310. export class StringDictionary<T> {
  65311. /**
  65312. * This will clear this dictionary and copy the content from the 'source' one.
  65313. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65314. * @param source the dictionary to take the content from and copy to this dictionary
  65315. */
  65316. copyFrom(source: StringDictionary<T>): void;
  65317. /**
  65318. * Get a value based from its key
  65319. * @param key the given key to get the matching value from
  65320. * @return the value if found, otherwise undefined is returned
  65321. */
  65322. get(key: string): T | undefined;
  65323. /**
  65324. * Get a value from its key or add it if it doesn't exist.
  65325. * This method will ensure you that a given key/data will be present in the dictionary.
  65326. * @param key the given key to get the matching value from
  65327. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65328. * The factory will only be invoked if there's no data for the given key.
  65329. * @return the value corresponding to the key.
  65330. */
  65331. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65332. /**
  65333. * Get a value from its key if present in the dictionary otherwise add it
  65334. * @param key the key to get the value from
  65335. * @param val if there's no such key/value pair in the dictionary add it with this value
  65336. * @return the value corresponding to the key
  65337. */
  65338. getOrAdd(key: string, val: T): T;
  65339. /**
  65340. * Check if there's a given key in the dictionary
  65341. * @param key the key to check for
  65342. * @return true if the key is present, false otherwise
  65343. */
  65344. contains(key: string): boolean;
  65345. /**
  65346. * Add a new key and its corresponding value
  65347. * @param key the key to add
  65348. * @param value the value corresponding to the key
  65349. * @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
  65350. */
  65351. add(key: string, value: T): boolean;
  65352. /**
  65353. * Update a specific value associated to a key
  65354. * @param key defines the key to use
  65355. * @param value defines the value to store
  65356. * @returns true if the value was updated (or false if the key was not found)
  65357. */
  65358. set(key: string, value: T): boolean;
  65359. /**
  65360. * Get the element of the given key and remove it from the dictionary
  65361. * @param key defines the key to search
  65362. * @returns the value associated with the key or null if not found
  65363. */
  65364. getAndRemove(key: string): Nullable<T>;
  65365. /**
  65366. * Remove a key/value from the dictionary.
  65367. * @param key the key to remove
  65368. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65369. */
  65370. remove(key: string): boolean;
  65371. /**
  65372. * Clear the whole content of the dictionary
  65373. */
  65374. clear(): void;
  65375. /**
  65376. * Gets the current count
  65377. */
  65378. readonly count: number;
  65379. /**
  65380. * Execute a callback on each key/val of the dictionary.
  65381. * Note that you can remove any element in this dictionary in the callback implementation
  65382. * @param callback the callback to execute on a given key/value pair
  65383. */
  65384. forEach(callback: (key: string, val: T) => void): void;
  65385. /**
  65386. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65387. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65388. * Note that you can remove any element in this dictionary in the callback implementation
  65389. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65390. * @returns the first item
  65391. */
  65392. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65393. private _count;
  65394. private _data;
  65395. }
  65396. }
  65397. declare module BABYLON {
  65398. /**
  65399. * Helper class that provides a small promise polyfill
  65400. */
  65401. export class PromisePolyfill {
  65402. /**
  65403. * Static function used to check if the polyfill is required
  65404. * If this is the case then the function will inject the polyfill to window.Promise
  65405. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65406. */
  65407. static Apply(force?: boolean): void;
  65408. }
  65409. }
  65410. declare module BABYLON {
  65411. /**
  65412. * Class used to store data that will be store in GPU memory
  65413. */
  65414. export class Buffer {
  65415. private _engine;
  65416. private _buffer;
  65417. /** @hidden */
  65418. _data: Nullable<DataArray>;
  65419. private _updatable;
  65420. private _instanced;
  65421. /**
  65422. * Gets the byte stride.
  65423. */
  65424. readonly byteStride: number;
  65425. /**
  65426. * Constructor
  65427. * @param engine the engine
  65428. * @param data the data to use for this buffer
  65429. * @param updatable whether the data is updatable
  65430. * @param stride the stride (optional)
  65431. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65432. * @param instanced whether the buffer is instanced (optional)
  65433. * @param useBytes set to true if the stride in in bytes (optional)
  65434. */
  65435. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65436. /**
  65437. * Create a new VertexBuffer based on the current buffer
  65438. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65439. * @param offset defines offset in the buffer (0 by default)
  65440. * @param size defines the size in floats of attributes (position is 3 for instance)
  65441. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65442. * @param instanced defines if the vertex buffer contains indexed data
  65443. * @param useBytes defines if the offset and stride are in bytes
  65444. * @returns the new vertex buffer
  65445. */
  65446. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65447. /**
  65448. * Gets a boolean indicating if the Buffer is updatable?
  65449. * @returns true if the buffer is updatable
  65450. */
  65451. isUpdatable(): boolean;
  65452. /**
  65453. * Gets current buffer's data
  65454. * @returns a DataArray or null
  65455. */
  65456. getData(): Nullable<DataArray>;
  65457. /**
  65458. * Gets underlying native buffer
  65459. * @returns underlying native buffer
  65460. */
  65461. getBuffer(): Nullable<DataBuffer>;
  65462. /**
  65463. * Gets the stride in float32 units (i.e. byte stride / 4).
  65464. * May not be an integer if the byte stride is not divisible by 4.
  65465. * DEPRECATED. Use byteStride instead.
  65466. * @returns the stride in float32 units
  65467. */
  65468. getStrideSize(): number;
  65469. /**
  65470. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65471. * @param data defines the data to store
  65472. */
  65473. create(data?: Nullable<DataArray>): void;
  65474. /** @hidden */
  65475. _rebuild(): void;
  65476. /**
  65477. * Update current buffer data
  65478. * @param data defines the data to store
  65479. */
  65480. update(data: DataArray): void;
  65481. /**
  65482. * Updates the data directly.
  65483. * @param data the new data
  65484. * @param offset the new offset
  65485. * @param vertexCount the vertex count (optional)
  65486. * @param useBytes set to true if the offset is in bytes
  65487. */
  65488. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65489. /**
  65490. * Release all resources
  65491. */
  65492. dispose(): void;
  65493. }
  65494. /**
  65495. * Specialized buffer used to store vertex data
  65496. */
  65497. export class VertexBuffer {
  65498. /** @hidden */
  65499. _buffer: Buffer;
  65500. private _kind;
  65501. private _size;
  65502. private _ownsBuffer;
  65503. private _instanced;
  65504. private _instanceDivisor;
  65505. /**
  65506. * The byte type.
  65507. */
  65508. static readonly BYTE: number;
  65509. /**
  65510. * The unsigned byte type.
  65511. */
  65512. static readonly UNSIGNED_BYTE: number;
  65513. /**
  65514. * The short type.
  65515. */
  65516. static readonly SHORT: number;
  65517. /**
  65518. * The unsigned short type.
  65519. */
  65520. static readonly UNSIGNED_SHORT: number;
  65521. /**
  65522. * The integer type.
  65523. */
  65524. static readonly INT: number;
  65525. /**
  65526. * The unsigned integer type.
  65527. */
  65528. static readonly UNSIGNED_INT: number;
  65529. /**
  65530. * The float type.
  65531. */
  65532. static readonly FLOAT: number;
  65533. /**
  65534. * Gets or sets the instance divisor when in instanced mode
  65535. */
  65536. instanceDivisor: number;
  65537. /**
  65538. * Gets the byte stride.
  65539. */
  65540. readonly byteStride: number;
  65541. /**
  65542. * Gets the byte offset.
  65543. */
  65544. readonly byteOffset: number;
  65545. /**
  65546. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65547. */
  65548. readonly normalized: boolean;
  65549. /**
  65550. * Gets the data type of each component in the array.
  65551. */
  65552. readonly type: number;
  65553. /**
  65554. * Constructor
  65555. * @param engine the engine
  65556. * @param data the data to use for this vertex buffer
  65557. * @param kind the vertex buffer kind
  65558. * @param updatable whether the data is updatable
  65559. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65560. * @param stride the stride (optional)
  65561. * @param instanced whether the buffer is instanced (optional)
  65562. * @param offset the offset of the data (optional)
  65563. * @param size the number of components (optional)
  65564. * @param type the type of the component (optional)
  65565. * @param normalized whether the data contains normalized data (optional)
  65566. * @param useBytes set to true if stride and offset are in bytes (optional)
  65567. */
  65568. 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);
  65569. /** @hidden */
  65570. _rebuild(): void;
  65571. /**
  65572. * Returns the kind of the VertexBuffer (string)
  65573. * @returns a string
  65574. */
  65575. getKind(): string;
  65576. /**
  65577. * Gets a boolean indicating if the VertexBuffer is updatable?
  65578. * @returns true if the buffer is updatable
  65579. */
  65580. isUpdatable(): boolean;
  65581. /**
  65582. * Gets current buffer's data
  65583. * @returns a DataArray or null
  65584. */
  65585. getData(): Nullable<DataArray>;
  65586. /**
  65587. * Gets underlying native buffer
  65588. * @returns underlying native buffer
  65589. */
  65590. getBuffer(): Nullable<DataBuffer>;
  65591. /**
  65592. * Gets the stride in float32 units (i.e. byte stride / 4).
  65593. * May not be an integer if the byte stride is not divisible by 4.
  65594. * DEPRECATED. Use byteStride instead.
  65595. * @returns the stride in float32 units
  65596. */
  65597. getStrideSize(): number;
  65598. /**
  65599. * Returns the offset as a multiple of the type byte length.
  65600. * DEPRECATED. Use byteOffset instead.
  65601. * @returns the offset in bytes
  65602. */
  65603. getOffset(): number;
  65604. /**
  65605. * Returns the number of components per vertex attribute (integer)
  65606. * @returns the size in float
  65607. */
  65608. getSize(): number;
  65609. /**
  65610. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65611. * @returns true if this buffer is instanced
  65612. */
  65613. getIsInstanced(): boolean;
  65614. /**
  65615. * Returns the instancing divisor, zero for non-instanced (integer).
  65616. * @returns a number
  65617. */
  65618. getInstanceDivisor(): number;
  65619. /**
  65620. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65621. * @param data defines the data to store
  65622. */
  65623. create(data?: DataArray): void;
  65624. /**
  65625. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65626. * This function will create a new buffer if the current one is not updatable
  65627. * @param data defines the data to store
  65628. */
  65629. update(data: DataArray): void;
  65630. /**
  65631. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65632. * Returns the directly updated WebGLBuffer.
  65633. * @param data the new data
  65634. * @param offset the new offset
  65635. * @param useBytes set to true if the offset is in bytes
  65636. */
  65637. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65638. /**
  65639. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65640. */
  65641. dispose(): void;
  65642. /**
  65643. * Enumerates each value of this vertex buffer as numbers.
  65644. * @param count the number of values to enumerate
  65645. * @param callback the callback function called for each value
  65646. */
  65647. forEach(count: number, callback: (value: number, index: number) => void): void;
  65648. /**
  65649. * Positions
  65650. */
  65651. static readonly PositionKind: string;
  65652. /**
  65653. * Normals
  65654. */
  65655. static readonly NormalKind: string;
  65656. /**
  65657. * Tangents
  65658. */
  65659. static readonly TangentKind: string;
  65660. /**
  65661. * Texture coordinates
  65662. */
  65663. static readonly UVKind: string;
  65664. /**
  65665. * Texture coordinates 2
  65666. */
  65667. static readonly UV2Kind: string;
  65668. /**
  65669. * Texture coordinates 3
  65670. */
  65671. static readonly UV3Kind: string;
  65672. /**
  65673. * Texture coordinates 4
  65674. */
  65675. static readonly UV4Kind: string;
  65676. /**
  65677. * Texture coordinates 5
  65678. */
  65679. static readonly UV5Kind: string;
  65680. /**
  65681. * Texture coordinates 6
  65682. */
  65683. static readonly UV6Kind: string;
  65684. /**
  65685. * Colors
  65686. */
  65687. static readonly ColorKind: string;
  65688. /**
  65689. * Matrix indices (for bones)
  65690. */
  65691. static readonly MatricesIndicesKind: string;
  65692. /**
  65693. * Matrix weights (for bones)
  65694. */
  65695. static readonly MatricesWeightsKind: string;
  65696. /**
  65697. * Additional matrix indices (for bones)
  65698. */
  65699. static readonly MatricesIndicesExtraKind: string;
  65700. /**
  65701. * Additional matrix weights (for bones)
  65702. */
  65703. static readonly MatricesWeightsExtraKind: string;
  65704. /**
  65705. * Deduces the stride given a kind.
  65706. * @param kind The kind string to deduce
  65707. * @returns The deduced stride
  65708. */
  65709. static DeduceStride(kind: string): number;
  65710. /**
  65711. * Gets the byte length of the given type.
  65712. * @param type the type
  65713. * @returns the number of bytes
  65714. */
  65715. static GetTypeByteLength(type: number): number;
  65716. /**
  65717. * Enumerates each value of the given parameters as numbers.
  65718. * @param data the data to enumerate
  65719. * @param byteOffset the byte offset of the data
  65720. * @param byteStride the byte stride of the data
  65721. * @param componentCount the number of components per element
  65722. * @param componentType the type of the component
  65723. * @param count the total number of components
  65724. * @param normalized whether the data is normalized
  65725. * @param callback the callback function called for each value
  65726. */
  65727. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65728. private static _GetFloatValue;
  65729. }
  65730. }
  65731. declare module BABYLON {
  65732. /**
  65733. * Class representing spherical harmonics coefficients to the 3rd degree
  65734. */
  65735. export class SphericalHarmonics {
  65736. /**
  65737. * Defines whether or not the harmonics have been prescaled for rendering.
  65738. */
  65739. preScaled: boolean;
  65740. /**
  65741. * The l0,0 coefficients of the spherical harmonics
  65742. */
  65743. l00: Vector3;
  65744. /**
  65745. * The l1,-1 coefficients of the spherical harmonics
  65746. */
  65747. l1_1: Vector3;
  65748. /**
  65749. * The l1,0 coefficients of the spherical harmonics
  65750. */
  65751. l10: Vector3;
  65752. /**
  65753. * The l1,1 coefficients of the spherical harmonics
  65754. */
  65755. l11: Vector3;
  65756. /**
  65757. * The l2,-2 coefficients of the spherical harmonics
  65758. */
  65759. l2_2: Vector3;
  65760. /**
  65761. * The l2,-1 coefficients of the spherical harmonics
  65762. */
  65763. l2_1: Vector3;
  65764. /**
  65765. * The l2,0 coefficients of the spherical harmonics
  65766. */
  65767. l20: Vector3;
  65768. /**
  65769. * The l2,1 coefficients of the spherical harmonics
  65770. */
  65771. l21: Vector3;
  65772. /**
  65773. * The l2,2 coefficients of the spherical harmonics
  65774. */
  65775. l22: Vector3;
  65776. /**
  65777. * Adds a light to the spherical harmonics
  65778. * @param direction the direction of the light
  65779. * @param color the color of the light
  65780. * @param deltaSolidAngle the delta solid angle of the light
  65781. */
  65782. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65783. /**
  65784. * Scales the spherical harmonics by the given amount
  65785. * @param scale the amount to scale
  65786. */
  65787. scaleInPlace(scale: number): void;
  65788. /**
  65789. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65790. *
  65791. * ```
  65792. * E_lm = A_l * L_lm
  65793. * ```
  65794. *
  65795. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65796. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65797. * the scaling factors are given in equation 9.
  65798. */
  65799. convertIncidentRadianceToIrradiance(): void;
  65800. /**
  65801. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65802. *
  65803. * ```
  65804. * L = (1/pi) * E * rho
  65805. * ```
  65806. *
  65807. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65808. */
  65809. convertIrradianceToLambertianRadiance(): void;
  65810. /**
  65811. * Integrates the reconstruction coefficients directly in to the SH preventing further
  65812. * required operations at run time.
  65813. *
  65814. * This is simply done by scaling back the SH with Ylm constants parameter.
  65815. * The trigonometric part being applied by the shader at run time.
  65816. */
  65817. preScaleForRendering(): void;
  65818. /**
  65819. * Constructs a spherical harmonics from an array.
  65820. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65821. * @returns the spherical harmonics
  65822. */
  65823. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65824. /**
  65825. * Gets the spherical harmonics from polynomial
  65826. * @param polynomial the spherical polynomial
  65827. * @returns the spherical harmonics
  65828. */
  65829. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65830. }
  65831. /**
  65832. * Class representing spherical polynomial coefficients to the 3rd degree
  65833. */
  65834. export class SphericalPolynomial {
  65835. private _harmonics;
  65836. /**
  65837. * The spherical harmonics used to create the polynomials.
  65838. */
  65839. readonly preScaledHarmonics: SphericalHarmonics;
  65840. /**
  65841. * The x coefficients of the spherical polynomial
  65842. */
  65843. x: Vector3;
  65844. /**
  65845. * The y coefficients of the spherical polynomial
  65846. */
  65847. y: Vector3;
  65848. /**
  65849. * The z coefficients of the spherical polynomial
  65850. */
  65851. z: Vector3;
  65852. /**
  65853. * The xx coefficients of the spherical polynomial
  65854. */
  65855. xx: Vector3;
  65856. /**
  65857. * The yy coefficients of the spherical polynomial
  65858. */
  65859. yy: Vector3;
  65860. /**
  65861. * The zz coefficients of the spherical polynomial
  65862. */
  65863. zz: Vector3;
  65864. /**
  65865. * The xy coefficients of the spherical polynomial
  65866. */
  65867. xy: Vector3;
  65868. /**
  65869. * The yz coefficients of the spherical polynomial
  65870. */
  65871. yz: Vector3;
  65872. /**
  65873. * The zx coefficients of the spherical polynomial
  65874. */
  65875. zx: Vector3;
  65876. /**
  65877. * Adds an ambient color to the spherical polynomial
  65878. * @param color the color to add
  65879. */
  65880. addAmbient(color: Color3): void;
  65881. /**
  65882. * Scales the spherical polynomial by the given amount
  65883. * @param scale the amount to scale
  65884. */
  65885. scaleInPlace(scale: number): void;
  65886. /**
  65887. * Gets the spherical polynomial from harmonics
  65888. * @param harmonics the spherical harmonics
  65889. * @returns the spherical polynomial
  65890. */
  65891. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65892. /**
  65893. * Constructs a spherical polynomial from an array.
  65894. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65895. * @returns the spherical polynomial
  65896. */
  65897. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65898. }
  65899. }
  65900. declare module BABYLON {
  65901. /**
  65902. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65903. */
  65904. export interface CubeMapInfo {
  65905. /**
  65906. * The pixel array for the front face.
  65907. * This is stored in format, left to right, up to down format.
  65908. */
  65909. front: Nullable<ArrayBufferView>;
  65910. /**
  65911. * The pixel array for the back face.
  65912. * This is stored in format, left to right, up to down format.
  65913. */
  65914. back: Nullable<ArrayBufferView>;
  65915. /**
  65916. * The pixel array for the left face.
  65917. * This is stored in format, left to right, up to down format.
  65918. */
  65919. left: Nullable<ArrayBufferView>;
  65920. /**
  65921. * The pixel array for the right face.
  65922. * This is stored in format, left to right, up to down format.
  65923. */
  65924. right: Nullable<ArrayBufferView>;
  65925. /**
  65926. * The pixel array for the up face.
  65927. * This is stored in format, left to right, up to down format.
  65928. */
  65929. up: Nullable<ArrayBufferView>;
  65930. /**
  65931. * The pixel array for the down face.
  65932. * This is stored in format, left to right, up to down format.
  65933. */
  65934. down: Nullable<ArrayBufferView>;
  65935. /**
  65936. * The size of the cubemap stored.
  65937. *
  65938. * Each faces will be size * size pixels.
  65939. */
  65940. size: number;
  65941. /**
  65942. * The format of the texture.
  65943. *
  65944. * RGBA, RGB.
  65945. */
  65946. format: number;
  65947. /**
  65948. * The type of the texture data.
  65949. *
  65950. * UNSIGNED_INT, FLOAT.
  65951. */
  65952. type: number;
  65953. /**
  65954. * Specifies whether the texture is in gamma space.
  65955. */
  65956. gammaSpace: boolean;
  65957. }
  65958. /**
  65959. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65960. */
  65961. export class PanoramaToCubeMapTools {
  65962. private static FACE_FRONT;
  65963. private static FACE_BACK;
  65964. private static FACE_RIGHT;
  65965. private static FACE_LEFT;
  65966. private static FACE_DOWN;
  65967. private static FACE_UP;
  65968. /**
  65969. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65970. *
  65971. * @param float32Array The source data.
  65972. * @param inputWidth The width of the input panorama.
  65973. * @param inputHeight The height of the input panorama.
  65974. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65975. * @return The cubemap data
  65976. */
  65977. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65978. private static CreateCubemapTexture;
  65979. private static CalcProjectionSpherical;
  65980. }
  65981. }
  65982. declare module BABYLON {
  65983. /**
  65984. * Helper class dealing with the extraction of spherical polynomial dataArray
  65985. * from a cube map.
  65986. */
  65987. export class CubeMapToSphericalPolynomialTools {
  65988. private static FileFaces;
  65989. /**
  65990. * Converts a texture to the according Spherical Polynomial data.
  65991. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65992. *
  65993. * @param texture The texture to extract the information from.
  65994. * @return The Spherical Polynomial data.
  65995. */
  65996. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65997. /**
  65998. * Converts a cubemap to the according Spherical Polynomial data.
  65999. * This extracts the first 3 orders only as they are the only one used in the lighting.
  66000. *
  66001. * @param cubeInfo The Cube map to extract the information from.
  66002. * @return The Spherical Polynomial data.
  66003. */
  66004. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  66005. }
  66006. }
  66007. declare module BABYLON {
  66008. /**
  66009. * The engine store class is responsible to hold all the instances of Engine and Scene created
  66010. * during the life time of the application.
  66011. */
  66012. export class EngineStore {
  66013. /** Gets the list of created engines */
  66014. static Instances: Engine[];
  66015. /**
  66016. * Gets the latest created engine
  66017. */
  66018. static readonly LastCreatedEngine: Nullable<Engine>;
  66019. /**
  66020. * Gets the latest created scene
  66021. */
  66022. static readonly LastCreatedScene: Nullable<Scene>;
  66023. }
  66024. }
  66025. declare module BABYLON {
  66026. /**
  66027. * Define options used to create a render target texture
  66028. */
  66029. export class RenderTargetCreationOptions {
  66030. /**
  66031. * Specifies is mipmaps must be generated
  66032. */
  66033. generateMipMaps?: boolean;
  66034. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  66035. generateDepthBuffer?: boolean;
  66036. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  66037. generateStencilBuffer?: boolean;
  66038. /** Defines texture type (int by default) */
  66039. type?: number;
  66040. /** Defines sampling mode (trilinear by default) */
  66041. samplingMode?: number;
  66042. /** Defines format (RGBA by default) */
  66043. format?: number;
  66044. }
  66045. }
  66046. declare module BABYLON {
  66047. /**
  66048. * @hidden
  66049. **/
  66050. export class _AlphaState {
  66051. private _isAlphaBlendDirty;
  66052. private _isBlendFunctionParametersDirty;
  66053. private _isBlendEquationParametersDirty;
  66054. private _isBlendConstantsDirty;
  66055. private _alphaBlend;
  66056. private _blendFunctionParameters;
  66057. private _blendEquationParameters;
  66058. private _blendConstants;
  66059. /**
  66060. * Initializes the state.
  66061. */
  66062. constructor();
  66063. readonly isDirty: boolean;
  66064. alphaBlend: boolean;
  66065. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  66066. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  66067. setAlphaEquationParameters(rgb: number, alpha: number): void;
  66068. reset(): void;
  66069. apply(gl: WebGLRenderingContext): void;
  66070. }
  66071. }
  66072. declare module BABYLON {
  66073. /**
  66074. * @hidden
  66075. **/
  66076. export class _DepthCullingState {
  66077. private _isDepthTestDirty;
  66078. private _isDepthMaskDirty;
  66079. private _isDepthFuncDirty;
  66080. private _isCullFaceDirty;
  66081. private _isCullDirty;
  66082. private _isZOffsetDirty;
  66083. private _isFrontFaceDirty;
  66084. private _depthTest;
  66085. private _depthMask;
  66086. private _depthFunc;
  66087. private _cull;
  66088. private _cullFace;
  66089. private _zOffset;
  66090. private _frontFace;
  66091. /**
  66092. * Initializes the state.
  66093. */
  66094. constructor();
  66095. readonly isDirty: boolean;
  66096. zOffset: number;
  66097. cullFace: Nullable<number>;
  66098. cull: Nullable<boolean>;
  66099. depthFunc: Nullable<number>;
  66100. depthMask: boolean;
  66101. depthTest: boolean;
  66102. frontFace: Nullable<number>;
  66103. reset(): void;
  66104. apply(gl: WebGLRenderingContext): void;
  66105. }
  66106. }
  66107. declare module BABYLON {
  66108. /**
  66109. * @hidden
  66110. **/
  66111. export class _StencilState {
  66112. /** 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 */
  66113. static readonly ALWAYS: number;
  66114. /** Passed to stencilOperation to specify that stencil value must be kept */
  66115. static readonly KEEP: number;
  66116. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66117. static readonly REPLACE: number;
  66118. private _isStencilTestDirty;
  66119. private _isStencilMaskDirty;
  66120. private _isStencilFuncDirty;
  66121. private _isStencilOpDirty;
  66122. private _stencilTest;
  66123. private _stencilMask;
  66124. private _stencilFunc;
  66125. private _stencilFuncRef;
  66126. private _stencilFuncMask;
  66127. private _stencilOpStencilFail;
  66128. private _stencilOpDepthFail;
  66129. private _stencilOpStencilDepthPass;
  66130. readonly isDirty: boolean;
  66131. stencilFunc: number;
  66132. stencilFuncRef: number;
  66133. stencilFuncMask: number;
  66134. stencilOpStencilFail: number;
  66135. stencilOpDepthFail: number;
  66136. stencilOpStencilDepthPass: number;
  66137. stencilMask: number;
  66138. stencilTest: boolean;
  66139. constructor();
  66140. reset(): void;
  66141. apply(gl: WebGLRenderingContext): void;
  66142. }
  66143. }
  66144. declare module BABYLON {
  66145. /**
  66146. * @hidden
  66147. **/
  66148. export class _TimeToken {
  66149. _startTimeQuery: Nullable<WebGLQuery>;
  66150. _endTimeQuery: Nullable<WebGLQuery>;
  66151. _timeElapsedQuery: Nullable<WebGLQuery>;
  66152. _timeElapsedQueryEnded: boolean;
  66153. }
  66154. }
  66155. declare module BABYLON {
  66156. /**
  66157. * Class used to store data associated with WebGL texture data for the engine
  66158. * This class should not be used directly
  66159. */
  66160. export class InternalTexture {
  66161. /** hidden */
  66162. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  66163. /**
  66164. * The source of the texture data is unknown
  66165. */
  66166. static DATASOURCE_UNKNOWN: number;
  66167. /**
  66168. * Texture data comes from an URL
  66169. */
  66170. static DATASOURCE_URL: number;
  66171. /**
  66172. * Texture data is only used for temporary storage
  66173. */
  66174. static DATASOURCE_TEMP: number;
  66175. /**
  66176. * Texture data comes from raw data (ArrayBuffer)
  66177. */
  66178. static DATASOURCE_RAW: number;
  66179. /**
  66180. * Texture content is dynamic (video or dynamic texture)
  66181. */
  66182. static DATASOURCE_DYNAMIC: number;
  66183. /**
  66184. * Texture content is generated by rendering to it
  66185. */
  66186. static DATASOURCE_RENDERTARGET: number;
  66187. /**
  66188. * Texture content is part of a multi render target process
  66189. */
  66190. static DATASOURCE_MULTIRENDERTARGET: number;
  66191. /**
  66192. * Texture data comes from a cube data file
  66193. */
  66194. static DATASOURCE_CUBE: number;
  66195. /**
  66196. * Texture data comes from a raw cube data
  66197. */
  66198. static DATASOURCE_CUBERAW: number;
  66199. /**
  66200. * Texture data come from a prefiltered cube data file
  66201. */
  66202. static DATASOURCE_CUBEPREFILTERED: number;
  66203. /**
  66204. * Texture content is raw 3D data
  66205. */
  66206. static DATASOURCE_RAW3D: number;
  66207. /**
  66208. * Texture content is a depth texture
  66209. */
  66210. static DATASOURCE_DEPTHTEXTURE: number;
  66211. /**
  66212. * Texture data comes from a raw cube data encoded with RGBD
  66213. */
  66214. static DATASOURCE_CUBERAW_RGBD: number;
  66215. /**
  66216. * Defines if the texture is ready
  66217. */
  66218. isReady: boolean;
  66219. /**
  66220. * Defines if the texture is a cube texture
  66221. */
  66222. isCube: boolean;
  66223. /**
  66224. * Defines if the texture contains 3D data
  66225. */
  66226. is3D: boolean;
  66227. /**
  66228. * Defines if the texture contains multiview data
  66229. */
  66230. isMultiview: boolean;
  66231. /**
  66232. * Gets the URL used to load this texture
  66233. */
  66234. url: string;
  66235. /**
  66236. * Gets the sampling mode of the texture
  66237. */
  66238. samplingMode: number;
  66239. /**
  66240. * Gets a boolean indicating if the texture needs mipmaps generation
  66241. */
  66242. generateMipMaps: boolean;
  66243. /**
  66244. * Gets the number of samples used by the texture (WebGL2+ only)
  66245. */
  66246. samples: number;
  66247. /**
  66248. * Gets the type of the texture (int, float...)
  66249. */
  66250. type: number;
  66251. /**
  66252. * Gets the format of the texture (RGB, RGBA...)
  66253. */
  66254. format: number;
  66255. /**
  66256. * Observable called when the texture is loaded
  66257. */
  66258. onLoadedObservable: Observable<InternalTexture>;
  66259. /**
  66260. * Gets the width of the texture
  66261. */
  66262. width: number;
  66263. /**
  66264. * Gets the height of the texture
  66265. */
  66266. height: number;
  66267. /**
  66268. * Gets the depth of the texture
  66269. */
  66270. depth: number;
  66271. /**
  66272. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66273. */
  66274. baseWidth: number;
  66275. /**
  66276. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66277. */
  66278. baseHeight: number;
  66279. /**
  66280. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66281. */
  66282. baseDepth: number;
  66283. /**
  66284. * Gets a boolean indicating if the texture is inverted on Y axis
  66285. */
  66286. invertY: boolean;
  66287. /** @hidden */
  66288. _invertVScale: boolean;
  66289. /** @hidden */
  66290. _associatedChannel: number;
  66291. /** @hidden */
  66292. _dataSource: number;
  66293. /** @hidden */
  66294. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66295. /** @hidden */
  66296. _bufferView: Nullable<ArrayBufferView>;
  66297. /** @hidden */
  66298. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66299. /** @hidden */
  66300. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66301. /** @hidden */
  66302. _size: number;
  66303. /** @hidden */
  66304. _extension: string;
  66305. /** @hidden */
  66306. _files: Nullable<string[]>;
  66307. /** @hidden */
  66308. _workingCanvas: Nullable<HTMLCanvasElement>;
  66309. /** @hidden */
  66310. _workingContext: Nullable<CanvasRenderingContext2D>;
  66311. /** @hidden */
  66312. _framebuffer: Nullable<WebGLFramebuffer>;
  66313. /** @hidden */
  66314. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66315. /** @hidden */
  66316. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66317. /** @hidden */
  66318. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66319. /** @hidden */
  66320. _attachments: Nullable<number[]>;
  66321. /** @hidden */
  66322. _cachedCoordinatesMode: Nullable<number>;
  66323. /** @hidden */
  66324. _cachedWrapU: Nullable<number>;
  66325. /** @hidden */
  66326. _cachedWrapV: Nullable<number>;
  66327. /** @hidden */
  66328. _cachedWrapR: Nullable<number>;
  66329. /** @hidden */
  66330. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66331. /** @hidden */
  66332. _isDisabled: boolean;
  66333. /** @hidden */
  66334. _compression: Nullable<string>;
  66335. /** @hidden */
  66336. _generateStencilBuffer: boolean;
  66337. /** @hidden */
  66338. _generateDepthBuffer: boolean;
  66339. /** @hidden */
  66340. _comparisonFunction: number;
  66341. /** @hidden */
  66342. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66343. /** @hidden */
  66344. _lodGenerationScale: number;
  66345. /** @hidden */
  66346. _lodGenerationOffset: number;
  66347. /** @hidden */
  66348. _colorTextureArray: Nullable<WebGLTexture>;
  66349. /** @hidden */
  66350. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66351. /** @hidden */
  66352. _lodTextureHigh: Nullable<BaseTexture>;
  66353. /** @hidden */
  66354. _lodTextureMid: Nullable<BaseTexture>;
  66355. /** @hidden */
  66356. _lodTextureLow: Nullable<BaseTexture>;
  66357. /** @hidden */
  66358. _isRGBD: boolean;
  66359. /** @hidden */
  66360. _webGLTexture: Nullable<WebGLTexture>;
  66361. /** @hidden */
  66362. _references: number;
  66363. private _engine;
  66364. /**
  66365. * Gets the Engine the texture belongs to.
  66366. * @returns The babylon engine
  66367. */
  66368. getEngine(): Engine;
  66369. /**
  66370. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66371. */
  66372. readonly dataSource: number;
  66373. /**
  66374. * Creates a new InternalTexture
  66375. * @param engine defines the engine to use
  66376. * @param dataSource defines the type of data that will be used
  66377. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66378. */
  66379. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66380. /**
  66381. * Increments the number of references (ie. the number of Texture that point to it)
  66382. */
  66383. incrementReferences(): void;
  66384. /**
  66385. * Change the size of the texture (not the size of the content)
  66386. * @param width defines the new width
  66387. * @param height defines the new height
  66388. * @param depth defines the new depth (1 by default)
  66389. */
  66390. updateSize(width: int, height: int, depth?: int): void;
  66391. /** @hidden */
  66392. _rebuild(): void;
  66393. /** @hidden */
  66394. _swapAndDie(target: InternalTexture): void;
  66395. /**
  66396. * Dispose the current allocated resources
  66397. */
  66398. dispose(): void;
  66399. }
  66400. }
  66401. declare module BABYLON {
  66402. /**
  66403. * This represents the main contract an easing function should follow.
  66404. * Easing functions are used throughout the animation system.
  66405. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66406. */
  66407. export interface IEasingFunction {
  66408. /**
  66409. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66410. * of the easing function.
  66411. * The link below provides some of the most common examples of easing functions.
  66412. * @see https://easings.net/
  66413. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66414. * @returns the corresponding value on the curve defined by the easing function
  66415. */
  66416. ease(gradient: number): number;
  66417. }
  66418. /**
  66419. * Base class used for every default easing function.
  66420. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66421. */
  66422. export class EasingFunction implements IEasingFunction {
  66423. /**
  66424. * Interpolation follows the mathematical formula associated with the easing function.
  66425. */
  66426. static readonly EASINGMODE_EASEIN: number;
  66427. /**
  66428. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66429. */
  66430. static readonly EASINGMODE_EASEOUT: number;
  66431. /**
  66432. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66433. */
  66434. static readonly EASINGMODE_EASEINOUT: number;
  66435. private _easingMode;
  66436. /**
  66437. * Sets the easing mode of the current function.
  66438. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66439. */
  66440. setEasingMode(easingMode: number): void;
  66441. /**
  66442. * Gets the current easing mode.
  66443. * @returns the easing mode
  66444. */
  66445. getEasingMode(): number;
  66446. /**
  66447. * @hidden
  66448. */
  66449. easeInCore(gradient: number): number;
  66450. /**
  66451. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66452. * of the easing function.
  66453. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66454. * @returns the corresponding value on the curve defined by the easing function
  66455. */
  66456. ease(gradient: number): number;
  66457. }
  66458. /**
  66459. * Easing function with a circle shape (see link below).
  66460. * @see https://easings.net/#easeInCirc
  66461. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66462. */
  66463. export class CircleEase extends EasingFunction implements IEasingFunction {
  66464. /** @hidden */
  66465. easeInCore(gradient: number): number;
  66466. }
  66467. /**
  66468. * Easing function with a ease back shape (see link below).
  66469. * @see https://easings.net/#easeInBack
  66470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66471. */
  66472. export class BackEase extends EasingFunction implements IEasingFunction {
  66473. /** Defines the amplitude of the function */
  66474. amplitude: number;
  66475. /**
  66476. * Instantiates a back ease easing
  66477. * @see https://easings.net/#easeInBack
  66478. * @param amplitude Defines the amplitude of the function
  66479. */
  66480. constructor(
  66481. /** Defines the amplitude of the function */
  66482. amplitude?: number);
  66483. /** @hidden */
  66484. easeInCore(gradient: number): number;
  66485. }
  66486. /**
  66487. * Easing function with a bouncing shape (see link below).
  66488. * @see https://easings.net/#easeInBounce
  66489. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66490. */
  66491. export class BounceEase extends EasingFunction implements IEasingFunction {
  66492. /** Defines the number of bounces */
  66493. bounces: number;
  66494. /** Defines the amplitude of the bounce */
  66495. bounciness: number;
  66496. /**
  66497. * Instantiates a bounce easing
  66498. * @see https://easings.net/#easeInBounce
  66499. * @param bounces Defines the number of bounces
  66500. * @param bounciness Defines the amplitude of the bounce
  66501. */
  66502. constructor(
  66503. /** Defines the number of bounces */
  66504. bounces?: number,
  66505. /** Defines the amplitude of the bounce */
  66506. bounciness?: number);
  66507. /** @hidden */
  66508. easeInCore(gradient: number): number;
  66509. }
  66510. /**
  66511. * Easing function with a power of 3 shape (see link below).
  66512. * @see https://easings.net/#easeInCubic
  66513. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66514. */
  66515. export class CubicEase extends EasingFunction implements IEasingFunction {
  66516. /** @hidden */
  66517. easeInCore(gradient: number): number;
  66518. }
  66519. /**
  66520. * Easing function with an elastic shape (see link below).
  66521. * @see https://easings.net/#easeInElastic
  66522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66523. */
  66524. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66525. /** Defines the number of oscillations*/
  66526. oscillations: number;
  66527. /** Defines the amplitude of the oscillations*/
  66528. springiness: number;
  66529. /**
  66530. * Instantiates an elastic easing function
  66531. * @see https://easings.net/#easeInElastic
  66532. * @param oscillations Defines the number of oscillations
  66533. * @param springiness Defines the amplitude of the oscillations
  66534. */
  66535. constructor(
  66536. /** Defines the number of oscillations*/
  66537. oscillations?: number,
  66538. /** Defines the amplitude of the oscillations*/
  66539. springiness?: number);
  66540. /** @hidden */
  66541. easeInCore(gradient: number): number;
  66542. }
  66543. /**
  66544. * Easing function with an exponential shape (see link below).
  66545. * @see https://easings.net/#easeInExpo
  66546. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66547. */
  66548. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66549. /** Defines the exponent of the function */
  66550. exponent: number;
  66551. /**
  66552. * Instantiates an exponential easing function
  66553. * @see https://easings.net/#easeInExpo
  66554. * @param exponent Defines the exponent of the function
  66555. */
  66556. constructor(
  66557. /** Defines the exponent of the function */
  66558. exponent?: number);
  66559. /** @hidden */
  66560. easeInCore(gradient: number): number;
  66561. }
  66562. /**
  66563. * Easing function with a power shape (see link below).
  66564. * @see https://easings.net/#easeInQuad
  66565. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66566. */
  66567. export class PowerEase extends EasingFunction implements IEasingFunction {
  66568. /** Defines the power of the function */
  66569. power: number;
  66570. /**
  66571. * Instantiates an power base easing function
  66572. * @see https://easings.net/#easeInQuad
  66573. * @param power Defines the power of the function
  66574. */
  66575. constructor(
  66576. /** Defines the power of the function */
  66577. power?: number);
  66578. /** @hidden */
  66579. easeInCore(gradient: number): number;
  66580. }
  66581. /**
  66582. * Easing function with a power of 2 shape (see link below).
  66583. * @see https://easings.net/#easeInQuad
  66584. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66585. */
  66586. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66587. /** @hidden */
  66588. easeInCore(gradient: number): number;
  66589. }
  66590. /**
  66591. * Easing function with a power of 4 shape (see link below).
  66592. * @see https://easings.net/#easeInQuart
  66593. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66594. */
  66595. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66596. /** @hidden */
  66597. easeInCore(gradient: number): number;
  66598. }
  66599. /**
  66600. * Easing function with a power of 5 shape (see link below).
  66601. * @see https://easings.net/#easeInQuint
  66602. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66603. */
  66604. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66605. /** @hidden */
  66606. easeInCore(gradient: number): number;
  66607. }
  66608. /**
  66609. * Easing function with a sin shape (see link below).
  66610. * @see https://easings.net/#easeInSine
  66611. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66612. */
  66613. export class SineEase extends EasingFunction implements IEasingFunction {
  66614. /** @hidden */
  66615. easeInCore(gradient: number): number;
  66616. }
  66617. /**
  66618. * Easing function with a bezier shape (see link below).
  66619. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66620. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66621. */
  66622. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66623. /** Defines the x component of the start tangent in the bezier curve */
  66624. x1: number;
  66625. /** Defines the y component of the start tangent in the bezier curve */
  66626. y1: number;
  66627. /** Defines the x component of the end tangent in the bezier curve */
  66628. x2: number;
  66629. /** Defines the y component of the end tangent in the bezier curve */
  66630. y2: number;
  66631. /**
  66632. * Instantiates a bezier function
  66633. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66634. * @param x1 Defines the x component of the start tangent in the bezier curve
  66635. * @param y1 Defines the y component of the start tangent in the bezier curve
  66636. * @param x2 Defines the x component of the end tangent in the bezier curve
  66637. * @param y2 Defines the y component of the end tangent in the bezier curve
  66638. */
  66639. constructor(
  66640. /** Defines the x component of the start tangent in the bezier curve */
  66641. x1?: number,
  66642. /** Defines the y component of the start tangent in the bezier curve */
  66643. y1?: number,
  66644. /** Defines the x component of the end tangent in the bezier curve */
  66645. x2?: number,
  66646. /** Defines the y component of the end tangent in the bezier curve */
  66647. y2?: number);
  66648. /** @hidden */
  66649. easeInCore(gradient: number): number;
  66650. }
  66651. }
  66652. declare module BABYLON {
  66653. /**
  66654. * Defines an interface which represents an animation key frame
  66655. */
  66656. export interface IAnimationKey {
  66657. /**
  66658. * Frame of the key frame
  66659. */
  66660. frame: number;
  66661. /**
  66662. * Value at the specifies key frame
  66663. */
  66664. value: any;
  66665. /**
  66666. * The input tangent for the cubic hermite spline
  66667. */
  66668. inTangent?: any;
  66669. /**
  66670. * The output tangent for the cubic hermite spline
  66671. */
  66672. outTangent?: any;
  66673. /**
  66674. * The animation interpolation type
  66675. */
  66676. interpolation?: AnimationKeyInterpolation;
  66677. }
  66678. /**
  66679. * Enum for the animation key frame interpolation type
  66680. */
  66681. export enum AnimationKeyInterpolation {
  66682. /**
  66683. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66684. */
  66685. STEP = 1
  66686. }
  66687. }
  66688. declare module BABYLON {
  66689. /**
  66690. * Represents the range of an animation
  66691. */
  66692. export class AnimationRange {
  66693. /**The name of the animation range**/
  66694. name: string;
  66695. /**The starting frame of the animation */
  66696. from: number;
  66697. /**The ending frame of the animation*/
  66698. to: number;
  66699. /**
  66700. * Initializes the range of an animation
  66701. * @param name The name of the animation range
  66702. * @param from The starting frame of the animation
  66703. * @param to The ending frame of the animation
  66704. */
  66705. constructor(
  66706. /**The name of the animation range**/
  66707. name: string,
  66708. /**The starting frame of the animation */
  66709. from: number,
  66710. /**The ending frame of the animation*/
  66711. to: number);
  66712. /**
  66713. * Makes a copy of the animation range
  66714. * @returns A copy of the animation range
  66715. */
  66716. clone(): AnimationRange;
  66717. }
  66718. }
  66719. declare module BABYLON {
  66720. /**
  66721. * Composed of a frame, and an action function
  66722. */
  66723. export class AnimationEvent {
  66724. /** The frame for which the event is triggered **/
  66725. frame: number;
  66726. /** The event to perform when triggered **/
  66727. action: (currentFrame: number) => void;
  66728. /** Specifies if the event should be triggered only once**/
  66729. onlyOnce?: boolean | undefined;
  66730. /**
  66731. * Specifies if the animation event is done
  66732. */
  66733. isDone: boolean;
  66734. /**
  66735. * Initializes the animation event
  66736. * @param frame The frame for which the event is triggered
  66737. * @param action The event to perform when triggered
  66738. * @param onlyOnce Specifies if the event should be triggered only once
  66739. */
  66740. constructor(
  66741. /** The frame for which the event is triggered **/
  66742. frame: number,
  66743. /** The event to perform when triggered **/
  66744. action: (currentFrame: number) => void,
  66745. /** Specifies if the event should be triggered only once**/
  66746. onlyOnce?: boolean | undefined);
  66747. /** @hidden */
  66748. _clone(): AnimationEvent;
  66749. }
  66750. }
  66751. declare module BABYLON {
  66752. /**
  66753. * Interface used to define a behavior
  66754. */
  66755. export interface Behavior<T> {
  66756. /** gets or sets behavior's name */
  66757. name: string;
  66758. /**
  66759. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66760. */
  66761. init(): void;
  66762. /**
  66763. * Called when the behavior is attached to a target
  66764. * @param target defines the target where the behavior is attached to
  66765. */
  66766. attach(target: T): void;
  66767. /**
  66768. * Called when the behavior is detached from its target
  66769. */
  66770. detach(): void;
  66771. }
  66772. /**
  66773. * Interface implemented by classes supporting behaviors
  66774. */
  66775. export interface IBehaviorAware<T> {
  66776. /**
  66777. * Attach a behavior
  66778. * @param behavior defines the behavior to attach
  66779. * @returns the current host
  66780. */
  66781. addBehavior(behavior: Behavior<T>): T;
  66782. /**
  66783. * Remove a behavior from the current object
  66784. * @param behavior defines the behavior to detach
  66785. * @returns the current host
  66786. */
  66787. removeBehavior(behavior: Behavior<T>): T;
  66788. /**
  66789. * Gets a behavior using its name to search
  66790. * @param name defines the name to search
  66791. * @returns the behavior or null if not found
  66792. */
  66793. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66794. }
  66795. }
  66796. declare module BABYLON {
  66797. /**
  66798. * @hidden
  66799. */
  66800. export class IntersectionInfo {
  66801. bu: Nullable<number>;
  66802. bv: Nullable<number>;
  66803. distance: number;
  66804. faceId: number;
  66805. subMeshId: number;
  66806. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66807. }
  66808. }
  66809. declare module BABYLON {
  66810. /**
  66811. * Class used to store bounding sphere information
  66812. */
  66813. export class BoundingSphere {
  66814. /**
  66815. * Gets the center of the bounding sphere in local space
  66816. */
  66817. readonly center: Vector3;
  66818. /**
  66819. * Radius of the bounding sphere in local space
  66820. */
  66821. radius: number;
  66822. /**
  66823. * Gets the center of the bounding sphere in world space
  66824. */
  66825. readonly centerWorld: Vector3;
  66826. /**
  66827. * Radius of the bounding sphere in world space
  66828. */
  66829. radiusWorld: number;
  66830. /**
  66831. * Gets the minimum vector in local space
  66832. */
  66833. readonly minimum: Vector3;
  66834. /**
  66835. * Gets the maximum vector in local space
  66836. */
  66837. readonly maximum: Vector3;
  66838. private _worldMatrix;
  66839. private static readonly TmpVector3;
  66840. /**
  66841. * Creates a new bounding sphere
  66842. * @param min defines the minimum vector (in local space)
  66843. * @param max defines the maximum vector (in local space)
  66844. * @param worldMatrix defines the new world matrix
  66845. */
  66846. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66847. /**
  66848. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66849. * @param min defines the new minimum vector (in local space)
  66850. * @param max defines the new maximum vector (in local space)
  66851. * @param worldMatrix defines the new world matrix
  66852. */
  66853. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66854. /**
  66855. * Scale the current bounding sphere by applying a scale factor
  66856. * @param factor defines the scale factor to apply
  66857. * @returns the current bounding box
  66858. */
  66859. scale(factor: number): BoundingSphere;
  66860. /**
  66861. * Gets the world matrix of the bounding box
  66862. * @returns a matrix
  66863. */
  66864. getWorldMatrix(): DeepImmutable<Matrix>;
  66865. /** @hidden */
  66866. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66867. /**
  66868. * Tests if the bounding sphere is intersecting the frustum planes
  66869. * @param frustumPlanes defines the frustum planes to test
  66870. * @returns true if there is an intersection
  66871. */
  66872. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66873. /**
  66874. * Tests if the bounding sphere center is in between the frustum planes.
  66875. * Used for optimistic fast inclusion.
  66876. * @param frustumPlanes defines the frustum planes to test
  66877. * @returns true if the sphere center is in between the frustum planes
  66878. */
  66879. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66880. /**
  66881. * Tests if a point is inside the bounding sphere
  66882. * @param point defines the point to test
  66883. * @returns true if the point is inside the bounding sphere
  66884. */
  66885. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66886. /**
  66887. * Checks if two sphere intersct
  66888. * @param sphere0 sphere 0
  66889. * @param sphere1 sphere 1
  66890. * @returns true if the speres intersect
  66891. */
  66892. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66893. }
  66894. }
  66895. declare module BABYLON {
  66896. /**
  66897. * Class used to store bounding box information
  66898. */
  66899. export class BoundingBox implements ICullable {
  66900. /**
  66901. * Gets the 8 vectors representing the bounding box in local space
  66902. */
  66903. readonly vectors: Vector3[];
  66904. /**
  66905. * Gets the center of the bounding box in local space
  66906. */
  66907. readonly center: Vector3;
  66908. /**
  66909. * Gets the center of the bounding box in world space
  66910. */
  66911. readonly centerWorld: Vector3;
  66912. /**
  66913. * Gets the extend size in local space
  66914. */
  66915. readonly extendSize: Vector3;
  66916. /**
  66917. * Gets the extend size in world space
  66918. */
  66919. readonly extendSizeWorld: Vector3;
  66920. /**
  66921. * Gets the OBB (object bounding box) directions
  66922. */
  66923. readonly directions: Vector3[];
  66924. /**
  66925. * Gets the 8 vectors representing the bounding box in world space
  66926. */
  66927. readonly vectorsWorld: Vector3[];
  66928. /**
  66929. * Gets the minimum vector in world space
  66930. */
  66931. readonly minimumWorld: Vector3;
  66932. /**
  66933. * Gets the maximum vector in world space
  66934. */
  66935. readonly maximumWorld: Vector3;
  66936. /**
  66937. * Gets the minimum vector in local space
  66938. */
  66939. readonly minimum: Vector3;
  66940. /**
  66941. * Gets the maximum vector in local space
  66942. */
  66943. readonly maximum: Vector3;
  66944. private _worldMatrix;
  66945. private static readonly TmpVector3;
  66946. /**
  66947. * @hidden
  66948. */
  66949. _tag: number;
  66950. /**
  66951. * Creates a new bounding box
  66952. * @param min defines the minimum vector (in local space)
  66953. * @param max defines the maximum vector (in local space)
  66954. * @param worldMatrix defines the new world matrix
  66955. */
  66956. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66957. /**
  66958. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66959. * @param min defines the new minimum vector (in local space)
  66960. * @param max defines the new maximum vector (in local space)
  66961. * @param worldMatrix defines the new world matrix
  66962. */
  66963. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66964. /**
  66965. * Scale the current bounding box by applying a scale factor
  66966. * @param factor defines the scale factor to apply
  66967. * @returns the current bounding box
  66968. */
  66969. scale(factor: number): BoundingBox;
  66970. /**
  66971. * Gets the world matrix of the bounding box
  66972. * @returns a matrix
  66973. */
  66974. getWorldMatrix(): DeepImmutable<Matrix>;
  66975. /** @hidden */
  66976. _update(world: DeepImmutable<Matrix>): void;
  66977. /**
  66978. * Tests if the bounding box is intersecting the frustum planes
  66979. * @param frustumPlanes defines the frustum planes to test
  66980. * @returns true if there is an intersection
  66981. */
  66982. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66983. /**
  66984. * Tests if the bounding box is entirely inside the frustum planes
  66985. * @param frustumPlanes defines the frustum planes to test
  66986. * @returns true if there is an inclusion
  66987. */
  66988. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66989. /**
  66990. * Tests if a point is inside the bounding box
  66991. * @param point defines the point to test
  66992. * @returns true if the point is inside the bounding box
  66993. */
  66994. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66995. /**
  66996. * Tests if the bounding box intersects with a bounding sphere
  66997. * @param sphere defines the sphere to test
  66998. * @returns true if there is an intersection
  66999. */
  67000. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  67001. /**
  67002. * Tests if the bounding box intersects with a box defined by a min and max vectors
  67003. * @param min defines the min vector to use
  67004. * @param max defines the max vector to use
  67005. * @returns true if there is an intersection
  67006. */
  67007. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  67008. /**
  67009. * Tests if two bounding boxes are intersections
  67010. * @param box0 defines the first box to test
  67011. * @param box1 defines the second box to test
  67012. * @returns true if there is an intersection
  67013. */
  67014. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  67015. /**
  67016. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  67017. * @param minPoint defines the minimum vector of the bounding box
  67018. * @param maxPoint defines the maximum vector of the bounding box
  67019. * @param sphereCenter defines the sphere center
  67020. * @param sphereRadius defines the sphere radius
  67021. * @returns true if there is an intersection
  67022. */
  67023. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  67024. /**
  67025. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  67026. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67027. * @param frustumPlanes defines the frustum planes to test
  67028. * @return true if there is an inclusion
  67029. */
  67030. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67031. /**
  67032. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  67033. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67034. * @param frustumPlanes defines the frustum planes to test
  67035. * @return true if there is an intersection
  67036. */
  67037. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67038. }
  67039. }
  67040. declare module BABYLON {
  67041. /** @hidden */
  67042. export class Collider {
  67043. /** Define if a collision was found */
  67044. collisionFound: boolean;
  67045. /**
  67046. * Define last intersection point in local space
  67047. */
  67048. intersectionPoint: Vector3;
  67049. /**
  67050. * Define last collided mesh
  67051. */
  67052. collidedMesh: Nullable<AbstractMesh>;
  67053. private _collisionPoint;
  67054. private _planeIntersectionPoint;
  67055. private _tempVector;
  67056. private _tempVector2;
  67057. private _tempVector3;
  67058. private _tempVector4;
  67059. private _edge;
  67060. private _baseToVertex;
  67061. private _destinationPoint;
  67062. private _slidePlaneNormal;
  67063. private _displacementVector;
  67064. /** @hidden */
  67065. _radius: Vector3;
  67066. /** @hidden */
  67067. _retry: number;
  67068. private _velocity;
  67069. private _basePoint;
  67070. private _epsilon;
  67071. /** @hidden */
  67072. _velocityWorldLength: number;
  67073. /** @hidden */
  67074. _basePointWorld: Vector3;
  67075. private _velocityWorld;
  67076. private _normalizedVelocity;
  67077. /** @hidden */
  67078. _initialVelocity: Vector3;
  67079. /** @hidden */
  67080. _initialPosition: Vector3;
  67081. private _nearestDistance;
  67082. private _collisionMask;
  67083. collisionMask: number;
  67084. /**
  67085. * Gets the plane normal used to compute the sliding response (in local space)
  67086. */
  67087. readonly slidePlaneNormal: Vector3;
  67088. /** @hidden */
  67089. _initialize(source: Vector3, dir: Vector3, e: number): void;
  67090. /** @hidden */
  67091. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  67092. /** @hidden */
  67093. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  67094. /** @hidden */
  67095. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  67096. /** @hidden */
  67097. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  67098. /** @hidden */
  67099. _getResponse(pos: Vector3, vel: Vector3): void;
  67100. }
  67101. }
  67102. declare module BABYLON {
  67103. /**
  67104. * Interface for cullable objects
  67105. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  67106. */
  67107. export interface ICullable {
  67108. /**
  67109. * Checks if the object or part of the object is in the frustum
  67110. * @param frustumPlanes Camera near/planes
  67111. * @returns true if the object is in frustum otherwise false
  67112. */
  67113. isInFrustum(frustumPlanes: Plane[]): boolean;
  67114. /**
  67115. * Checks if a cullable object (mesh...) is in the camera frustum
  67116. * Unlike isInFrustum this cheks the full bounding box
  67117. * @param frustumPlanes Camera near/planes
  67118. * @returns true if the object is in frustum otherwise false
  67119. */
  67120. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  67121. }
  67122. /**
  67123. * Info for a bounding data of a mesh
  67124. */
  67125. export class BoundingInfo implements ICullable {
  67126. /**
  67127. * Bounding box for the mesh
  67128. */
  67129. readonly boundingBox: BoundingBox;
  67130. /**
  67131. * Bounding sphere for the mesh
  67132. */
  67133. readonly boundingSphere: BoundingSphere;
  67134. private _isLocked;
  67135. private static readonly TmpVector3;
  67136. /**
  67137. * Constructs bounding info
  67138. * @param minimum min vector of the bounding box/sphere
  67139. * @param maximum max vector of the bounding box/sphere
  67140. * @param worldMatrix defines the new world matrix
  67141. */
  67142. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67143. /**
  67144. * Recreates the entire bounding info from scratch as if we call the constructor in place
  67145. * @param min defines the new minimum vector (in local space)
  67146. * @param max defines the new maximum vector (in local space)
  67147. * @param worldMatrix defines the new world matrix
  67148. */
  67149. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67150. /**
  67151. * min vector of the bounding box/sphere
  67152. */
  67153. readonly minimum: Vector3;
  67154. /**
  67155. * max vector of the bounding box/sphere
  67156. */
  67157. readonly maximum: Vector3;
  67158. /**
  67159. * If the info is locked and won't be updated to avoid perf overhead
  67160. */
  67161. isLocked: boolean;
  67162. /**
  67163. * Updates the bounding sphere and box
  67164. * @param world world matrix to be used to update
  67165. */
  67166. update(world: DeepImmutable<Matrix>): void;
  67167. /**
  67168. * Recreate the bounding info to be centered around a specific point given a specific extend.
  67169. * @param center New center of the bounding info
  67170. * @param extend New extend of the bounding info
  67171. * @returns the current bounding info
  67172. */
  67173. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  67174. /**
  67175. * Scale the current bounding info by applying a scale factor
  67176. * @param factor defines the scale factor to apply
  67177. * @returns the current bounding info
  67178. */
  67179. scale(factor: number): BoundingInfo;
  67180. /**
  67181. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  67182. * @param frustumPlanes defines the frustum to test
  67183. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  67184. * @returns true if the bounding info is in the frustum planes
  67185. */
  67186. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  67187. /**
  67188. * Gets the world distance between the min and max points of the bounding box
  67189. */
  67190. readonly diagonalLength: number;
  67191. /**
  67192. * Checks if a cullable object (mesh...) is in the camera frustum
  67193. * Unlike isInFrustum this cheks the full bounding box
  67194. * @param frustumPlanes Camera near/planes
  67195. * @returns true if the object is in frustum otherwise false
  67196. */
  67197. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67198. /** @hidden */
  67199. _checkCollision(collider: Collider): boolean;
  67200. /**
  67201. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  67202. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67203. * @param point the point to check intersection with
  67204. * @returns if the point intersects
  67205. */
  67206. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67207. /**
  67208. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  67209. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67210. * @param boundingInfo the bounding info to check intersection with
  67211. * @param precise if the intersection should be done using OBB
  67212. * @returns if the bounding info intersects
  67213. */
  67214. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  67215. }
  67216. }
  67217. declare module BABYLON {
  67218. /**
  67219. * Defines an array and its length.
  67220. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  67221. */
  67222. export interface ISmartArrayLike<T> {
  67223. /**
  67224. * The data of the array.
  67225. */
  67226. data: Array<T>;
  67227. /**
  67228. * The active length of the array.
  67229. */
  67230. length: number;
  67231. }
  67232. /**
  67233. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67234. */
  67235. export class SmartArray<T> implements ISmartArrayLike<T> {
  67236. /**
  67237. * The full set of data from the array.
  67238. */
  67239. data: Array<T>;
  67240. /**
  67241. * The active length of the array.
  67242. */
  67243. length: number;
  67244. protected _id: number;
  67245. /**
  67246. * Instantiates a Smart Array.
  67247. * @param capacity defines the default capacity of the array.
  67248. */
  67249. constructor(capacity: number);
  67250. /**
  67251. * Pushes a value at the end of the active data.
  67252. * @param value defines the object to push in the array.
  67253. */
  67254. push(value: T): void;
  67255. /**
  67256. * Iterates over the active data and apply the lambda to them.
  67257. * @param func defines the action to apply on each value.
  67258. */
  67259. forEach(func: (content: T) => void): void;
  67260. /**
  67261. * Sorts the full sets of data.
  67262. * @param compareFn defines the comparison function to apply.
  67263. */
  67264. sort(compareFn: (a: T, b: T) => number): void;
  67265. /**
  67266. * Resets the active data to an empty array.
  67267. */
  67268. reset(): void;
  67269. /**
  67270. * Releases all the data from the array as well as the array.
  67271. */
  67272. dispose(): void;
  67273. /**
  67274. * Concats the active data with a given array.
  67275. * @param array defines the data to concatenate with.
  67276. */
  67277. concat(array: any): void;
  67278. /**
  67279. * Returns the position of a value in the active data.
  67280. * @param value defines the value to find the index for
  67281. * @returns the index if found in the active data otherwise -1
  67282. */
  67283. indexOf(value: T): number;
  67284. /**
  67285. * Returns whether an element is part of the active data.
  67286. * @param value defines the value to look for
  67287. * @returns true if found in the active data otherwise false
  67288. */
  67289. contains(value: T): boolean;
  67290. private static _GlobalId;
  67291. }
  67292. /**
  67293. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67294. * The data in this array can only be present once
  67295. */
  67296. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67297. private _duplicateId;
  67298. /**
  67299. * Pushes a value at the end of the active data.
  67300. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67301. * @param value defines the object to push in the array.
  67302. */
  67303. push(value: T): void;
  67304. /**
  67305. * Pushes a value at the end of the active data.
  67306. * If the data is already present, it won t be added again
  67307. * @param value defines the object to push in the array.
  67308. * @returns true if added false if it was already present
  67309. */
  67310. pushNoDuplicate(value: T): boolean;
  67311. /**
  67312. * Resets the active data to an empty array.
  67313. */
  67314. reset(): void;
  67315. /**
  67316. * Concats the active data with a given array.
  67317. * This ensures no dupplicate will be present in the result.
  67318. * @param array defines the data to concatenate with.
  67319. */
  67320. concatWithNoDuplicate(array: any): void;
  67321. }
  67322. }
  67323. declare module BABYLON {
  67324. /**
  67325. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67326. * separate meshes. This can be use to improve performances.
  67327. * @see http://doc.babylonjs.com/how_to/multi_materials
  67328. */
  67329. export class MultiMaterial extends Material {
  67330. private _subMaterials;
  67331. /**
  67332. * Gets or Sets the list of Materials used within the multi material.
  67333. * They need to be ordered according to the submeshes order in the associated mesh
  67334. */
  67335. subMaterials: Nullable<Material>[];
  67336. /**
  67337. * Function used to align with Node.getChildren()
  67338. * @returns the list of Materials used within the multi material
  67339. */
  67340. getChildren(): Nullable<Material>[];
  67341. /**
  67342. * Instantiates a new Multi Material
  67343. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67344. * separate meshes. This can be use to improve performances.
  67345. * @see http://doc.babylonjs.com/how_to/multi_materials
  67346. * @param name Define the name in the scene
  67347. * @param scene Define the scene the material belongs to
  67348. */
  67349. constructor(name: string, scene: Scene);
  67350. private _hookArray;
  67351. /**
  67352. * Get one of the submaterial by its index in the submaterials array
  67353. * @param index The index to look the sub material at
  67354. * @returns The Material if the index has been defined
  67355. */
  67356. getSubMaterial(index: number): Nullable<Material>;
  67357. /**
  67358. * Get the list of active textures for the whole sub materials list.
  67359. * @returns All the textures that will be used during the rendering
  67360. */
  67361. getActiveTextures(): BaseTexture[];
  67362. /**
  67363. * Gets the current class name of the material e.g. "MultiMaterial"
  67364. * Mainly use in serialization.
  67365. * @returns the class name
  67366. */
  67367. getClassName(): string;
  67368. /**
  67369. * Checks if the material is ready to render the requested sub mesh
  67370. * @param mesh Define the mesh the submesh belongs to
  67371. * @param subMesh Define the sub mesh to look readyness for
  67372. * @param useInstances Define whether or not the material is used with instances
  67373. * @returns true if ready, otherwise false
  67374. */
  67375. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67376. /**
  67377. * Clones the current material and its related sub materials
  67378. * @param name Define the name of the newly cloned material
  67379. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67380. * @returns the cloned material
  67381. */
  67382. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67383. /**
  67384. * Serializes the materials into a JSON representation.
  67385. * @returns the JSON representation
  67386. */
  67387. serialize(): any;
  67388. /**
  67389. * Dispose the material and release its associated resources
  67390. * @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)
  67391. * @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)
  67392. * @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)
  67393. */
  67394. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67395. /**
  67396. * Creates a MultiMaterial from parsed MultiMaterial data.
  67397. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67398. * @param scene defines the hosting scene
  67399. * @returns a new MultiMaterial
  67400. */
  67401. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67402. }
  67403. }
  67404. declare module BABYLON {
  67405. /**
  67406. * Class used to represent data loading progression
  67407. */
  67408. export class SceneLoaderFlags {
  67409. private static _ForceFullSceneLoadingForIncremental;
  67410. private static _ShowLoadingScreen;
  67411. private static _CleanBoneMatrixWeights;
  67412. private static _loggingLevel;
  67413. /**
  67414. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67415. */
  67416. static ForceFullSceneLoadingForIncremental: boolean;
  67417. /**
  67418. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67419. */
  67420. static ShowLoadingScreen: boolean;
  67421. /**
  67422. * Defines the current logging level (while loading the scene)
  67423. * @ignorenaming
  67424. */
  67425. static loggingLevel: number;
  67426. /**
  67427. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67428. */
  67429. static CleanBoneMatrixWeights: boolean;
  67430. }
  67431. }
  67432. declare module BABYLON {
  67433. /**
  67434. * 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.
  67435. * @see https://doc.babylonjs.com/how_to/transformnode
  67436. */
  67437. export class TransformNode extends Node {
  67438. /**
  67439. * Object will not rotate to face the camera
  67440. */
  67441. static BILLBOARDMODE_NONE: number;
  67442. /**
  67443. * Object will rotate to face the camera but only on the x axis
  67444. */
  67445. static BILLBOARDMODE_X: number;
  67446. /**
  67447. * Object will rotate to face the camera but only on the y axis
  67448. */
  67449. static BILLBOARDMODE_Y: number;
  67450. /**
  67451. * Object will rotate to face the camera but only on the z axis
  67452. */
  67453. static BILLBOARDMODE_Z: number;
  67454. /**
  67455. * Object will rotate to face the camera
  67456. */
  67457. static BILLBOARDMODE_ALL: number;
  67458. private _forward;
  67459. private _forwardInverted;
  67460. private _up;
  67461. private _right;
  67462. private _rightInverted;
  67463. private _position;
  67464. private _rotation;
  67465. private _rotationQuaternion;
  67466. protected _scaling: Vector3;
  67467. protected _isDirty: boolean;
  67468. private _transformToBoneReferal;
  67469. private _billboardMode;
  67470. /**
  67471. * Gets or sets the billboard mode. Default is 0.
  67472. *
  67473. * | Value | Type | Description |
  67474. * | --- | --- | --- |
  67475. * | 0 | BILLBOARDMODE_NONE | |
  67476. * | 1 | BILLBOARDMODE_X | |
  67477. * | 2 | BILLBOARDMODE_Y | |
  67478. * | 4 | BILLBOARDMODE_Z | |
  67479. * | 7 | BILLBOARDMODE_ALL | |
  67480. *
  67481. */
  67482. billboardMode: number;
  67483. private _preserveParentRotationForBillboard;
  67484. /**
  67485. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67486. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67487. */
  67488. preserveParentRotationForBillboard: boolean;
  67489. /**
  67490. * 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
  67491. */
  67492. scalingDeterminant: number;
  67493. private _infiniteDistance;
  67494. /**
  67495. * Gets or sets the distance of the object to max, often used by skybox
  67496. */
  67497. infiniteDistance: boolean;
  67498. /**
  67499. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67500. * By default the system will update normals to compensate
  67501. */
  67502. ignoreNonUniformScaling: boolean;
  67503. /**
  67504. * 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
  67505. */
  67506. reIntegrateRotationIntoRotationQuaternion: boolean;
  67507. /** @hidden */
  67508. _poseMatrix: Nullable<Matrix>;
  67509. /** @hidden */
  67510. _localMatrix: Matrix;
  67511. private _usePivotMatrix;
  67512. private _absolutePosition;
  67513. private _pivotMatrix;
  67514. private _pivotMatrixInverse;
  67515. protected _postMultiplyPivotMatrix: boolean;
  67516. protected _isWorldMatrixFrozen: boolean;
  67517. /** @hidden */
  67518. _indexInSceneTransformNodesArray: number;
  67519. /**
  67520. * An event triggered after the world matrix is updated
  67521. */
  67522. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67523. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67524. /**
  67525. * Gets a string identifying the name of the class
  67526. * @returns "TransformNode" string
  67527. */
  67528. getClassName(): string;
  67529. /**
  67530. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67531. */
  67532. position: Vector3;
  67533. /**
  67534. * 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)).
  67535. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67536. */
  67537. rotation: Vector3;
  67538. /**
  67539. * 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)).
  67540. */
  67541. scaling: Vector3;
  67542. /**
  67543. * 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).
  67544. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67545. */
  67546. rotationQuaternion: Nullable<Quaternion>;
  67547. /**
  67548. * The forward direction of that transform in world space.
  67549. */
  67550. readonly forward: Vector3;
  67551. /**
  67552. * The up direction of that transform in world space.
  67553. */
  67554. readonly up: Vector3;
  67555. /**
  67556. * The right direction of that transform in world space.
  67557. */
  67558. readonly right: Vector3;
  67559. /**
  67560. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67561. * @param matrix the matrix to copy the pose from
  67562. * @returns this TransformNode.
  67563. */
  67564. updatePoseMatrix(matrix: Matrix): TransformNode;
  67565. /**
  67566. * Returns the mesh Pose matrix.
  67567. * @returns the pose matrix
  67568. */
  67569. getPoseMatrix(): Matrix;
  67570. /** @hidden */
  67571. _isSynchronized(): boolean;
  67572. /** @hidden */
  67573. _initCache(): void;
  67574. /**
  67575. * Flag the transform node as dirty (Forcing it to update everything)
  67576. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67577. * @returns this transform node
  67578. */
  67579. markAsDirty(property: string): TransformNode;
  67580. /**
  67581. * Returns the current mesh absolute position.
  67582. * Returns a Vector3.
  67583. */
  67584. readonly absolutePosition: Vector3;
  67585. /**
  67586. * Sets a new matrix to apply before all other transformation
  67587. * @param matrix defines the transform matrix
  67588. * @returns the current TransformNode
  67589. */
  67590. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67591. /**
  67592. * Sets a new pivot matrix to the current node
  67593. * @param matrix defines the new pivot matrix to use
  67594. * @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
  67595. * @returns the current TransformNode
  67596. */
  67597. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67598. /**
  67599. * Returns the mesh pivot matrix.
  67600. * Default : Identity.
  67601. * @returns the matrix
  67602. */
  67603. getPivotMatrix(): Matrix;
  67604. /**
  67605. * Prevents the World matrix to be computed any longer.
  67606. * @returns the TransformNode.
  67607. */
  67608. freezeWorldMatrix(): TransformNode;
  67609. /**
  67610. * Allows back the World matrix computation.
  67611. * @returns the TransformNode.
  67612. */
  67613. unfreezeWorldMatrix(): this;
  67614. /**
  67615. * True if the World matrix has been frozen.
  67616. */
  67617. readonly isWorldMatrixFrozen: boolean;
  67618. /**
  67619. * Retuns the mesh absolute position in the World.
  67620. * @returns a Vector3.
  67621. */
  67622. getAbsolutePosition(): Vector3;
  67623. /**
  67624. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67625. * @param absolutePosition the absolute position to set
  67626. * @returns the TransformNode.
  67627. */
  67628. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67629. /**
  67630. * Sets the mesh position in its local space.
  67631. * @param vector3 the position to set in localspace
  67632. * @returns the TransformNode.
  67633. */
  67634. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67635. /**
  67636. * Returns the mesh position in the local space from the current World matrix values.
  67637. * @returns a new Vector3.
  67638. */
  67639. getPositionExpressedInLocalSpace(): Vector3;
  67640. /**
  67641. * Translates the mesh along the passed Vector3 in its local space.
  67642. * @param vector3 the distance to translate in localspace
  67643. * @returns the TransformNode.
  67644. */
  67645. locallyTranslate(vector3: Vector3): TransformNode;
  67646. private static _lookAtVectorCache;
  67647. /**
  67648. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67649. * @param targetPoint the position (must be in same space as current mesh) to look at
  67650. * @param yawCor optional yaw (y-axis) correction in radians
  67651. * @param pitchCor optional pitch (x-axis) correction in radians
  67652. * @param rollCor optional roll (z-axis) correction in radians
  67653. * @param space the choosen space of the target
  67654. * @returns the TransformNode.
  67655. */
  67656. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67657. /**
  67658. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67659. * This Vector3 is expressed in the World space.
  67660. * @param localAxis axis to rotate
  67661. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67662. */
  67663. getDirection(localAxis: Vector3): Vector3;
  67664. /**
  67665. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67666. * localAxis is expressed in the mesh local space.
  67667. * result is computed in the Wordl space from the mesh World matrix.
  67668. * @param localAxis axis to rotate
  67669. * @param result the resulting transformnode
  67670. * @returns this TransformNode.
  67671. */
  67672. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67673. /**
  67674. * Sets this transform node rotation to the given local axis.
  67675. * @param localAxis the axis in local space
  67676. * @param yawCor optional yaw (y-axis) correction in radians
  67677. * @param pitchCor optional pitch (x-axis) correction in radians
  67678. * @param rollCor optional roll (z-axis) correction in radians
  67679. * @returns this TransformNode
  67680. */
  67681. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67682. /**
  67683. * Sets a new pivot point to the current node
  67684. * @param point defines the new pivot point to use
  67685. * @param space defines if the point is in world or local space (local by default)
  67686. * @returns the current TransformNode
  67687. */
  67688. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67689. /**
  67690. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67691. * @returns the pivot point
  67692. */
  67693. getPivotPoint(): Vector3;
  67694. /**
  67695. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67696. * @param result the vector3 to store the result
  67697. * @returns this TransformNode.
  67698. */
  67699. getPivotPointToRef(result: Vector3): TransformNode;
  67700. /**
  67701. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67702. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67703. */
  67704. getAbsolutePivotPoint(): Vector3;
  67705. /**
  67706. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67707. * @param result vector3 to store the result
  67708. * @returns this TransformNode.
  67709. */
  67710. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67711. /**
  67712. * Defines the passed node as the parent of the current node.
  67713. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67714. * @see https://doc.babylonjs.com/how_to/parenting
  67715. * @param node the node ot set as the parent
  67716. * @returns this TransformNode.
  67717. */
  67718. setParent(node: Nullable<Node>): TransformNode;
  67719. private _nonUniformScaling;
  67720. /**
  67721. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67722. */
  67723. readonly nonUniformScaling: boolean;
  67724. /** @hidden */
  67725. _updateNonUniformScalingState(value: boolean): boolean;
  67726. /**
  67727. * Attach the current TransformNode to another TransformNode associated with a bone
  67728. * @param bone Bone affecting the TransformNode
  67729. * @param affectedTransformNode TransformNode associated with the bone
  67730. * @returns this object
  67731. */
  67732. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67733. /**
  67734. * Detach the transform node if its associated with a bone
  67735. * @returns this object
  67736. */
  67737. detachFromBone(): TransformNode;
  67738. private static _rotationAxisCache;
  67739. /**
  67740. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67741. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67742. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67743. * The passed axis is also normalized.
  67744. * @param axis the axis to rotate around
  67745. * @param amount the amount to rotate in radians
  67746. * @param space Space to rotate in (Default: local)
  67747. * @returns the TransformNode.
  67748. */
  67749. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67750. /**
  67751. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67752. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67753. * The passed axis is also normalized. .
  67754. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67755. * @param point the point to rotate around
  67756. * @param axis the axis to rotate around
  67757. * @param amount the amount to rotate in radians
  67758. * @returns the TransformNode
  67759. */
  67760. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67761. /**
  67762. * Translates the mesh along the axis vector for the passed distance in the given space.
  67763. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67764. * @param axis the axis to translate in
  67765. * @param distance the distance to translate
  67766. * @param space Space to rotate in (Default: local)
  67767. * @returns the TransformNode.
  67768. */
  67769. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67770. /**
  67771. * Adds a rotation step to the mesh current rotation.
  67772. * x, y, z are Euler angles expressed in radians.
  67773. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67774. * This means this rotation is made in the mesh local space only.
  67775. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67776. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67777. * ```javascript
  67778. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67779. * ```
  67780. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67781. * 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.
  67782. * @param x Rotation to add
  67783. * @param y Rotation to add
  67784. * @param z Rotation to add
  67785. * @returns the TransformNode.
  67786. */
  67787. addRotation(x: number, y: number, z: number): TransformNode;
  67788. /**
  67789. * @hidden
  67790. */
  67791. protected _getEffectiveParent(): Nullable<Node>;
  67792. /**
  67793. * Computes the world matrix of the node
  67794. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67795. * @returns the world matrix
  67796. */
  67797. computeWorldMatrix(force?: boolean): Matrix;
  67798. protected _afterComputeWorldMatrix(): void;
  67799. /**
  67800. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67801. * @param func callback function to add
  67802. *
  67803. * @returns the TransformNode.
  67804. */
  67805. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67806. /**
  67807. * Removes a registered callback function.
  67808. * @param func callback function to remove
  67809. * @returns the TransformNode.
  67810. */
  67811. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67812. /**
  67813. * Gets the position of the current mesh in camera space
  67814. * @param camera defines the camera to use
  67815. * @returns a position
  67816. */
  67817. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67818. /**
  67819. * Returns the distance from the mesh to the active camera
  67820. * @param camera defines the camera to use
  67821. * @returns the distance
  67822. */
  67823. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67824. /**
  67825. * Clone the current transform node
  67826. * @param name Name of the new clone
  67827. * @param newParent New parent for the clone
  67828. * @param doNotCloneChildren Do not clone children hierarchy
  67829. * @returns the new transform node
  67830. */
  67831. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67832. /**
  67833. * Serializes the objects information.
  67834. * @param currentSerializationObject defines the object to serialize in
  67835. * @returns the serialized object
  67836. */
  67837. serialize(currentSerializationObject?: any): any;
  67838. /**
  67839. * Returns a new TransformNode object parsed from the source provided.
  67840. * @param parsedTransformNode is the source.
  67841. * @param scene the scne the object belongs to
  67842. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67843. * @returns a new TransformNode object parsed from the source provided.
  67844. */
  67845. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67846. /**
  67847. * Get all child-transformNodes of this node
  67848. * @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
  67849. * @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
  67850. * @returns an array of TransformNode
  67851. */
  67852. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67853. /**
  67854. * Releases resources associated with this transform node.
  67855. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67856. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67857. */
  67858. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67859. }
  67860. }
  67861. declare module BABYLON {
  67862. /**
  67863. * Class used to override all child animations of a given target
  67864. */
  67865. export class AnimationPropertiesOverride {
  67866. /**
  67867. * Gets or sets a value indicating if animation blending must be used
  67868. */
  67869. enableBlending: boolean;
  67870. /**
  67871. * Gets or sets the blending speed to use when enableBlending is true
  67872. */
  67873. blendingSpeed: number;
  67874. /**
  67875. * Gets or sets the default loop mode to use
  67876. */
  67877. loopMode: number;
  67878. }
  67879. }
  67880. declare module BABYLON {
  67881. /**
  67882. * Class used to store bone information
  67883. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67884. */
  67885. export class Bone extends Node {
  67886. /**
  67887. * defines the bone name
  67888. */
  67889. name: string;
  67890. private static _tmpVecs;
  67891. private static _tmpQuat;
  67892. private static _tmpMats;
  67893. /**
  67894. * Gets the list of child bones
  67895. */
  67896. children: Bone[];
  67897. /** Gets the animations associated with this bone */
  67898. animations: Animation[];
  67899. /**
  67900. * Gets or sets bone length
  67901. */
  67902. length: number;
  67903. /**
  67904. * @hidden Internal only
  67905. * Set this value to map this bone to a different index in the transform matrices
  67906. * Set this value to -1 to exclude the bone from the transform matrices
  67907. */
  67908. _index: Nullable<number>;
  67909. private _skeleton;
  67910. private _localMatrix;
  67911. private _restPose;
  67912. private _baseMatrix;
  67913. private _absoluteTransform;
  67914. private _invertedAbsoluteTransform;
  67915. private _parent;
  67916. private _scalingDeterminant;
  67917. private _worldTransform;
  67918. private _localScaling;
  67919. private _localRotation;
  67920. private _localPosition;
  67921. private _needToDecompose;
  67922. private _needToCompose;
  67923. /** @hidden */
  67924. _linkedTransformNode: Nullable<TransformNode>;
  67925. /** @hidden */
  67926. /** @hidden */
  67927. _matrix: Matrix;
  67928. /**
  67929. * Create a new bone
  67930. * @param name defines the bone name
  67931. * @param skeleton defines the parent skeleton
  67932. * @param parentBone defines the parent (can be null if the bone is the root)
  67933. * @param localMatrix defines the local matrix
  67934. * @param restPose defines the rest pose matrix
  67935. * @param baseMatrix defines the base matrix
  67936. * @param index defines index of the bone in the hiearchy
  67937. */
  67938. constructor(
  67939. /**
  67940. * defines the bone name
  67941. */
  67942. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67943. /**
  67944. * Gets the current object class name.
  67945. * @return the class name
  67946. */
  67947. getClassName(): string;
  67948. /**
  67949. * Gets the parent skeleton
  67950. * @returns a skeleton
  67951. */
  67952. getSkeleton(): Skeleton;
  67953. /**
  67954. * Gets parent bone
  67955. * @returns a bone or null if the bone is the root of the bone hierarchy
  67956. */
  67957. getParent(): Nullable<Bone>;
  67958. /**
  67959. * Returns an array containing the root bones
  67960. * @returns an array containing the root bones
  67961. */
  67962. getChildren(): Array<Bone>;
  67963. /**
  67964. * Sets the parent bone
  67965. * @param parent defines the parent (can be null if the bone is the root)
  67966. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67967. */
  67968. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67969. /**
  67970. * Gets the local matrix
  67971. * @returns a matrix
  67972. */
  67973. getLocalMatrix(): Matrix;
  67974. /**
  67975. * Gets the base matrix (initial matrix which remains unchanged)
  67976. * @returns a matrix
  67977. */
  67978. getBaseMatrix(): Matrix;
  67979. /**
  67980. * Gets the rest pose matrix
  67981. * @returns a matrix
  67982. */
  67983. getRestPose(): Matrix;
  67984. /**
  67985. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67986. */
  67987. getWorldMatrix(): Matrix;
  67988. /**
  67989. * Sets the local matrix to rest pose matrix
  67990. */
  67991. returnToRest(): void;
  67992. /**
  67993. * Gets the inverse of the absolute transform matrix.
  67994. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67995. * @returns a matrix
  67996. */
  67997. getInvertedAbsoluteTransform(): Matrix;
  67998. /**
  67999. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  68000. * @returns a matrix
  68001. */
  68002. getAbsoluteTransform(): Matrix;
  68003. /**
  68004. * Links with the given transform node.
  68005. * The local matrix of this bone is copied from the transform node every frame.
  68006. * @param transformNode defines the transform node to link to
  68007. */
  68008. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  68009. /** Gets or sets current position (in local space) */
  68010. position: Vector3;
  68011. /** Gets or sets current rotation (in local space) */
  68012. rotation: Vector3;
  68013. /** Gets or sets current rotation quaternion (in local space) */
  68014. rotationQuaternion: Quaternion;
  68015. /** Gets or sets current scaling (in local space) */
  68016. scaling: Vector3;
  68017. /**
  68018. * Gets the animation properties override
  68019. */
  68020. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  68021. private _decompose;
  68022. private _compose;
  68023. /**
  68024. * Update the base and local matrices
  68025. * @param matrix defines the new base or local matrix
  68026. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68027. * @param updateLocalMatrix defines if the local matrix should be updated
  68028. */
  68029. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  68030. /** @hidden */
  68031. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  68032. /**
  68033. * Flag the bone as dirty (Forcing it to update everything)
  68034. */
  68035. markAsDirty(): void;
  68036. private _markAsDirtyAndCompose;
  68037. private _markAsDirtyAndDecompose;
  68038. /**
  68039. * Translate the bone in local or world space
  68040. * @param vec The amount to translate the bone
  68041. * @param space The space that the translation is in
  68042. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68043. */
  68044. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68045. /**
  68046. * Set the postion of the bone in local or world space
  68047. * @param position The position to set the bone
  68048. * @param space The space that the position is in
  68049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68050. */
  68051. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68052. /**
  68053. * Set the absolute position of the bone (world space)
  68054. * @param position The position to set the bone
  68055. * @param mesh The mesh that this bone is attached to
  68056. */
  68057. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  68058. /**
  68059. * Scale the bone on the x, y and z axes (in local space)
  68060. * @param x The amount to scale the bone on the x axis
  68061. * @param y The amount to scale the bone on the y axis
  68062. * @param z The amount to scale the bone on the z axis
  68063. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  68064. */
  68065. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  68066. /**
  68067. * Set the bone scaling in local space
  68068. * @param scale defines the scaling vector
  68069. */
  68070. setScale(scale: Vector3): void;
  68071. /**
  68072. * Gets the current scaling in local space
  68073. * @returns the current scaling vector
  68074. */
  68075. getScale(): Vector3;
  68076. /**
  68077. * Gets the current scaling in local space and stores it in a target vector
  68078. * @param result defines the target vector
  68079. */
  68080. getScaleToRef(result: Vector3): void;
  68081. /**
  68082. * Set the yaw, pitch, and roll of the bone in local or world space
  68083. * @param yaw The rotation of the bone on the y axis
  68084. * @param pitch The rotation of the bone on the x axis
  68085. * @param roll The rotation of the bone on the z axis
  68086. * @param space The space that the axes of rotation are in
  68087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68088. */
  68089. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  68090. /**
  68091. * Add a rotation to the bone on an axis in local or world space
  68092. * @param axis The axis to rotate the bone on
  68093. * @param amount The amount to rotate the bone
  68094. * @param space The space that the axis is in
  68095. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68096. */
  68097. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  68098. /**
  68099. * Set the rotation of the bone to a particular axis angle in local or world space
  68100. * @param axis The axis to rotate the bone on
  68101. * @param angle The angle that the bone should be rotated to
  68102. * @param space The space that the axis is in
  68103. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68104. */
  68105. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  68106. /**
  68107. * Set the euler rotation of the bone in local of world space
  68108. * @param rotation The euler rotation that the bone should be set to
  68109. * @param space The space that the rotation is in
  68110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68111. */
  68112. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68113. /**
  68114. * Set the quaternion rotation of the bone in local of world space
  68115. * @param quat The quaternion rotation that the bone should be set to
  68116. * @param space The space that the rotation is in
  68117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68118. */
  68119. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  68120. /**
  68121. * Set the rotation matrix of the bone in local of world space
  68122. * @param rotMat The rotation matrix that the bone should be set to
  68123. * @param space The space that the rotation is in
  68124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68125. */
  68126. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  68127. private _rotateWithMatrix;
  68128. private _getNegativeRotationToRef;
  68129. /**
  68130. * Get the position of the bone in local or world space
  68131. * @param space The space that the returned position is in
  68132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68133. * @returns The position of the bone
  68134. */
  68135. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68136. /**
  68137. * Copy the position of the bone to a vector3 in local or world space
  68138. * @param space The space that the returned position is in
  68139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68140. * @param result The vector3 to copy the position to
  68141. */
  68142. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  68143. /**
  68144. * Get the absolute position of the bone (world space)
  68145. * @param mesh The mesh that this bone is attached to
  68146. * @returns The absolute position of the bone
  68147. */
  68148. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  68149. /**
  68150. * Copy the absolute position of the bone (world space) to the result param
  68151. * @param mesh The mesh that this bone is attached to
  68152. * @param result The vector3 to copy the absolute position to
  68153. */
  68154. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  68155. /**
  68156. * Compute the absolute transforms of this bone and its children
  68157. */
  68158. computeAbsoluteTransforms(): void;
  68159. /**
  68160. * Get the world direction from an axis that is in the local space of the bone
  68161. * @param localAxis The local direction that is used to compute the world direction
  68162. * @param mesh The mesh that this bone is attached to
  68163. * @returns The world direction
  68164. */
  68165. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68166. /**
  68167. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  68168. * @param localAxis The local direction that is used to compute the world direction
  68169. * @param mesh The mesh that this bone is attached to
  68170. * @param result The vector3 that the world direction will be copied to
  68171. */
  68172. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68173. /**
  68174. * Get the euler rotation of the bone in local or world space
  68175. * @param space The space that the rotation should be in
  68176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68177. * @returns The euler rotation
  68178. */
  68179. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68180. /**
  68181. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  68182. * @param space The space that the rotation should be in
  68183. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68184. * @param result The vector3 that the rotation should be copied to
  68185. */
  68186. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68187. /**
  68188. * Get the quaternion rotation of the bone in either local or world space
  68189. * @param space The space that the rotation should be in
  68190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68191. * @returns The quaternion rotation
  68192. */
  68193. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  68194. /**
  68195. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  68196. * @param space The space that the rotation should be in
  68197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68198. * @param result The quaternion that the rotation should be copied to
  68199. */
  68200. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  68201. /**
  68202. * Get the rotation matrix of the bone in local or world space
  68203. * @param space The space that the rotation should be in
  68204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68205. * @returns The rotation matrix
  68206. */
  68207. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  68208. /**
  68209. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  68210. * @param space The space that the rotation should be in
  68211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68212. * @param result The quaternion that the rotation should be copied to
  68213. */
  68214. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  68215. /**
  68216. * Get the world position of a point that is in the local space of the bone
  68217. * @param position The local position
  68218. * @param mesh The mesh that this bone is attached to
  68219. * @returns The world position
  68220. */
  68221. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68222. /**
  68223. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68224. * @param position The local position
  68225. * @param mesh The mesh that this bone is attached to
  68226. * @param result The vector3 that the world position should be copied to
  68227. */
  68228. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68229. /**
  68230. * Get the local position of a point that is in world space
  68231. * @param position The world position
  68232. * @param mesh The mesh that this bone is attached to
  68233. * @returns The local position
  68234. */
  68235. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68236. /**
  68237. * Get the local position of a point that is in world space and copy it to the result param
  68238. * @param position The world position
  68239. * @param mesh The mesh that this bone is attached to
  68240. * @param result The vector3 that the local position should be copied to
  68241. */
  68242. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68243. }
  68244. }
  68245. declare module BABYLON {
  68246. /**
  68247. * Enum that determines the text-wrapping mode to use.
  68248. */
  68249. export enum InspectableType {
  68250. /**
  68251. * Checkbox for booleans
  68252. */
  68253. Checkbox = 0,
  68254. /**
  68255. * Sliders for numbers
  68256. */
  68257. Slider = 1,
  68258. /**
  68259. * Vector3
  68260. */
  68261. Vector3 = 2,
  68262. /**
  68263. * Quaternions
  68264. */
  68265. Quaternion = 3,
  68266. /**
  68267. * Color3
  68268. */
  68269. Color3 = 4
  68270. }
  68271. /**
  68272. * Interface used to define custom inspectable properties.
  68273. * This interface is used by the inspector to display custom property grids
  68274. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68275. */
  68276. export interface IInspectable {
  68277. /**
  68278. * Gets the label to display
  68279. */
  68280. label: string;
  68281. /**
  68282. * Gets the name of the property to edit
  68283. */
  68284. propertyName: string;
  68285. /**
  68286. * Gets the type of the editor to use
  68287. */
  68288. type: InspectableType;
  68289. /**
  68290. * Gets the minimum value of the property when using in "slider" mode
  68291. */
  68292. min?: number;
  68293. /**
  68294. * Gets the maximum value of the property when using in "slider" mode
  68295. */
  68296. max?: number;
  68297. /**
  68298. * Gets the setp to use when using in "slider" mode
  68299. */
  68300. step?: number;
  68301. }
  68302. }
  68303. declare module BABYLON {
  68304. /**
  68305. * This represents the required contract to create a new type of texture loader.
  68306. */
  68307. export interface IInternalTextureLoader {
  68308. /**
  68309. * Defines wether the loader supports cascade loading the different faces.
  68310. */
  68311. supportCascades: boolean;
  68312. /**
  68313. * This returns if the loader support the current file information.
  68314. * @param extension defines the file extension of the file being loaded
  68315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68316. * @param fallback defines the fallback internal texture if any
  68317. * @param isBase64 defines whether the texture is encoded as a base64
  68318. * @param isBuffer defines whether the texture data are stored as a buffer
  68319. * @returns true if the loader can load the specified file
  68320. */
  68321. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68322. /**
  68323. * Transform the url before loading if required.
  68324. * @param rootUrl the url of the texture
  68325. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68326. * @returns the transformed texture
  68327. */
  68328. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68329. /**
  68330. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68331. * @param rootUrl the url of the texture
  68332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68333. * @returns the fallback texture
  68334. */
  68335. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68336. /**
  68337. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68338. * @param data contains the texture data
  68339. * @param texture defines the BabylonJS internal texture
  68340. * @param createPolynomials will be true if polynomials have been requested
  68341. * @param onLoad defines the callback to trigger once the texture is ready
  68342. * @param onError defines the callback to trigger in case of error
  68343. */
  68344. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68345. /**
  68346. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68347. * @param data contains the texture data
  68348. * @param texture defines the BabylonJS internal texture
  68349. * @param callback defines the method to call once ready to upload
  68350. */
  68351. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68352. }
  68353. }
  68354. declare module BABYLON {
  68355. interface Engine {
  68356. /**
  68357. * Creates a depth stencil cube texture.
  68358. * This is only available in WebGL 2.
  68359. * @param size The size of face edge in the cube texture.
  68360. * @param options The options defining the cube texture.
  68361. * @returns The cube texture
  68362. */
  68363. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68364. /**
  68365. * Creates a cube texture
  68366. * @param rootUrl defines the url where the files to load is located
  68367. * @param scene defines the current scene
  68368. * @param files defines the list of files to load (1 per face)
  68369. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68370. * @param onLoad defines an optional callback raised when the texture is loaded
  68371. * @param onError defines an optional callback raised if there is an issue to load the texture
  68372. * @param format defines the format of the data
  68373. * @param forcedExtension defines the extension to use to pick the right loader
  68374. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68375. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68376. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68377. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68378. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68379. * @returns the cube texture as an InternalTexture
  68380. */
  68381. 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;
  68382. /**
  68383. * Creates a cube texture
  68384. * @param rootUrl defines the url where the files to load is located
  68385. * @param scene defines the current scene
  68386. * @param files defines the list of files to load (1 per face)
  68387. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68388. * @param onLoad defines an optional callback raised when the texture is loaded
  68389. * @param onError defines an optional callback raised if there is an issue to load the texture
  68390. * @param format defines the format of the data
  68391. * @param forcedExtension defines the extension to use to pick the right loader
  68392. * @returns the cube texture as an InternalTexture
  68393. */
  68394. 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;
  68395. /**
  68396. * Creates a cube texture
  68397. * @param rootUrl defines the url where the files to load is located
  68398. * @param scene defines the current scene
  68399. * @param files defines the list of files to load (1 per face)
  68400. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68401. * @param onLoad defines an optional callback raised when the texture is loaded
  68402. * @param onError defines an optional callback raised if there is an issue to load the texture
  68403. * @param format defines the format of the data
  68404. * @param forcedExtension defines the extension to use to pick the right loader
  68405. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68406. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68407. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68408. * @returns the cube texture as an InternalTexture
  68409. */
  68410. 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;
  68411. /** @hidden */
  68412. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68413. /** @hidden */
  68414. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68415. /** @hidden */
  68416. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68417. /** @hidden */
  68418. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68419. }
  68420. }
  68421. declare module BABYLON {
  68422. /**
  68423. * Class for creating a cube texture
  68424. */
  68425. export class CubeTexture extends BaseTexture {
  68426. private _delayedOnLoad;
  68427. /**
  68428. * The url of the texture
  68429. */
  68430. url: string;
  68431. /**
  68432. * Gets or sets the center of the bounding box associated with the cube texture.
  68433. * It must define where the camera used to render the texture was set
  68434. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68435. */
  68436. boundingBoxPosition: Vector3;
  68437. private _boundingBoxSize;
  68438. /**
  68439. * Gets or sets the size of the bounding box associated with the cube texture
  68440. * When defined, the cubemap will switch to local mode
  68441. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68442. * @example https://www.babylonjs-playground.com/#RNASML
  68443. */
  68444. /**
  68445. * Returns the bounding box size
  68446. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68447. */
  68448. boundingBoxSize: Vector3;
  68449. protected _rotationY: number;
  68450. /**
  68451. * Sets texture matrix rotation angle around Y axis in radians.
  68452. */
  68453. /**
  68454. * Gets texture matrix rotation angle around Y axis radians.
  68455. */
  68456. rotationY: number;
  68457. /**
  68458. * Are mip maps generated for this texture or not.
  68459. */
  68460. readonly noMipmap: boolean;
  68461. private _noMipmap;
  68462. private _files;
  68463. private _extensions;
  68464. private _textureMatrix;
  68465. private _format;
  68466. private _createPolynomials;
  68467. /** @hidden */
  68468. _prefiltered: boolean;
  68469. /**
  68470. * Creates a cube texture from an array of image urls
  68471. * @param files defines an array of image urls
  68472. * @param scene defines the hosting scene
  68473. * @param noMipmap specifies if mip maps are not used
  68474. * @returns a cube texture
  68475. */
  68476. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68477. /**
  68478. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68479. * @param url defines the url of the prefiltered texture
  68480. * @param scene defines the scene the texture is attached to
  68481. * @param forcedExtension defines the extension of the file if different from the url
  68482. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68483. * @return the prefiltered texture
  68484. */
  68485. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68486. /**
  68487. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68488. * as prefiltered data.
  68489. * @param rootUrl defines the url of the texture or the root name of the six images
  68490. * @param scene defines the scene the texture is attached to
  68491. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68492. * @param noMipmap defines if mipmaps should be created or not
  68493. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68494. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68495. * @param onError defines a callback triggered in case of error during load
  68496. * @param format defines the internal format to use for the texture once loaded
  68497. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68498. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68499. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68500. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68501. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68502. * @return the cube texture
  68503. */
  68504. 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);
  68505. /**
  68506. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  68507. */
  68508. readonly isPrefiltered: boolean;
  68509. /**
  68510. * Get the current class name of the texture useful for serialization or dynamic coding.
  68511. * @returns "CubeTexture"
  68512. */
  68513. getClassName(): string;
  68514. /**
  68515. * Update the url (and optional buffer) of this texture if url was null during construction.
  68516. * @param url the url of the texture
  68517. * @param forcedExtension defines the extension to use
  68518. * @param onLoad callback called when the texture is loaded (defaults to null)
  68519. */
  68520. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68521. /**
  68522. * Delays loading of the cube texture
  68523. * @param forcedExtension defines the extension to use
  68524. */
  68525. delayLoad(forcedExtension?: string): void;
  68526. /**
  68527. * Returns the reflection texture matrix
  68528. * @returns the reflection texture matrix
  68529. */
  68530. getReflectionTextureMatrix(): Matrix;
  68531. /**
  68532. * Sets the reflection texture matrix
  68533. * @param value Reflection texture matrix
  68534. */
  68535. setReflectionTextureMatrix(value: Matrix): void;
  68536. /**
  68537. * Parses text to create a cube texture
  68538. * @param parsedTexture define the serialized text to read from
  68539. * @param scene defines the hosting scene
  68540. * @param rootUrl defines the root url of the cube texture
  68541. * @returns a cube texture
  68542. */
  68543. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68544. /**
  68545. * Makes a clone, or deep copy, of the cube texture
  68546. * @returns a new cube texture
  68547. */
  68548. clone(): CubeTexture;
  68549. }
  68550. }
  68551. declare module BABYLON {
  68552. /** @hidden */
  68553. export var postprocessVertexShader: {
  68554. name: string;
  68555. shader: string;
  68556. };
  68557. }
  68558. declare module BABYLON {
  68559. /**
  68560. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68561. * This is the base of the follow, arc rotate cameras and Free camera
  68562. * @see http://doc.babylonjs.com/features/cameras
  68563. */
  68564. export class TargetCamera extends Camera {
  68565. private static _RigCamTransformMatrix;
  68566. private static _TargetTransformMatrix;
  68567. private static _TargetFocalPoint;
  68568. /**
  68569. * Define the current direction the camera is moving to
  68570. */
  68571. cameraDirection: Vector3;
  68572. /**
  68573. * Define the current rotation the camera is rotating to
  68574. */
  68575. cameraRotation: Vector2;
  68576. /**
  68577. * When set, the up vector of the camera will be updated by the rotation of the camera
  68578. */
  68579. updateUpVectorFromRotation: boolean;
  68580. private _tmpQuaternion;
  68581. /**
  68582. * Define the current rotation of the camera
  68583. */
  68584. rotation: Vector3;
  68585. /**
  68586. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68587. */
  68588. rotationQuaternion: Quaternion;
  68589. /**
  68590. * Define the current speed of the camera
  68591. */
  68592. speed: number;
  68593. /**
  68594. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68595. * around all axis.
  68596. */
  68597. noRotationConstraint: boolean;
  68598. /**
  68599. * Define the current target of the camera as an object or a position.
  68600. */
  68601. lockedTarget: any;
  68602. /** @hidden */
  68603. _currentTarget: Vector3;
  68604. /** @hidden */
  68605. _initialFocalDistance: number;
  68606. /** @hidden */
  68607. _viewMatrix: Matrix;
  68608. /** @hidden */
  68609. _camMatrix: Matrix;
  68610. /** @hidden */
  68611. _cameraTransformMatrix: Matrix;
  68612. /** @hidden */
  68613. _cameraRotationMatrix: Matrix;
  68614. /** @hidden */
  68615. _referencePoint: Vector3;
  68616. /** @hidden */
  68617. _transformedReferencePoint: Vector3;
  68618. protected _globalCurrentTarget: Vector3;
  68619. protected _globalCurrentUpVector: Vector3;
  68620. /** @hidden */
  68621. _reset: () => void;
  68622. private _defaultUp;
  68623. /**
  68624. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68625. * This is the base of the follow, arc rotate cameras and Free camera
  68626. * @see http://doc.babylonjs.com/features/cameras
  68627. * @param name Defines the name of the camera in the scene
  68628. * @param position Defines the start position of the camera in the scene
  68629. * @param scene Defines the scene the camera belongs to
  68630. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68631. */
  68632. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68633. /**
  68634. * Gets the position in front of the camera at a given distance.
  68635. * @param distance The distance from the camera we want the position to be
  68636. * @returns the position
  68637. */
  68638. getFrontPosition(distance: number): Vector3;
  68639. /** @hidden */
  68640. _getLockedTargetPosition(): Nullable<Vector3>;
  68641. private _storedPosition;
  68642. private _storedRotation;
  68643. private _storedRotationQuaternion;
  68644. /**
  68645. * Store current camera state of the camera (fov, position, rotation, etc..)
  68646. * @returns the camera
  68647. */
  68648. storeState(): Camera;
  68649. /**
  68650. * Restored camera state. You must call storeState() first
  68651. * @returns whether it was successful or not
  68652. * @hidden
  68653. */
  68654. _restoreStateValues(): boolean;
  68655. /** @hidden */
  68656. _initCache(): void;
  68657. /** @hidden */
  68658. _updateCache(ignoreParentClass?: boolean): void;
  68659. /** @hidden */
  68660. _isSynchronizedViewMatrix(): boolean;
  68661. /** @hidden */
  68662. _computeLocalCameraSpeed(): number;
  68663. /**
  68664. * Defines the target the camera should look at.
  68665. * This will automatically adapt alpha beta and radius to fit within the new target.
  68666. * @param target Defines the new target as a Vector or a mesh
  68667. */
  68668. setTarget(target: Vector3): void;
  68669. /**
  68670. * Return the current target position of the camera. This value is expressed in local space.
  68671. * @returns the target position
  68672. */
  68673. getTarget(): Vector3;
  68674. /** @hidden */
  68675. _decideIfNeedsToMove(): boolean;
  68676. /** @hidden */
  68677. _updatePosition(): void;
  68678. /** @hidden */
  68679. _checkInputs(): void;
  68680. protected _updateCameraRotationMatrix(): void;
  68681. /**
  68682. * 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)
  68683. * @returns the current camera
  68684. */
  68685. private _rotateUpVectorWithCameraRotationMatrix;
  68686. private _cachedRotationZ;
  68687. private _cachedQuaternionRotationZ;
  68688. /** @hidden */
  68689. _getViewMatrix(): Matrix;
  68690. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68691. /**
  68692. * @hidden
  68693. */
  68694. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68695. /**
  68696. * @hidden
  68697. */
  68698. _updateRigCameras(): void;
  68699. private _getRigCamPositionAndTarget;
  68700. /**
  68701. * Gets the current object class name.
  68702. * @return the class name
  68703. */
  68704. getClassName(): string;
  68705. }
  68706. }
  68707. declare module BABYLON {
  68708. /**
  68709. * @ignore
  68710. * This is a list of all the different input types that are available in the application.
  68711. * Fo instance: ArcRotateCameraGamepadInput...
  68712. */
  68713. export var CameraInputTypes: {};
  68714. /**
  68715. * This is the contract to implement in order to create a new input class.
  68716. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68717. */
  68718. export interface ICameraInput<TCamera extends Camera> {
  68719. /**
  68720. * Defines the camera the input is attached to.
  68721. */
  68722. camera: Nullable<TCamera>;
  68723. /**
  68724. * Gets the class name of the current intput.
  68725. * @returns the class name
  68726. */
  68727. getClassName(): string;
  68728. /**
  68729. * Get the friendly name associated with the input class.
  68730. * @returns the input friendly name
  68731. */
  68732. getSimpleName(): string;
  68733. /**
  68734. * Attach the input controls to a specific dom element to get the input from.
  68735. * @param element Defines the element the controls should be listened from
  68736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68737. */
  68738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68739. /**
  68740. * Detach the current controls from the specified dom element.
  68741. * @param element Defines the element to stop listening the inputs from
  68742. */
  68743. detachControl(element: Nullable<HTMLElement>): void;
  68744. /**
  68745. * Update the current camera state depending on the inputs that have been used this frame.
  68746. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68747. */
  68748. checkInputs?: () => void;
  68749. }
  68750. /**
  68751. * Represents a map of input types to input instance or input index to input instance.
  68752. */
  68753. export interface CameraInputsMap<TCamera extends Camera> {
  68754. /**
  68755. * Accessor to the input by input type.
  68756. */
  68757. [name: string]: ICameraInput<TCamera>;
  68758. /**
  68759. * Accessor to the input by input index.
  68760. */
  68761. [idx: number]: ICameraInput<TCamera>;
  68762. }
  68763. /**
  68764. * This represents the input manager used within a camera.
  68765. * It helps dealing with all the different kind of input attached to a camera.
  68766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68767. */
  68768. export class CameraInputsManager<TCamera extends Camera> {
  68769. /**
  68770. * Defines the list of inputs attahed to the camera.
  68771. */
  68772. attached: CameraInputsMap<TCamera>;
  68773. /**
  68774. * Defines the dom element the camera is collecting inputs from.
  68775. * This is null if the controls have not been attached.
  68776. */
  68777. attachedElement: Nullable<HTMLElement>;
  68778. /**
  68779. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68780. */
  68781. noPreventDefault: boolean;
  68782. /**
  68783. * Defined the camera the input manager belongs to.
  68784. */
  68785. camera: TCamera;
  68786. /**
  68787. * Update the current camera state depending on the inputs that have been used this frame.
  68788. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68789. */
  68790. checkInputs: () => void;
  68791. /**
  68792. * Instantiate a new Camera Input Manager.
  68793. * @param camera Defines the camera the input manager blongs to
  68794. */
  68795. constructor(camera: TCamera);
  68796. /**
  68797. * Add an input method to a camera
  68798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68799. * @param input camera input method
  68800. */
  68801. add(input: ICameraInput<TCamera>): void;
  68802. /**
  68803. * Remove a specific input method from a camera
  68804. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68805. * @param inputToRemove camera input method
  68806. */
  68807. remove(inputToRemove: ICameraInput<TCamera>): void;
  68808. /**
  68809. * Remove a specific input type from a camera
  68810. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68811. * @param inputType the type of the input to remove
  68812. */
  68813. removeByType(inputType: string): void;
  68814. private _addCheckInputs;
  68815. /**
  68816. * Attach the input controls to the currently attached dom element to listen the events from.
  68817. * @param input Defines the input to attach
  68818. */
  68819. attachInput(input: ICameraInput<TCamera>): void;
  68820. /**
  68821. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68822. * @param element Defines the dom element to collect the events from
  68823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68824. */
  68825. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68826. /**
  68827. * Detach the current manager inputs controls from a specific dom element.
  68828. * @param element Defines the dom element to collect the events from
  68829. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68830. */
  68831. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68832. /**
  68833. * Rebuild the dynamic inputCheck function from the current list of
  68834. * defined inputs in the manager.
  68835. */
  68836. rebuildInputCheck(): void;
  68837. /**
  68838. * Remove all attached input methods from a camera
  68839. */
  68840. clear(): void;
  68841. /**
  68842. * Serialize the current input manager attached to a camera.
  68843. * This ensures than once parsed,
  68844. * the input associated to the camera will be identical to the current ones
  68845. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68846. */
  68847. serialize(serializedCamera: any): void;
  68848. /**
  68849. * Parses an input manager serialized JSON to restore the previous list of inputs
  68850. * and states associated to a camera.
  68851. * @param parsedCamera Defines the JSON to parse
  68852. */
  68853. parse(parsedCamera: any): void;
  68854. }
  68855. }
  68856. declare module BABYLON {
  68857. /**
  68858. * Gather the list of keyboard event types as constants.
  68859. */
  68860. export class KeyboardEventTypes {
  68861. /**
  68862. * The keydown event is fired when a key becomes active (pressed).
  68863. */
  68864. static readonly KEYDOWN: number;
  68865. /**
  68866. * The keyup event is fired when a key has been released.
  68867. */
  68868. static readonly KEYUP: number;
  68869. }
  68870. /**
  68871. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68872. */
  68873. export class KeyboardInfo {
  68874. /**
  68875. * Defines the type of event (KeyboardEventTypes)
  68876. */
  68877. type: number;
  68878. /**
  68879. * Defines the related dom event
  68880. */
  68881. event: KeyboardEvent;
  68882. /**
  68883. * Instantiates a new keyboard info.
  68884. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68885. * @param type Defines the type of event (KeyboardEventTypes)
  68886. * @param event Defines the related dom event
  68887. */
  68888. constructor(
  68889. /**
  68890. * Defines the type of event (KeyboardEventTypes)
  68891. */
  68892. type: number,
  68893. /**
  68894. * Defines the related dom event
  68895. */
  68896. event: KeyboardEvent);
  68897. }
  68898. /**
  68899. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68900. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68901. */
  68902. export class KeyboardInfoPre extends KeyboardInfo {
  68903. /**
  68904. * Defines the type of event (KeyboardEventTypes)
  68905. */
  68906. type: number;
  68907. /**
  68908. * Defines the related dom event
  68909. */
  68910. event: KeyboardEvent;
  68911. /**
  68912. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68913. */
  68914. skipOnPointerObservable: boolean;
  68915. /**
  68916. * Instantiates a new keyboard pre info.
  68917. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68918. * @param type Defines the type of event (KeyboardEventTypes)
  68919. * @param event Defines the related dom event
  68920. */
  68921. constructor(
  68922. /**
  68923. * Defines the type of event (KeyboardEventTypes)
  68924. */
  68925. type: number,
  68926. /**
  68927. * Defines the related dom event
  68928. */
  68929. event: KeyboardEvent);
  68930. }
  68931. }
  68932. declare module BABYLON {
  68933. /**
  68934. * Manage the keyboard inputs to control the movement of a free camera.
  68935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68936. */
  68937. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68938. /**
  68939. * Defines the camera the input is attached to.
  68940. */
  68941. camera: FreeCamera;
  68942. /**
  68943. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68944. */
  68945. keysUp: number[];
  68946. /**
  68947. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68948. */
  68949. keysDown: number[];
  68950. /**
  68951. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68952. */
  68953. keysLeft: number[];
  68954. /**
  68955. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68956. */
  68957. keysRight: number[];
  68958. private _keys;
  68959. private _onCanvasBlurObserver;
  68960. private _onKeyboardObserver;
  68961. private _engine;
  68962. private _scene;
  68963. /**
  68964. * Attach the input controls to a specific dom element to get the input from.
  68965. * @param element Defines the element the controls should be listened from
  68966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68967. */
  68968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68969. /**
  68970. * Detach the current controls from the specified dom element.
  68971. * @param element Defines the element to stop listening the inputs from
  68972. */
  68973. detachControl(element: Nullable<HTMLElement>): void;
  68974. /**
  68975. * Update the current camera state depending on the inputs that have been used this frame.
  68976. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68977. */
  68978. checkInputs(): void;
  68979. /**
  68980. * Gets the class name of the current intput.
  68981. * @returns the class name
  68982. */
  68983. getClassName(): string;
  68984. /** @hidden */
  68985. _onLostFocus(): void;
  68986. /**
  68987. * Get the friendly name associated with the input class.
  68988. * @returns the input friendly name
  68989. */
  68990. getSimpleName(): string;
  68991. }
  68992. }
  68993. declare module BABYLON {
  68994. /**
  68995. * Interface describing all the common properties and methods a shadow light needs to implement.
  68996. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68997. * as well as binding the different shadow properties to the effects.
  68998. */
  68999. export interface IShadowLight extends Light {
  69000. /**
  69001. * The light id in the scene (used in scene.findLighById for instance)
  69002. */
  69003. id: string;
  69004. /**
  69005. * The position the shdow will be casted from.
  69006. */
  69007. position: Vector3;
  69008. /**
  69009. * In 2d mode (needCube being false), the direction used to cast the shadow.
  69010. */
  69011. direction: Vector3;
  69012. /**
  69013. * The transformed position. Position of the light in world space taking parenting in account.
  69014. */
  69015. transformedPosition: Vector3;
  69016. /**
  69017. * The transformed direction. Direction of the light in world space taking parenting in account.
  69018. */
  69019. transformedDirection: Vector3;
  69020. /**
  69021. * The friendly name of the light in the scene.
  69022. */
  69023. name: string;
  69024. /**
  69025. * Defines the shadow projection clipping minimum z value.
  69026. */
  69027. shadowMinZ: number;
  69028. /**
  69029. * Defines the shadow projection clipping maximum z value.
  69030. */
  69031. shadowMaxZ: number;
  69032. /**
  69033. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69034. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69035. */
  69036. computeTransformedInformation(): boolean;
  69037. /**
  69038. * Gets the scene the light belongs to.
  69039. * @returns The scene
  69040. */
  69041. getScene(): Scene;
  69042. /**
  69043. * Callback defining a custom Projection Matrix Builder.
  69044. * This can be used to override the default projection matrix computation.
  69045. */
  69046. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69047. /**
  69048. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69049. * @param matrix The materix to updated with the projection information
  69050. * @param viewMatrix The transform matrix of the light
  69051. * @param renderList The list of mesh to render in the map
  69052. * @returns The current light
  69053. */
  69054. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69055. /**
  69056. * Gets the current depth scale used in ESM.
  69057. * @returns The scale
  69058. */
  69059. getDepthScale(): number;
  69060. /**
  69061. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69062. * @returns true if a cube texture needs to be use
  69063. */
  69064. needCube(): boolean;
  69065. /**
  69066. * Detects if the projection matrix requires to be recomputed this frame.
  69067. * @returns true if it requires to be recomputed otherwise, false.
  69068. */
  69069. needProjectionMatrixCompute(): boolean;
  69070. /**
  69071. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69072. */
  69073. forceProjectionMatrixCompute(): void;
  69074. /**
  69075. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69076. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69077. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69078. */
  69079. getShadowDirection(faceIndex?: number): Vector3;
  69080. /**
  69081. * Gets the minZ used for shadow according to both the scene and the light.
  69082. * @param activeCamera The camera we are returning the min for
  69083. * @returns the depth min z
  69084. */
  69085. getDepthMinZ(activeCamera: Camera): number;
  69086. /**
  69087. * Gets the maxZ used for shadow according to both the scene and the light.
  69088. * @param activeCamera The camera we are returning the max for
  69089. * @returns the depth max z
  69090. */
  69091. getDepthMaxZ(activeCamera: Camera): number;
  69092. }
  69093. /**
  69094. * Base implementation IShadowLight
  69095. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  69096. */
  69097. export abstract class ShadowLight extends Light implements IShadowLight {
  69098. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  69099. protected _position: Vector3;
  69100. protected _setPosition(value: Vector3): void;
  69101. /**
  69102. * Sets the position the shadow will be casted from. Also use as the light position for both
  69103. * point and spot lights.
  69104. */
  69105. /**
  69106. * Sets the position the shadow will be casted from. Also use as the light position for both
  69107. * point and spot lights.
  69108. */
  69109. position: Vector3;
  69110. protected _direction: Vector3;
  69111. protected _setDirection(value: Vector3): void;
  69112. /**
  69113. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  69114. * Also use as the light direction on spot and directional lights.
  69115. */
  69116. /**
  69117. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  69118. * Also use as the light direction on spot and directional lights.
  69119. */
  69120. direction: Vector3;
  69121. private _shadowMinZ;
  69122. /**
  69123. * Gets the shadow projection clipping minimum z value.
  69124. */
  69125. /**
  69126. * Sets the shadow projection clipping minimum z value.
  69127. */
  69128. shadowMinZ: number;
  69129. private _shadowMaxZ;
  69130. /**
  69131. * Sets the shadow projection clipping maximum z value.
  69132. */
  69133. /**
  69134. * Gets the shadow projection clipping maximum z value.
  69135. */
  69136. shadowMaxZ: number;
  69137. /**
  69138. * Callback defining a custom Projection Matrix Builder.
  69139. * This can be used to override the default projection matrix computation.
  69140. */
  69141. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69142. /**
  69143. * The transformed position. Position of the light in world space taking parenting in account.
  69144. */
  69145. transformedPosition: Vector3;
  69146. /**
  69147. * The transformed direction. Direction of the light in world space taking parenting in account.
  69148. */
  69149. transformedDirection: Vector3;
  69150. private _needProjectionMatrixCompute;
  69151. /**
  69152. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69153. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69154. */
  69155. computeTransformedInformation(): boolean;
  69156. /**
  69157. * Return the depth scale used for the shadow map.
  69158. * @returns the depth scale.
  69159. */
  69160. getDepthScale(): number;
  69161. /**
  69162. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69163. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69164. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69165. */
  69166. getShadowDirection(faceIndex?: number): Vector3;
  69167. /**
  69168. * Returns the ShadowLight absolute position in the World.
  69169. * @returns the position vector in world space
  69170. */
  69171. getAbsolutePosition(): Vector3;
  69172. /**
  69173. * Sets the ShadowLight direction toward the passed target.
  69174. * @param target The point to target in local space
  69175. * @returns the updated ShadowLight direction
  69176. */
  69177. setDirectionToTarget(target: Vector3): Vector3;
  69178. /**
  69179. * Returns the light rotation in euler definition.
  69180. * @returns the x y z rotation in local space.
  69181. */
  69182. getRotation(): Vector3;
  69183. /**
  69184. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69185. * @returns true if a cube texture needs to be use
  69186. */
  69187. needCube(): boolean;
  69188. /**
  69189. * Detects if the projection matrix requires to be recomputed this frame.
  69190. * @returns true if it requires to be recomputed otherwise, false.
  69191. */
  69192. needProjectionMatrixCompute(): boolean;
  69193. /**
  69194. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69195. */
  69196. forceProjectionMatrixCompute(): void;
  69197. /** @hidden */
  69198. _initCache(): void;
  69199. /** @hidden */
  69200. _isSynchronized(): boolean;
  69201. /**
  69202. * Computes the world matrix of the node
  69203. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69204. * @returns the world matrix
  69205. */
  69206. computeWorldMatrix(force?: boolean): Matrix;
  69207. /**
  69208. * Gets the minZ used for shadow according to both the scene and the light.
  69209. * @param activeCamera The camera we are returning the min for
  69210. * @returns the depth min z
  69211. */
  69212. getDepthMinZ(activeCamera: Camera): number;
  69213. /**
  69214. * Gets the maxZ used for shadow according to both the scene and the light.
  69215. * @param activeCamera The camera we are returning the max for
  69216. * @returns the depth max z
  69217. */
  69218. getDepthMaxZ(activeCamera: Camera): number;
  69219. /**
  69220. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69221. * @param matrix The materix to updated with the projection information
  69222. * @param viewMatrix The transform matrix of the light
  69223. * @param renderList The list of mesh to render in the map
  69224. * @returns The current light
  69225. */
  69226. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69227. }
  69228. }
  69229. declare module BABYLON {
  69230. /**
  69231. * "Static Class" containing the most commonly used helper while dealing with material for
  69232. * rendering purpose.
  69233. *
  69234. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69235. *
  69236. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69237. */
  69238. export class MaterialHelper {
  69239. /**
  69240. * Bind the current view position to an effect.
  69241. * @param effect The effect to be bound
  69242. * @param scene The scene the eyes position is used from
  69243. */
  69244. static BindEyePosition(effect: Effect, scene: Scene): void;
  69245. /**
  69246. * Helps preparing the defines values about the UVs in used in the effect.
  69247. * UVs are shared as much as we can accross channels in the shaders.
  69248. * @param texture The texture we are preparing the UVs for
  69249. * @param defines The defines to update
  69250. * @param key The channel key "diffuse", "specular"... used in the shader
  69251. */
  69252. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69253. /**
  69254. * Binds a texture matrix value to its corrsponding uniform
  69255. * @param texture The texture to bind the matrix for
  69256. * @param uniformBuffer The uniform buffer receivin the data
  69257. * @param key The channel key "diffuse", "specular"... used in the shader
  69258. */
  69259. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69260. /**
  69261. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69262. * @param mesh defines the current mesh
  69263. * @param scene defines the current scene
  69264. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69265. * @param pointsCloud defines if point cloud rendering has to be turned on
  69266. * @param fogEnabled defines if fog has to be turned on
  69267. * @param alphaTest defines if alpha testing has to be turned on
  69268. * @param defines defines the current list of defines
  69269. */
  69270. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69271. /**
  69272. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69273. * @param scene defines the current scene
  69274. * @param engine defines the current engine
  69275. * @param defines specifies the list of active defines
  69276. * @param useInstances defines if instances have to be turned on
  69277. * @param useClipPlane defines if clip plane have to be turned on
  69278. */
  69279. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69280. /**
  69281. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69282. * @param mesh The mesh containing the geometry data we will draw
  69283. * @param defines The defines to update
  69284. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69285. * @param useBones Precise whether bones should be used or not (override mesh info)
  69286. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69287. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69288. * @returns false if defines are considered not dirty and have not been checked
  69289. */
  69290. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69291. /**
  69292. * Prepares the defines related to multiview
  69293. * @param scene The scene we are intending to draw
  69294. * @param defines The defines to update
  69295. */
  69296. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69297. /**
  69298. * Prepares the defines related to the light information passed in parameter
  69299. * @param scene The scene we are intending to draw
  69300. * @param mesh The mesh the effect is compiling for
  69301. * @param defines The defines to update
  69302. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69303. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69304. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69305. * @returns true if normals will be required for the rest of the effect
  69306. */
  69307. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69308. /**
  69309. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69310. * that won t be acctive due to defines being turned off.
  69311. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69312. * @param samplersList The samplers list
  69313. * @param defines The defines helping in the list generation
  69314. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69315. */
  69316. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69317. /**
  69318. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69319. * @param defines The defines to update while falling back
  69320. * @param fallbacks The authorized effect fallbacks
  69321. * @param maxSimultaneousLights The maximum number of lights allowed
  69322. * @param rank the current rank of the Effect
  69323. * @returns The newly affected rank
  69324. */
  69325. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69326. /**
  69327. * Prepares the list of attributes required for morph targets according to the effect defines.
  69328. * @param attribs The current list of supported attribs
  69329. * @param mesh The mesh to prepare the morph targets attributes for
  69330. * @param defines The current Defines of the effect
  69331. */
  69332. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69333. /**
  69334. * Prepares the list of attributes required for bones according to the effect defines.
  69335. * @param attribs The current list of supported attribs
  69336. * @param mesh The mesh to prepare the bones attributes for
  69337. * @param defines The current Defines of the effect
  69338. * @param fallbacks The current efffect fallback strategy
  69339. */
  69340. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69341. /**
  69342. * Prepares the list of attributes required for instances according to the effect defines.
  69343. * @param attribs The current list of supported attribs
  69344. * @param defines The current Defines of the effect
  69345. */
  69346. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69347. /**
  69348. * Binds the light shadow information to the effect for the given mesh.
  69349. * @param light The light containing the generator
  69350. * @param scene The scene the lights belongs to
  69351. * @param mesh The mesh we are binding the information to render
  69352. * @param lightIndex The light index in the effect used to render the mesh
  69353. * @param effect The effect we are binding the data to
  69354. */
  69355. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69356. /**
  69357. * Binds the light information to the effect.
  69358. * @param light The light containing the generator
  69359. * @param effect The effect we are binding the data to
  69360. * @param lightIndex The light index in the effect used to render
  69361. */
  69362. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69363. /**
  69364. * Binds the lights information from the scene to the effect for the given mesh.
  69365. * @param scene The scene the lights belongs to
  69366. * @param mesh The mesh we are binding the information to render
  69367. * @param effect The effect we are binding the data to
  69368. * @param defines The generated defines for the effect
  69369. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69370. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69371. */
  69372. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69373. private static _tempFogColor;
  69374. /**
  69375. * Binds the fog information from the scene to the effect for the given mesh.
  69376. * @param scene The scene the lights belongs to
  69377. * @param mesh The mesh we are binding the information to render
  69378. * @param effect The effect we are binding the data to
  69379. * @param linearSpace Defines if the fog effect is applied in linear space
  69380. */
  69381. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69382. /**
  69383. * Binds the bones information from the mesh to the effect.
  69384. * @param mesh The mesh we are binding the information to render
  69385. * @param effect The effect we are binding the data to
  69386. */
  69387. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69388. /**
  69389. * Binds the morph targets information from the mesh to the effect.
  69390. * @param abstractMesh The mesh we are binding the information to render
  69391. * @param effect The effect we are binding the data to
  69392. */
  69393. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69394. /**
  69395. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69396. * @param defines The generated defines used in the effect
  69397. * @param effect The effect we are binding the data to
  69398. * @param scene The scene we are willing to render with logarithmic scale for
  69399. */
  69400. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69401. /**
  69402. * Binds the clip plane information from the scene to the effect.
  69403. * @param scene The scene the clip plane information are extracted from
  69404. * @param effect The effect we are binding the data to
  69405. */
  69406. static BindClipPlane(effect: Effect, scene: Scene): void;
  69407. }
  69408. }
  69409. declare module BABYLON {
  69410. /** @hidden */
  69411. export var kernelBlurVaryingDeclaration: {
  69412. name: string;
  69413. shader: string;
  69414. };
  69415. }
  69416. declare module BABYLON {
  69417. /** @hidden */
  69418. export var kernelBlurFragment: {
  69419. name: string;
  69420. shader: string;
  69421. };
  69422. }
  69423. declare module BABYLON {
  69424. /** @hidden */
  69425. export var kernelBlurFragment2: {
  69426. name: string;
  69427. shader: string;
  69428. };
  69429. }
  69430. declare module BABYLON {
  69431. /** @hidden */
  69432. export var kernelBlurPixelShader: {
  69433. name: string;
  69434. shader: string;
  69435. };
  69436. }
  69437. declare module BABYLON {
  69438. /** @hidden */
  69439. export var kernelBlurVertex: {
  69440. name: string;
  69441. shader: string;
  69442. };
  69443. }
  69444. declare module BABYLON {
  69445. /** @hidden */
  69446. export var kernelBlurVertexShader: {
  69447. name: string;
  69448. shader: string;
  69449. };
  69450. }
  69451. declare module BABYLON {
  69452. /**
  69453. * The Blur Post Process which blurs an image based on a kernel and direction.
  69454. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69455. */
  69456. export class BlurPostProcess extends PostProcess {
  69457. /** The direction in which to blur the image. */
  69458. direction: Vector2;
  69459. private blockCompilation;
  69460. protected _kernel: number;
  69461. protected _idealKernel: number;
  69462. protected _packedFloat: boolean;
  69463. private _staticDefines;
  69464. /**
  69465. * Sets the length in pixels of the blur sample region
  69466. */
  69467. /**
  69468. * Gets the length in pixels of the blur sample region
  69469. */
  69470. kernel: number;
  69471. /**
  69472. * Sets wether or not the blur needs to unpack/repack floats
  69473. */
  69474. /**
  69475. * Gets wether or not the blur is unpacking/repacking floats
  69476. */
  69477. packedFloat: boolean;
  69478. /**
  69479. * Creates a new instance BlurPostProcess
  69480. * @param name The name of the effect.
  69481. * @param direction The direction in which to blur the image.
  69482. * @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.
  69483. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69484. * @param camera The camera to apply the render pass to.
  69485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69486. * @param engine The engine which the post process will be applied. (default: current engine)
  69487. * @param reusable If the post process can be reused on the same frame. (default: false)
  69488. * @param textureType Type of textures used when performing the post process. (default: 0)
  69489. * @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)
  69490. */
  69491. constructor(name: string,
  69492. /** The direction in which to blur the image. */
  69493. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69494. /**
  69495. * Updates the effect with the current post process compile time values and recompiles the shader.
  69496. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69497. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69498. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69499. * @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
  69500. * @param onCompiled Called when the shader has been compiled.
  69501. * @param onError Called if there is an error when compiling a shader.
  69502. */
  69503. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69504. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69505. /**
  69506. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69507. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69508. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69509. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69510. * The gaps between physical kernels are compensated for in the weighting of the samples
  69511. * @param idealKernel Ideal blur kernel.
  69512. * @return Nearest best kernel.
  69513. */
  69514. protected _nearestBestKernel(idealKernel: number): number;
  69515. /**
  69516. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69517. * @param x The point on the Gaussian distribution to sample.
  69518. * @return the value of the Gaussian function at x.
  69519. */
  69520. protected _gaussianWeight(x: number): number;
  69521. /**
  69522. * Generates a string that can be used as a floating point number in GLSL.
  69523. * @param x Value to print.
  69524. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69525. * @return GLSL float string.
  69526. */
  69527. protected _glslFloat(x: number, decimalFigures?: number): string;
  69528. }
  69529. }
  69530. declare module BABYLON {
  69531. /** @hidden */
  69532. export var shadowMapPixelShader: {
  69533. name: string;
  69534. shader: string;
  69535. };
  69536. }
  69537. declare module BABYLON {
  69538. /** @hidden */
  69539. export var bonesDeclaration: {
  69540. name: string;
  69541. shader: string;
  69542. };
  69543. }
  69544. declare module BABYLON {
  69545. /** @hidden */
  69546. export var morphTargetsVertexGlobalDeclaration: {
  69547. name: string;
  69548. shader: string;
  69549. };
  69550. }
  69551. declare module BABYLON {
  69552. /** @hidden */
  69553. export var morphTargetsVertexDeclaration: {
  69554. name: string;
  69555. shader: string;
  69556. };
  69557. }
  69558. declare module BABYLON {
  69559. /** @hidden */
  69560. export var instancesDeclaration: {
  69561. name: string;
  69562. shader: string;
  69563. };
  69564. }
  69565. declare module BABYLON {
  69566. /** @hidden */
  69567. export var helperFunctions: {
  69568. name: string;
  69569. shader: string;
  69570. };
  69571. }
  69572. declare module BABYLON {
  69573. /** @hidden */
  69574. export var morphTargetsVertex: {
  69575. name: string;
  69576. shader: string;
  69577. };
  69578. }
  69579. declare module BABYLON {
  69580. /** @hidden */
  69581. export var instancesVertex: {
  69582. name: string;
  69583. shader: string;
  69584. };
  69585. }
  69586. declare module BABYLON {
  69587. /** @hidden */
  69588. export var bonesVertex: {
  69589. name: string;
  69590. shader: string;
  69591. };
  69592. }
  69593. declare module BABYLON {
  69594. /** @hidden */
  69595. export var shadowMapVertexShader: {
  69596. name: string;
  69597. shader: string;
  69598. };
  69599. }
  69600. declare module BABYLON {
  69601. /** @hidden */
  69602. export var depthBoxBlurPixelShader: {
  69603. name: string;
  69604. shader: string;
  69605. };
  69606. }
  69607. declare module BABYLON {
  69608. /**
  69609. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69610. */
  69611. export interface ICustomShaderOptions {
  69612. /**
  69613. * Gets or sets the custom shader name to use
  69614. */
  69615. shaderName: string;
  69616. /**
  69617. * The list of attribute names used in the shader
  69618. */
  69619. attributes?: string[];
  69620. /**
  69621. * The list of unifrom names used in the shader
  69622. */
  69623. uniforms?: string[];
  69624. /**
  69625. * The list of sampler names used in the shader
  69626. */
  69627. samplers?: string[];
  69628. /**
  69629. * The list of defines used in the shader
  69630. */
  69631. defines?: string[];
  69632. }
  69633. /**
  69634. * Interface to implement to create a shadow generator compatible with BJS.
  69635. */
  69636. export interface IShadowGenerator {
  69637. /**
  69638. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69639. * @returns The render target texture if present otherwise, null
  69640. */
  69641. getShadowMap(): Nullable<RenderTargetTexture>;
  69642. /**
  69643. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69644. * @returns The render target texture if the shadow map is present otherwise, null
  69645. */
  69646. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69647. /**
  69648. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69649. * @param subMesh The submesh we want to render in the shadow map
  69650. * @param useInstances Defines wether will draw in the map using instances
  69651. * @returns true if ready otherwise, false
  69652. */
  69653. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69654. /**
  69655. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69656. * @param defines Defines of the material we want to update
  69657. * @param lightIndex Index of the light in the enabled light list of the material
  69658. */
  69659. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69660. /**
  69661. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69662. * defined in the generator but impacting the effect).
  69663. * It implies the unifroms available on the materials are the standard BJS ones.
  69664. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69665. * @param effect The effect we are binfing the information for
  69666. */
  69667. bindShadowLight(lightIndex: string, effect: Effect): void;
  69668. /**
  69669. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69670. * (eq to shadow prjection matrix * light transform matrix)
  69671. * @returns The transform matrix used to create the shadow map
  69672. */
  69673. getTransformMatrix(): Matrix;
  69674. /**
  69675. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69676. * Cube and 2D textures for instance.
  69677. */
  69678. recreateShadowMap(): void;
  69679. /**
  69680. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69681. * @param onCompiled Callback triggered at the and of the effects compilation
  69682. * @param options Sets of optional options forcing the compilation with different modes
  69683. */
  69684. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69685. useInstances: boolean;
  69686. }>): void;
  69687. /**
  69688. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69689. * @param options Sets of optional options forcing the compilation with different modes
  69690. * @returns A promise that resolves when the compilation completes
  69691. */
  69692. forceCompilationAsync(options?: Partial<{
  69693. useInstances: boolean;
  69694. }>): Promise<void>;
  69695. /**
  69696. * Serializes the shadow generator setup to a json object.
  69697. * @returns The serialized JSON object
  69698. */
  69699. serialize(): any;
  69700. /**
  69701. * Disposes the Shadow map and related Textures and effects.
  69702. */
  69703. dispose(): void;
  69704. }
  69705. /**
  69706. * Default implementation IShadowGenerator.
  69707. * This is the main object responsible of generating shadows in the framework.
  69708. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69709. */
  69710. export class ShadowGenerator implements IShadowGenerator {
  69711. /**
  69712. * Shadow generator mode None: no filtering applied.
  69713. */
  69714. static readonly FILTER_NONE: number;
  69715. /**
  69716. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69717. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69718. */
  69719. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69720. /**
  69721. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69722. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69723. */
  69724. static readonly FILTER_POISSONSAMPLING: number;
  69725. /**
  69726. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69727. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69728. */
  69729. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69730. /**
  69731. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69732. * edge artifacts on steep falloff.
  69733. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69734. */
  69735. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69736. /**
  69737. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69738. * edge artifacts on steep falloff.
  69739. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69740. */
  69741. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69742. /**
  69743. * Shadow generator mode PCF: Percentage Closer Filtering
  69744. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69745. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69746. */
  69747. static readonly FILTER_PCF: number;
  69748. /**
  69749. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69750. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69751. * Contact Hardening
  69752. */
  69753. static readonly FILTER_PCSS: number;
  69754. /**
  69755. * Reserved for PCF and PCSS
  69756. * Highest Quality.
  69757. *
  69758. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69759. *
  69760. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69761. */
  69762. static readonly QUALITY_HIGH: number;
  69763. /**
  69764. * Reserved for PCF and PCSS
  69765. * Good tradeoff for quality/perf cross devices
  69766. *
  69767. * Execute PCF on a 3*3 kernel.
  69768. *
  69769. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69770. */
  69771. static readonly QUALITY_MEDIUM: number;
  69772. /**
  69773. * Reserved for PCF and PCSS
  69774. * The lowest quality but the fastest.
  69775. *
  69776. * Execute PCF on a 1*1 kernel.
  69777. *
  69778. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69779. */
  69780. static readonly QUALITY_LOW: number;
  69781. /** Gets or sets the custom shader name to use */
  69782. customShaderOptions: ICustomShaderOptions;
  69783. /**
  69784. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69785. */
  69786. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69787. /**
  69788. * Observable triggered before a mesh is rendered in the shadow map.
  69789. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69790. */
  69791. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69792. private _bias;
  69793. /**
  69794. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69795. */
  69796. /**
  69797. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69798. */
  69799. bias: number;
  69800. private _normalBias;
  69801. /**
  69802. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69803. */
  69804. /**
  69805. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69806. */
  69807. normalBias: number;
  69808. private _blurBoxOffset;
  69809. /**
  69810. * Gets the blur box offset: offset applied during the blur pass.
  69811. * Only useful if useKernelBlur = false
  69812. */
  69813. /**
  69814. * Sets the blur box offset: offset applied during the blur pass.
  69815. * Only useful if useKernelBlur = false
  69816. */
  69817. blurBoxOffset: number;
  69818. private _blurScale;
  69819. /**
  69820. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69821. * 2 means half of the size.
  69822. */
  69823. /**
  69824. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69825. * 2 means half of the size.
  69826. */
  69827. blurScale: number;
  69828. private _blurKernel;
  69829. /**
  69830. * Gets the blur kernel: kernel size of the blur pass.
  69831. * Only useful if useKernelBlur = true
  69832. */
  69833. /**
  69834. * Sets the blur kernel: kernel size of the blur pass.
  69835. * Only useful if useKernelBlur = true
  69836. */
  69837. blurKernel: number;
  69838. private _useKernelBlur;
  69839. /**
  69840. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69841. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69842. */
  69843. /**
  69844. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69845. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69846. */
  69847. useKernelBlur: boolean;
  69848. private _depthScale;
  69849. /**
  69850. * Gets the depth scale used in ESM mode.
  69851. */
  69852. /**
  69853. * Sets the depth scale used in ESM mode.
  69854. * This can override the scale stored on the light.
  69855. */
  69856. depthScale: number;
  69857. private _filter;
  69858. /**
  69859. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69860. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69861. */
  69862. /**
  69863. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69864. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69865. */
  69866. filter: number;
  69867. /**
  69868. * Gets if the current filter is set to Poisson Sampling.
  69869. */
  69870. /**
  69871. * Sets the current filter to Poisson Sampling.
  69872. */
  69873. usePoissonSampling: boolean;
  69874. /**
  69875. * Gets if the current filter is set to ESM.
  69876. */
  69877. /**
  69878. * Sets the current filter is to ESM.
  69879. */
  69880. useExponentialShadowMap: boolean;
  69881. /**
  69882. * Gets if the current filter is set to filtered ESM.
  69883. */
  69884. /**
  69885. * Gets if the current filter is set to filtered ESM.
  69886. */
  69887. useBlurExponentialShadowMap: boolean;
  69888. /**
  69889. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69890. * exponential to prevent steep falloff artifacts).
  69891. */
  69892. /**
  69893. * Sets the current filter to "close ESM" (using the inverse of the
  69894. * exponential to prevent steep falloff artifacts).
  69895. */
  69896. useCloseExponentialShadowMap: boolean;
  69897. /**
  69898. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69899. * exponential to prevent steep falloff artifacts).
  69900. */
  69901. /**
  69902. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69903. * exponential to prevent steep falloff artifacts).
  69904. */
  69905. useBlurCloseExponentialShadowMap: boolean;
  69906. /**
  69907. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69908. */
  69909. /**
  69910. * Sets the current filter to "PCF" (percentage closer filtering).
  69911. */
  69912. usePercentageCloserFiltering: boolean;
  69913. private _filteringQuality;
  69914. /**
  69915. * Gets the PCF or PCSS Quality.
  69916. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69917. */
  69918. /**
  69919. * Sets the PCF or PCSS Quality.
  69920. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69921. */
  69922. filteringQuality: number;
  69923. /**
  69924. * Gets if the current filter is set to "PCSS" (contact hardening).
  69925. */
  69926. /**
  69927. * Sets the current filter to "PCSS" (contact hardening).
  69928. */
  69929. useContactHardeningShadow: boolean;
  69930. private _contactHardeningLightSizeUVRatio;
  69931. /**
  69932. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69933. * Using a ratio helps keeping shape stability independently of the map size.
  69934. *
  69935. * It does not account for the light projection as it was having too much
  69936. * instability during the light setup or during light position changes.
  69937. *
  69938. * Only valid if useContactHardeningShadow is true.
  69939. */
  69940. /**
  69941. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69942. * Using a ratio helps keeping shape stability independently of the map size.
  69943. *
  69944. * It does not account for the light projection as it was having too much
  69945. * instability during the light setup or during light position changes.
  69946. *
  69947. * Only valid if useContactHardeningShadow is true.
  69948. */
  69949. contactHardeningLightSizeUVRatio: number;
  69950. private _darkness;
  69951. /**
  69952. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69953. * 0 means strongest and 1 would means no shadow.
  69954. * @returns the darkness.
  69955. */
  69956. getDarkness(): number;
  69957. /**
  69958. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69959. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69960. * @returns the shadow generator allowing fluent coding.
  69961. */
  69962. setDarkness(darkness: number): ShadowGenerator;
  69963. private _transparencyShadow;
  69964. /**
  69965. * Sets the ability to have transparent shadow (boolean).
  69966. * @param transparent True if transparent else False
  69967. * @returns the shadow generator allowing fluent coding
  69968. */
  69969. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69970. private _shadowMap;
  69971. private _shadowMap2;
  69972. /**
  69973. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69974. * @returns The render target texture if present otherwise, null
  69975. */
  69976. getShadowMap(): Nullable<RenderTargetTexture>;
  69977. /**
  69978. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69979. * @returns The render target texture if the shadow map is present otherwise, null
  69980. */
  69981. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69982. /**
  69983. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69984. * @param mesh Mesh to add
  69985. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69986. * @returns the Shadow Generator itself
  69987. */
  69988. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69989. /**
  69990. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69991. * @param mesh Mesh to remove
  69992. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69993. * @returns the Shadow Generator itself
  69994. */
  69995. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69996. /**
  69997. * Controls the extent to which the shadows fade out at the edge of the frustum
  69998. * Used only by directionals and spots
  69999. */
  70000. frustumEdgeFalloff: number;
  70001. private _light;
  70002. /**
  70003. * Returns the associated light object.
  70004. * @returns the light generating the shadow
  70005. */
  70006. getLight(): IShadowLight;
  70007. /**
  70008. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  70009. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  70010. * It might on the other hand introduce peter panning.
  70011. */
  70012. forceBackFacesOnly: boolean;
  70013. private _scene;
  70014. private _lightDirection;
  70015. private _effect;
  70016. private _viewMatrix;
  70017. private _projectionMatrix;
  70018. private _transformMatrix;
  70019. private _cachedPosition;
  70020. private _cachedDirection;
  70021. private _cachedDefines;
  70022. private _currentRenderID;
  70023. private _boxBlurPostprocess;
  70024. private _kernelBlurXPostprocess;
  70025. private _kernelBlurYPostprocess;
  70026. private _blurPostProcesses;
  70027. private _mapSize;
  70028. private _currentFaceIndex;
  70029. private _currentFaceIndexCache;
  70030. private _textureType;
  70031. private _defaultTextureMatrix;
  70032. /** @hidden */
  70033. static _SceneComponentInitialization: (scene: Scene) => void;
  70034. /**
  70035. * Creates a ShadowGenerator object.
  70036. * A ShadowGenerator is the required tool to use the shadows.
  70037. * Each light casting shadows needs to use its own ShadowGenerator.
  70038. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  70039. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  70040. * @param light The light object generating the shadows.
  70041. * @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.
  70042. */
  70043. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  70044. private _initializeGenerator;
  70045. private _initializeShadowMap;
  70046. private _initializeBlurRTTAndPostProcesses;
  70047. private _renderForShadowMap;
  70048. private _renderSubMeshForShadowMap;
  70049. private _applyFilterValues;
  70050. /**
  70051. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70052. * @param onCompiled Callback triggered at the and of the effects compilation
  70053. * @param options Sets of optional options forcing the compilation with different modes
  70054. */
  70055. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  70056. useInstances: boolean;
  70057. }>): void;
  70058. /**
  70059. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70060. * @param options Sets of optional options forcing the compilation with different modes
  70061. * @returns A promise that resolves when the compilation completes
  70062. */
  70063. forceCompilationAsync(options?: Partial<{
  70064. useInstances: boolean;
  70065. }>): Promise<void>;
  70066. /**
  70067. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  70068. * @param subMesh The submesh we want to render in the shadow map
  70069. * @param useInstances Defines wether will draw in the map using instances
  70070. * @returns true if ready otherwise, false
  70071. */
  70072. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70073. /**
  70074. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  70075. * @param defines Defines of the material we want to update
  70076. * @param lightIndex Index of the light in the enabled light list of the material
  70077. */
  70078. prepareDefines(defines: any, lightIndex: number): void;
  70079. /**
  70080. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  70081. * defined in the generator but impacting the effect).
  70082. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  70083. * @param effect The effect we are binfing the information for
  70084. */
  70085. bindShadowLight(lightIndex: string, effect: Effect): void;
  70086. /**
  70087. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  70088. * (eq to shadow prjection matrix * light transform matrix)
  70089. * @returns The transform matrix used to create the shadow map
  70090. */
  70091. getTransformMatrix(): Matrix;
  70092. /**
  70093. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  70094. * Cube and 2D textures for instance.
  70095. */
  70096. recreateShadowMap(): void;
  70097. private _disposeBlurPostProcesses;
  70098. private _disposeRTTandPostProcesses;
  70099. /**
  70100. * Disposes the ShadowGenerator.
  70101. * Returns nothing.
  70102. */
  70103. dispose(): void;
  70104. /**
  70105. * Serializes the shadow generator setup to a json object.
  70106. * @returns The serialized JSON object
  70107. */
  70108. serialize(): any;
  70109. /**
  70110. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  70111. * @param parsedShadowGenerator The JSON object to parse
  70112. * @param scene The scene to create the shadow map for
  70113. * @returns The parsed shadow generator
  70114. */
  70115. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  70116. }
  70117. }
  70118. declare module BABYLON {
  70119. /**
  70120. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  70121. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  70122. * 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.
  70123. */
  70124. export abstract class Light extends Node {
  70125. /**
  70126. * Falloff Default: light is falling off following the material specification:
  70127. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  70128. */
  70129. static readonly FALLOFF_DEFAULT: number;
  70130. /**
  70131. * Falloff Physical: light is falling off following the inverse squared distance law.
  70132. */
  70133. static readonly FALLOFF_PHYSICAL: number;
  70134. /**
  70135. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  70136. * to enhance interoperability with other engines.
  70137. */
  70138. static readonly FALLOFF_GLTF: number;
  70139. /**
  70140. * Falloff Standard: light is falling off like in the standard material
  70141. * to enhance interoperability with other materials.
  70142. */
  70143. static readonly FALLOFF_STANDARD: number;
  70144. /**
  70145. * If every light affecting the material is in this lightmapMode,
  70146. * material.lightmapTexture adds or multiplies
  70147. * (depends on material.useLightmapAsShadowmap)
  70148. * after every other light calculations.
  70149. */
  70150. static readonly LIGHTMAP_DEFAULT: number;
  70151. /**
  70152. * material.lightmapTexture as only diffuse lighting from this light
  70153. * adds only specular lighting from this light
  70154. * adds dynamic shadows
  70155. */
  70156. static readonly LIGHTMAP_SPECULAR: number;
  70157. /**
  70158. * material.lightmapTexture as only lighting
  70159. * no light calculation from this light
  70160. * only adds dynamic shadows from this light
  70161. */
  70162. static readonly LIGHTMAP_SHADOWSONLY: number;
  70163. /**
  70164. * Each light type uses the default quantity according to its type:
  70165. * point/spot lights use luminous intensity
  70166. * directional lights use illuminance
  70167. */
  70168. static readonly INTENSITYMODE_AUTOMATIC: number;
  70169. /**
  70170. * lumen (lm)
  70171. */
  70172. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  70173. /**
  70174. * candela (lm/sr)
  70175. */
  70176. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  70177. /**
  70178. * lux (lm/m^2)
  70179. */
  70180. static readonly INTENSITYMODE_ILLUMINANCE: number;
  70181. /**
  70182. * nit (cd/m^2)
  70183. */
  70184. static readonly INTENSITYMODE_LUMINANCE: number;
  70185. /**
  70186. * Light type const id of the point light.
  70187. */
  70188. static readonly LIGHTTYPEID_POINTLIGHT: number;
  70189. /**
  70190. * Light type const id of the directional light.
  70191. */
  70192. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  70193. /**
  70194. * Light type const id of the spot light.
  70195. */
  70196. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  70197. /**
  70198. * Light type const id of the hemispheric light.
  70199. */
  70200. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  70201. /**
  70202. * Diffuse gives the basic color to an object.
  70203. */
  70204. diffuse: Color3;
  70205. /**
  70206. * Specular produces a highlight color on an object.
  70207. * Note: This is note affecting PBR materials.
  70208. */
  70209. specular: Color3;
  70210. /**
  70211. * Defines the falloff type for this light. This lets overrriding how punctual light are
  70212. * falling off base on range or angle.
  70213. * This can be set to any values in Light.FALLOFF_x.
  70214. *
  70215. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  70216. * other types of materials.
  70217. */
  70218. falloffType: number;
  70219. /**
  70220. * Strength of the light.
  70221. * Note: By default it is define in the framework own unit.
  70222. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  70223. */
  70224. intensity: number;
  70225. private _range;
  70226. protected _inverseSquaredRange: number;
  70227. /**
  70228. * Defines how far from the source the light is impacting in scene units.
  70229. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70230. */
  70231. /**
  70232. * Defines how far from the source the light is impacting in scene units.
  70233. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70234. */
  70235. range: number;
  70236. /**
  70237. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70238. * of light.
  70239. */
  70240. private _photometricScale;
  70241. private _intensityMode;
  70242. /**
  70243. * Gets the photometric scale used to interpret the intensity.
  70244. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70245. */
  70246. /**
  70247. * Sets the photometric scale used to interpret the intensity.
  70248. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70249. */
  70250. intensityMode: number;
  70251. private _radius;
  70252. /**
  70253. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70254. */
  70255. /**
  70256. * sets the light radius used by PBR Materials to simulate soft area lights.
  70257. */
  70258. radius: number;
  70259. private _renderPriority;
  70260. /**
  70261. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70262. * exceeding the number allowed of the materials.
  70263. */
  70264. renderPriority: number;
  70265. private _shadowEnabled;
  70266. /**
  70267. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70268. * the current shadow generator.
  70269. */
  70270. /**
  70271. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70272. * the current shadow generator.
  70273. */
  70274. shadowEnabled: boolean;
  70275. private _includedOnlyMeshes;
  70276. /**
  70277. * Gets the only meshes impacted by this light.
  70278. */
  70279. /**
  70280. * Sets the only meshes impacted by this light.
  70281. */
  70282. includedOnlyMeshes: AbstractMesh[];
  70283. private _excludedMeshes;
  70284. /**
  70285. * Gets the meshes not impacted by this light.
  70286. */
  70287. /**
  70288. * Sets the meshes not impacted by this light.
  70289. */
  70290. excludedMeshes: AbstractMesh[];
  70291. private _excludeWithLayerMask;
  70292. /**
  70293. * Gets the layer id use to find what meshes are not impacted by the light.
  70294. * Inactive if 0
  70295. */
  70296. /**
  70297. * Sets the layer id use to find what meshes are not impacted by the light.
  70298. * Inactive if 0
  70299. */
  70300. excludeWithLayerMask: number;
  70301. private _includeOnlyWithLayerMask;
  70302. /**
  70303. * Gets the layer id use to find what meshes are impacted by the light.
  70304. * Inactive if 0
  70305. */
  70306. /**
  70307. * Sets the layer id use to find what meshes are impacted by the light.
  70308. * Inactive if 0
  70309. */
  70310. includeOnlyWithLayerMask: number;
  70311. private _lightmapMode;
  70312. /**
  70313. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70314. */
  70315. /**
  70316. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70317. */
  70318. lightmapMode: number;
  70319. /**
  70320. * Shadow generator associted to the light.
  70321. * @hidden Internal use only.
  70322. */
  70323. _shadowGenerator: Nullable<IShadowGenerator>;
  70324. /**
  70325. * @hidden Internal use only.
  70326. */
  70327. _excludedMeshesIds: string[];
  70328. /**
  70329. * @hidden Internal use only.
  70330. */
  70331. _includedOnlyMeshesIds: string[];
  70332. /**
  70333. * The current light unifom buffer.
  70334. * @hidden Internal use only.
  70335. */
  70336. _uniformBuffer: UniformBuffer;
  70337. /**
  70338. * Creates a Light object in the scene.
  70339. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70340. * @param name The firendly name of the light
  70341. * @param scene The scene the light belongs too
  70342. */
  70343. constructor(name: string, scene: Scene);
  70344. protected abstract _buildUniformLayout(): void;
  70345. /**
  70346. * Sets the passed Effect "effect" with the Light information.
  70347. * @param effect The effect to update
  70348. * @param lightIndex The index of the light in the effect to update
  70349. * @returns The light
  70350. */
  70351. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70352. /**
  70353. * Returns the string "Light".
  70354. * @returns the class name
  70355. */
  70356. getClassName(): string;
  70357. /** @hidden */
  70358. readonly _isLight: boolean;
  70359. /**
  70360. * Converts the light information to a readable string for debug purpose.
  70361. * @param fullDetails Supports for multiple levels of logging within scene loading
  70362. * @returns the human readable light info
  70363. */
  70364. toString(fullDetails?: boolean): string;
  70365. /** @hidden */
  70366. protected _syncParentEnabledState(): void;
  70367. /**
  70368. * Set the enabled state of this node.
  70369. * @param value - the new enabled state
  70370. */
  70371. setEnabled(value: boolean): void;
  70372. /**
  70373. * Returns the Light associated shadow generator if any.
  70374. * @return the associated shadow generator.
  70375. */
  70376. getShadowGenerator(): Nullable<IShadowGenerator>;
  70377. /**
  70378. * Returns a Vector3, the absolute light position in the World.
  70379. * @returns the world space position of the light
  70380. */
  70381. getAbsolutePosition(): Vector3;
  70382. /**
  70383. * Specifies if the light will affect the passed mesh.
  70384. * @param mesh The mesh to test against the light
  70385. * @return true the mesh is affected otherwise, false.
  70386. */
  70387. canAffectMesh(mesh: AbstractMesh): boolean;
  70388. /**
  70389. * Sort function to order lights for rendering.
  70390. * @param a First Light object to compare to second.
  70391. * @param b Second Light object to compare first.
  70392. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70393. */
  70394. static CompareLightsPriority(a: Light, b: Light): number;
  70395. /**
  70396. * Releases resources associated with this node.
  70397. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70398. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70399. */
  70400. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70401. /**
  70402. * Returns the light type ID (integer).
  70403. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70404. */
  70405. getTypeID(): number;
  70406. /**
  70407. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70408. * @returns the scaled intensity in intensity mode unit
  70409. */
  70410. getScaledIntensity(): number;
  70411. /**
  70412. * Returns a new Light object, named "name", from the current one.
  70413. * @param name The name of the cloned light
  70414. * @returns the new created light
  70415. */
  70416. clone(name: string): Nullable<Light>;
  70417. /**
  70418. * Serializes the current light into a Serialization object.
  70419. * @returns the serialized object.
  70420. */
  70421. serialize(): any;
  70422. /**
  70423. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70424. * This new light is named "name" and added to the passed scene.
  70425. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70426. * @param name The friendly name of the light
  70427. * @param scene The scene the new light will belong to
  70428. * @returns the constructor function
  70429. */
  70430. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70431. /**
  70432. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70433. * @param parsedLight The JSON representation of the light
  70434. * @param scene The scene to create the parsed light in
  70435. * @returns the created light after parsing
  70436. */
  70437. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70438. private _hookArrayForExcluded;
  70439. private _hookArrayForIncludedOnly;
  70440. private _resyncMeshes;
  70441. /**
  70442. * Forces the meshes to update their light related information in their rendering used effects
  70443. * @hidden Internal Use Only
  70444. */
  70445. _markMeshesAsLightDirty(): void;
  70446. /**
  70447. * Recomputes the cached photometric scale if needed.
  70448. */
  70449. private _computePhotometricScale;
  70450. /**
  70451. * Returns the Photometric Scale according to the light type and intensity mode.
  70452. */
  70453. private _getPhotometricScale;
  70454. /**
  70455. * Reorder the light in the scene according to their defined priority.
  70456. * @hidden Internal Use Only
  70457. */
  70458. _reorderLightsInScene(): void;
  70459. /**
  70460. * Prepares the list of defines specific to the light type.
  70461. * @param defines the list of defines
  70462. * @param lightIndex defines the index of the light for the effect
  70463. */
  70464. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70465. }
  70466. }
  70467. declare module BABYLON {
  70468. /**
  70469. * Interface used to define Action
  70470. */
  70471. export interface IAction {
  70472. /**
  70473. * Trigger for the action
  70474. */
  70475. trigger: number;
  70476. /** Options of the trigger */
  70477. triggerOptions: any;
  70478. /**
  70479. * Gets the trigger parameters
  70480. * @returns the trigger parameters
  70481. */
  70482. getTriggerParameter(): any;
  70483. /**
  70484. * Internal only - executes current action event
  70485. * @hidden
  70486. */
  70487. _executeCurrent(evt?: ActionEvent): void;
  70488. /**
  70489. * Serialize placeholder for child classes
  70490. * @param parent of child
  70491. * @returns the serialized object
  70492. */
  70493. serialize(parent: any): any;
  70494. /**
  70495. * Internal only
  70496. * @hidden
  70497. */
  70498. _prepare(): void;
  70499. /**
  70500. * Internal only - manager for action
  70501. * @hidden
  70502. */
  70503. _actionManager: AbstractActionManager;
  70504. }
  70505. /**
  70506. * The action to be carried out following a trigger
  70507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70508. */
  70509. export class Action implements IAction {
  70510. /** the trigger, with or without parameters, for the action */
  70511. triggerOptions: any;
  70512. /**
  70513. * Trigger for the action
  70514. */
  70515. trigger: number;
  70516. /**
  70517. * Internal only - manager for action
  70518. * @hidden
  70519. */
  70520. _actionManager: ActionManager;
  70521. private _nextActiveAction;
  70522. private _child;
  70523. private _condition?;
  70524. private _triggerParameter;
  70525. /**
  70526. * An event triggered prior to action being executed.
  70527. */
  70528. onBeforeExecuteObservable: Observable<Action>;
  70529. /**
  70530. * Creates a new Action
  70531. * @param triggerOptions the trigger, with or without parameters, for the action
  70532. * @param condition an optional determinant of action
  70533. */
  70534. constructor(
  70535. /** the trigger, with or without parameters, for the action */
  70536. triggerOptions: any, condition?: Condition);
  70537. /**
  70538. * Internal only
  70539. * @hidden
  70540. */
  70541. _prepare(): void;
  70542. /**
  70543. * Gets the trigger parameters
  70544. * @returns the trigger parameters
  70545. */
  70546. getTriggerParameter(): any;
  70547. /**
  70548. * Internal only - executes current action event
  70549. * @hidden
  70550. */
  70551. _executeCurrent(evt?: ActionEvent): void;
  70552. /**
  70553. * Execute placeholder for child classes
  70554. * @param evt optional action event
  70555. */
  70556. execute(evt?: ActionEvent): void;
  70557. /**
  70558. * Skips to next active action
  70559. */
  70560. skipToNextActiveAction(): void;
  70561. /**
  70562. * Adds action to chain of actions, may be a DoNothingAction
  70563. * @param action defines the next action to execute
  70564. * @returns The action passed in
  70565. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70566. */
  70567. then(action: Action): Action;
  70568. /**
  70569. * Internal only
  70570. * @hidden
  70571. */
  70572. _getProperty(propertyPath: string): string;
  70573. /**
  70574. * Internal only
  70575. * @hidden
  70576. */
  70577. _getEffectiveTarget(target: any, propertyPath: string): any;
  70578. /**
  70579. * Serialize placeholder for child classes
  70580. * @param parent of child
  70581. * @returns the serialized object
  70582. */
  70583. serialize(parent: any): any;
  70584. /**
  70585. * Internal only called by serialize
  70586. * @hidden
  70587. */
  70588. protected _serialize(serializedAction: any, parent?: any): any;
  70589. /**
  70590. * Internal only
  70591. * @hidden
  70592. */
  70593. static _SerializeValueAsString: (value: any) => string;
  70594. /**
  70595. * Internal only
  70596. * @hidden
  70597. */
  70598. static _GetTargetProperty: (target: Scene | Node) => {
  70599. name: string;
  70600. targetType: string;
  70601. value: string;
  70602. };
  70603. }
  70604. }
  70605. declare module BABYLON {
  70606. /**
  70607. * A Condition applied to an Action
  70608. */
  70609. export class Condition {
  70610. /**
  70611. * Internal only - manager for action
  70612. * @hidden
  70613. */
  70614. _actionManager: ActionManager;
  70615. /**
  70616. * Internal only
  70617. * @hidden
  70618. */
  70619. _evaluationId: number;
  70620. /**
  70621. * Internal only
  70622. * @hidden
  70623. */
  70624. _currentResult: boolean;
  70625. /**
  70626. * Creates a new Condition
  70627. * @param actionManager the manager of the action the condition is applied to
  70628. */
  70629. constructor(actionManager: ActionManager);
  70630. /**
  70631. * Check if the current condition is valid
  70632. * @returns a boolean
  70633. */
  70634. isValid(): boolean;
  70635. /**
  70636. * Internal only
  70637. * @hidden
  70638. */
  70639. _getProperty(propertyPath: string): string;
  70640. /**
  70641. * Internal only
  70642. * @hidden
  70643. */
  70644. _getEffectiveTarget(target: any, propertyPath: string): any;
  70645. /**
  70646. * Serialize placeholder for child classes
  70647. * @returns the serialized object
  70648. */
  70649. serialize(): any;
  70650. /**
  70651. * Internal only
  70652. * @hidden
  70653. */
  70654. protected _serialize(serializedCondition: any): any;
  70655. }
  70656. /**
  70657. * Defines specific conditional operators as extensions of Condition
  70658. */
  70659. export class ValueCondition extends Condition {
  70660. /** path to specify the property of the target the conditional operator uses */
  70661. propertyPath: string;
  70662. /** the value compared by the conditional operator against the current value of the property */
  70663. value: any;
  70664. /** the conditional operator, default ValueCondition.IsEqual */
  70665. operator: number;
  70666. /**
  70667. * Internal only
  70668. * @hidden
  70669. */
  70670. private static _IsEqual;
  70671. /**
  70672. * Internal only
  70673. * @hidden
  70674. */
  70675. private static _IsDifferent;
  70676. /**
  70677. * Internal only
  70678. * @hidden
  70679. */
  70680. private static _IsGreater;
  70681. /**
  70682. * Internal only
  70683. * @hidden
  70684. */
  70685. private static _IsLesser;
  70686. /**
  70687. * returns the number for IsEqual
  70688. */
  70689. static readonly IsEqual: number;
  70690. /**
  70691. * Returns the number for IsDifferent
  70692. */
  70693. static readonly IsDifferent: number;
  70694. /**
  70695. * Returns the number for IsGreater
  70696. */
  70697. static readonly IsGreater: number;
  70698. /**
  70699. * Returns the number for IsLesser
  70700. */
  70701. static readonly IsLesser: number;
  70702. /**
  70703. * Internal only The action manager for the condition
  70704. * @hidden
  70705. */
  70706. _actionManager: ActionManager;
  70707. /**
  70708. * Internal only
  70709. * @hidden
  70710. */
  70711. private _target;
  70712. /**
  70713. * Internal only
  70714. * @hidden
  70715. */
  70716. private _effectiveTarget;
  70717. /**
  70718. * Internal only
  70719. * @hidden
  70720. */
  70721. private _property;
  70722. /**
  70723. * Creates a new ValueCondition
  70724. * @param actionManager manager for the action the condition applies to
  70725. * @param target for the action
  70726. * @param propertyPath path to specify the property of the target the conditional operator uses
  70727. * @param value the value compared by the conditional operator against the current value of the property
  70728. * @param operator the conditional operator, default ValueCondition.IsEqual
  70729. */
  70730. constructor(actionManager: ActionManager, target: any,
  70731. /** path to specify the property of the target the conditional operator uses */
  70732. propertyPath: string,
  70733. /** the value compared by the conditional operator against the current value of the property */
  70734. value: any,
  70735. /** the conditional operator, default ValueCondition.IsEqual */
  70736. operator?: number);
  70737. /**
  70738. * Compares the given value with the property value for the specified conditional operator
  70739. * @returns the result of the comparison
  70740. */
  70741. isValid(): boolean;
  70742. /**
  70743. * Serialize the ValueCondition into a JSON compatible object
  70744. * @returns serialization object
  70745. */
  70746. serialize(): any;
  70747. /**
  70748. * Gets the name of the conditional operator for the ValueCondition
  70749. * @param operator the conditional operator
  70750. * @returns the name
  70751. */
  70752. static GetOperatorName(operator: number): string;
  70753. }
  70754. /**
  70755. * Defines a predicate condition as an extension of Condition
  70756. */
  70757. export class PredicateCondition extends Condition {
  70758. /** defines the predicate function used to validate the condition */
  70759. predicate: () => boolean;
  70760. /**
  70761. * Internal only - manager for action
  70762. * @hidden
  70763. */
  70764. _actionManager: ActionManager;
  70765. /**
  70766. * Creates a new PredicateCondition
  70767. * @param actionManager manager for the action the condition applies to
  70768. * @param predicate defines the predicate function used to validate the condition
  70769. */
  70770. constructor(actionManager: ActionManager,
  70771. /** defines the predicate function used to validate the condition */
  70772. predicate: () => boolean);
  70773. /**
  70774. * @returns the validity of the predicate condition
  70775. */
  70776. isValid(): boolean;
  70777. }
  70778. /**
  70779. * Defines a state condition as an extension of Condition
  70780. */
  70781. export class StateCondition extends Condition {
  70782. /** Value to compare with target state */
  70783. value: string;
  70784. /**
  70785. * Internal only - manager for action
  70786. * @hidden
  70787. */
  70788. _actionManager: ActionManager;
  70789. /**
  70790. * Internal only
  70791. * @hidden
  70792. */
  70793. private _target;
  70794. /**
  70795. * Creates a new StateCondition
  70796. * @param actionManager manager for the action the condition applies to
  70797. * @param target of the condition
  70798. * @param value to compare with target state
  70799. */
  70800. constructor(actionManager: ActionManager, target: any,
  70801. /** Value to compare with target state */
  70802. value: string);
  70803. /**
  70804. * Gets a boolean indicating if the current condition is met
  70805. * @returns the validity of the state
  70806. */
  70807. isValid(): boolean;
  70808. /**
  70809. * Serialize the StateCondition into a JSON compatible object
  70810. * @returns serialization object
  70811. */
  70812. serialize(): any;
  70813. }
  70814. }
  70815. declare module BABYLON {
  70816. /**
  70817. * This defines an action responsible to toggle a boolean once triggered.
  70818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70819. */
  70820. export class SwitchBooleanAction extends Action {
  70821. /**
  70822. * The path to the boolean property in the target object
  70823. */
  70824. propertyPath: string;
  70825. private _target;
  70826. private _effectiveTarget;
  70827. private _property;
  70828. /**
  70829. * Instantiate the action
  70830. * @param triggerOptions defines the trigger options
  70831. * @param target defines the object containing the boolean
  70832. * @param propertyPath defines the path to the boolean property in the target object
  70833. * @param condition defines the trigger related conditions
  70834. */
  70835. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70836. /** @hidden */
  70837. _prepare(): void;
  70838. /**
  70839. * Execute the action toggle the boolean value.
  70840. */
  70841. execute(): void;
  70842. /**
  70843. * Serializes the actions and its related information.
  70844. * @param parent defines the object to serialize in
  70845. * @returns the serialized object
  70846. */
  70847. serialize(parent: any): any;
  70848. }
  70849. /**
  70850. * This defines an action responsible to set a the state field of the target
  70851. * to a desired value once triggered.
  70852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70853. */
  70854. export class SetStateAction extends Action {
  70855. /**
  70856. * The value to store in the state field.
  70857. */
  70858. value: string;
  70859. private _target;
  70860. /**
  70861. * Instantiate the action
  70862. * @param triggerOptions defines the trigger options
  70863. * @param target defines the object containing the state property
  70864. * @param value defines the value to store in the state field
  70865. * @param condition defines the trigger related conditions
  70866. */
  70867. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70868. /**
  70869. * Execute the action and store the value on the target state property.
  70870. */
  70871. execute(): void;
  70872. /**
  70873. * Serializes the actions and its related information.
  70874. * @param parent defines the object to serialize in
  70875. * @returns the serialized object
  70876. */
  70877. serialize(parent: any): any;
  70878. }
  70879. /**
  70880. * This defines an action responsible to set a property of the target
  70881. * to a desired value once triggered.
  70882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70883. */
  70884. export class SetValueAction extends Action {
  70885. /**
  70886. * The path of the property to set in the target.
  70887. */
  70888. propertyPath: string;
  70889. /**
  70890. * The value to set in the property
  70891. */
  70892. value: any;
  70893. private _target;
  70894. private _effectiveTarget;
  70895. private _property;
  70896. /**
  70897. * Instantiate the action
  70898. * @param triggerOptions defines the trigger options
  70899. * @param target defines the object containing the property
  70900. * @param propertyPath defines the path of the property to set in the target
  70901. * @param value defines the value to set in the property
  70902. * @param condition defines the trigger related conditions
  70903. */
  70904. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70905. /** @hidden */
  70906. _prepare(): void;
  70907. /**
  70908. * Execute the action and set the targetted property to the desired value.
  70909. */
  70910. execute(): void;
  70911. /**
  70912. * Serializes the actions and its related information.
  70913. * @param parent defines the object to serialize in
  70914. * @returns the serialized object
  70915. */
  70916. serialize(parent: any): any;
  70917. }
  70918. /**
  70919. * This defines an action responsible to increment the target value
  70920. * to a desired value once triggered.
  70921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70922. */
  70923. export class IncrementValueAction extends Action {
  70924. /**
  70925. * The path of the property to increment in the target.
  70926. */
  70927. propertyPath: string;
  70928. /**
  70929. * The value we should increment the property by.
  70930. */
  70931. value: any;
  70932. private _target;
  70933. private _effectiveTarget;
  70934. private _property;
  70935. /**
  70936. * Instantiate the action
  70937. * @param triggerOptions defines the trigger options
  70938. * @param target defines the object containing the property
  70939. * @param propertyPath defines the path of the property to increment in the target
  70940. * @param value defines the value value we should increment the property by
  70941. * @param condition defines the trigger related conditions
  70942. */
  70943. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70944. /** @hidden */
  70945. _prepare(): void;
  70946. /**
  70947. * Execute the action and increment the target of the value amount.
  70948. */
  70949. execute(): void;
  70950. /**
  70951. * Serializes the actions and its related information.
  70952. * @param parent defines the object to serialize in
  70953. * @returns the serialized object
  70954. */
  70955. serialize(parent: any): any;
  70956. }
  70957. /**
  70958. * This defines an action responsible to start an animation once triggered.
  70959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70960. */
  70961. export class PlayAnimationAction extends Action {
  70962. /**
  70963. * Where the animation should start (animation frame)
  70964. */
  70965. from: number;
  70966. /**
  70967. * Where the animation should stop (animation frame)
  70968. */
  70969. to: number;
  70970. /**
  70971. * Define if the animation should loop or stop after the first play.
  70972. */
  70973. loop?: boolean;
  70974. private _target;
  70975. /**
  70976. * Instantiate the action
  70977. * @param triggerOptions defines the trigger options
  70978. * @param target defines the target animation or animation name
  70979. * @param from defines from where the animation should start (animation frame)
  70980. * @param end defines where the animation should stop (animation frame)
  70981. * @param loop defines if the animation should loop or stop after the first play
  70982. * @param condition defines the trigger related conditions
  70983. */
  70984. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70985. /** @hidden */
  70986. _prepare(): void;
  70987. /**
  70988. * Execute the action and play the animation.
  70989. */
  70990. execute(): void;
  70991. /**
  70992. * Serializes the actions and its related information.
  70993. * @param parent defines the object to serialize in
  70994. * @returns the serialized object
  70995. */
  70996. serialize(parent: any): any;
  70997. }
  70998. /**
  70999. * This defines an action responsible to stop an animation once triggered.
  71000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71001. */
  71002. export class StopAnimationAction extends Action {
  71003. private _target;
  71004. /**
  71005. * Instantiate the action
  71006. * @param triggerOptions defines the trigger options
  71007. * @param target defines the target animation or animation name
  71008. * @param condition defines the trigger related conditions
  71009. */
  71010. constructor(triggerOptions: any, target: any, condition?: Condition);
  71011. /** @hidden */
  71012. _prepare(): void;
  71013. /**
  71014. * Execute the action and stop the animation.
  71015. */
  71016. execute(): void;
  71017. /**
  71018. * Serializes the actions and its related information.
  71019. * @param parent defines the object to serialize in
  71020. * @returns the serialized object
  71021. */
  71022. serialize(parent: any): any;
  71023. }
  71024. /**
  71025. * This defines an action responsible that does nothing once triggered.
  71026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71027. */
  71028. export class DoNothingAction extends Action {
  71029. /**
  71030. * Instantiate the action
  71031. * @param triggerOptions defines the trigger options
  71032. * @param condition defines the trigger related conditions
  71033. */
  71034. constructor(triggerOptions?: any, condition?: Condition);
  71035. /**
  71036. * Execute the action and do nothing.
  71037. */
  71038. execute(): void;
  71039. /**
  71040. * Serializes the actions and its related information.
  71041. * @param parent defines the object to serialize in
  71042. * @returns the serialized object
  71043. */
  71044. serialize(parent: any): any;
  71045. }
  71046. /**
  71047. * This defines an action responsible to trigger several actions once triggered.
  71048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71049. */
  71050. export class CombineAction extends Action {
  71051. /**
  71052. * The list of aggregated animations to run.
  71053. */
  71054. children: Action[];
  71055. /**
  71056. * Instantiate the action
  71057. * @param triggerOptions defines the trigger options
  71058. * @param children defines the list of aggregated animations to run
  71059. * @param condition defines the trigger related conditions
  71060. */
  71061. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  71062. /** @hidden */
  71063. _prepare(): void;
  71064. /**
  71065. * Execute the action and executes all the aggregated actions.
  71066. */
  71067. execute(evt: ActionEvent): void;
  71068. /**
  71069. * Serializes the actions and its related information.
  71070. * @param parent defines the object to serialize in
  71071. * @returns the serialized object
  71072. */
  71073. serialize(parent: any): any;
  71074. }
  71075. /**
  71076. * This defines an action responsible to run code (external event) once triggered.
  71077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71078. */
  71079. export class ExecuteCodeAction extends Action {
  71080. /**
  71081. * The callback function to run.
  71082. */
  71083. func: (evt: ActionEvent) => void;
  71084. /**
  71085. * Instantiate the action
  71086. * @param triggerOptions defines the trigger options
  71087. * @param func defines the callback function to run
  71088. * @param condition defines the trigger related conditions
  71089. */
  71090. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  71091. /**
  71092. * Execute the action and run the attached code.
  71093. */
  71094. execute(evt: ActionEvent): void;
  71095. }
  71096. /**
  71097. * This defines an action responsible to set the parent property of the target once triggered.
  71098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71099. */
  71100. export class SetParentAction extends Action {
  71101. private _parent;
  71102. private _target;
  71103. /**
  71104. * Instantiate the action
  71105. * @param triggerOptions defines the trigger options
  71106. * @param target defines the target containing the parent property
  71107. * @param parent defines from where the animation should start (animation frame)
  71108. * @param condition defines the trigger related conditions
  71109. */
  71110. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  71111. /** @hidden */
  71112. _prepare(): void;
  71113. /**
  71114. * Execute the action and set the parent property.
  71115. */
  71116. execute(): void;
  71117. /**
  71118. * Serializes the actions and its related information.
  71119. * @param parent defines the object to serialize in
  71120. * @returns the serialized object
  71121. */
  71122. serialize(parent: any): any;
  71123. }
  71124. }
  71125. declare module BABYLON {
  71126. /**
  71127. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  71128. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  71129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71130. */
  71131. export class ActionManager extends AbstractActionManager {
  71132. /**
  71133. * Nothing
  71134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71135. */
  71136. static readonly NothingTrigger: number;
  71137. /**
  71138. * On pick
  71139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71140. */
  71141. static readonly OnPickTrigger: number;
  71142. /**
  71143. * On left pick
  71144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71145. */
  71146. static readonly OnLeftPickTrigger: number;
  71147. /**
  71148. * On right pick
  71149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71150. */
  71151. static readonly OnRightPickTrigger: number;
  71152. /**
  71153. * On center pick
  71154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71155. */
  71156. static readonly OnCenterPickTrigger: number;
  71157. /**
  71158. * On pick down
  71159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71160. */
  71161. static readonly OnPickDownTrigger: number;
  71162. /**
  71163. * On double pick
  71164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71165. */
  71166. static readonly OnDoublePickTrigger: number;
  71167. /**
  71168. * On pick up
  71169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71170. */
  71171. static readonly OnPickUpTrigger: number;
  71172. /**
  71173. * On pick out.
  71174. * This trigger will only be raised if you also declared a OnPickDown
  71175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71176. */
  71177. static readonly OnPickOutTrigger: number;
  71178. /**
  71179. * On long press
  71180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71181. */
  71182. static readonly OnLongPressTrigger: number;
  71183. /**
  71184. * On pointer over
  71185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71186. */
  71187. static readonly OnPointerOverTrigger: number;
  71188. /**
  71189. * On pointer out
  71190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71191. */
  71192. static readonly OnPointerOutTrigger: number;
  71193. /**
  71194. * On every frame
  71195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71196. */
  71197. static readonly OnEveryFrameTrigger: number;
  71198. /**
  71199. * On intersection enter
  71200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71201. */
  71202. static readonly OnIntersectionEnterTrigger: number;
  71203. /**
  71204. * On intersection exit
  71205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71206. */
  71207. static readonly OnIntersectionExitTrigger: number;
  71208. /**
  71209. * On key down
  71210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71211. */
  71212. static readonly OnKeyDownTrigger: number;
  71213. /**
  71214. * On key up
  71215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71216. */
  71217. static readonly OnKeyUpTrigger: number;
  71218. private _scene;
  71219. /**
  71220. * Creates a new action manager
  71221. * @param scene defines the hosting scene
  71222. */
  71223. constructor(scene: Scene);
  71224. /**
  71225. * Releases all associated resources
  71226. */
  71227. dispose(): void;
  71228. /**
  71229. * Gets hosting scene
  71230. * @returns the hosting scene
  71231. */
  71232. getScene(): Scene;
  71233. /**
  71234. * Does this action manager handles actions of any of the given triggers
  71235. * @param triggers defines the triggers to be tested
  71236. * @return a boolean indicating whether one (or more) of the triggers is handled
  71237. */
  71238. hasSpecificTriggers(triggers: number[]): boolean;
  71239. /**
  71240. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71241. * speed.
  71242. * @param triggerA defines the trigger to be tested
  71243. * @param triggerB defines the trigger to be tested
  71244. * @return a boolean indicating whether one (or more) of the triggers is handled
  71245. */
  71246. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71247. /**
  71248. * Does this action manager handles actions of a given trigger
  71249. * @param trigger defines the trigger to be tested
  71250. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71251. * @return whether the trigger is handled
  71252. */
  71253. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71254. /**
  71255. * Does this action manager has pointer triggers
  71256. */
  71257. readonly hasPointerTriggers: boolean;
  71258. /**
  71259. * Does this action manager has pick triggers
  71260. */
  71261. readonly hasPickTriggers: boolean;
  71262. /**
  71263. * Registers an action to this action manager
  71264. * @param action defines the action to be registered
  71265. * @return the action amended (prepared) after registration
  71266. */
  71267. registerAction(action: IAction): Nullable<IAction>;
  71268. /**
  71269. * Unregisters an action to this action manager
  71270. * @param action defines the action to be unregistered
  71271. * @return a boolean indicating whether the action has been unregistered
  71272. */
  71273. unregisterAction(action: IAction): Boolean;
  71274. /**
  71275. * Process a specific trigger
  71276. * @param trigger defines the trigger to process
  71277. * @param evt defines the event details to be processed
  71278. */
  71279. processTrigger(trigger: number, evt?: IActionEvent): void;
  71280. /** @hidden */
  71281. _getEffectiveTarget(target: any, propertyPath: string): any;
  71282. /** @hidden */
  71283. _getProperty(propertyPath: string): string;
  71284. /**
  71285. * Serialize this manager to a JSON object
  71286. * @param name defines the property name to store this manager
  71287. * @returns a JSON representation of this manager
  71288. */
  71289. serialize(name: string): any;
  71290. /**
  71291. * Creates a new ActionManager from a JSON data
  71292. * @param parsedActions defines the JSON data to read from
  71293. * @param object defines the hosting mesh
  71294. * @param scene defines the hosting scene
  71295. */
  71296. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71297. /**
  71298. * Get a trigger name by index
  71299. * @param trigger defines the trigger index
  71300. * @returns a trigger name
  71301. */
  71302. static GetTriggerName(trigger: number): string;
  71303. }
  71304. }
  71305. declare module BABYLON {
  71306. /**
  71307. * Class representing a ray with position and direction
  71308. */
  71309. export class Ray {
  71310. /** origin point */
  71311. origin: Vector3;
  71312. /** direction */
  71313. direction: Vector3;
  71314. /** length of the ray */
  71315. length: number;
  71316. private static readonly TmpVector3;
  71317. private _tmpRay;
  71318. /**
  71319. * Creates a new ray
  71320. * @param origin origin point
  71321. * @param direction direction
  71322. * @param length length of the ray
  71323. */
  71324. constructor(
  71325. /** origin point */
  71326. origin: Vector3,
  71327. /** direction */
  71328. direction: Vector3,
  71329. /** length of the ray */
  71330. length?: number);
  71331. /**
  71332. * Checks if the ray intersects a box
  71333. * @param minimum bound of the box
  71334. * @param maximum bound of the box
  71335. * @param intersectionTreshold extra extend to be added to the box in all direction
  71336. * @returns if the box was hit
  71337. */
  71338. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71339. /**
  71340. * Checks if the ray intersects a box
  71341. * @param box the bounding box to check
  71342. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71343. * @returns if the box was hit
  71344. */
  71345. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71346. /**
  71347. * If the ray hits a sphere
  71348. * @param sphere the bounding sphere to check
  71349. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71350. * @returns true if it hits the sphere
  71351. */
  71352. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71353. /**
  71354. * If the ray hits a triange
  71355. * @param vertex0 triangle vertex
  71356. * @param vertex1 triangle vertex
  71357. * @param vertex2 triangle vertex
  71358. * @returns intersection information if hit
  71359. */
  71360. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71361. /**
  71362. * Checks if ray intersects a plane
  71363. * @param plane the plane to check
  71364. * @returns the distance away it was hit
  71365. */
  71366. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71367. /**
  71368. * Checks if ray intersects a mesh
  71369. * @param mesh the mesh to check
  71370. * @param fastCheck if only the bounding box should checked
  71371. * @returns picking info of the intersecton
  71372. */
  71373. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71374. /**
  71375. * Checks if ray intersects a mesh
  71376. * @param meshes the meshes to check
  71377. * @param fastCheck if only the bounding box should checked
  71378. * @param results array to store result in
  71379. * @returns Array of picking infos
  71380. */
  71381. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71382. private _comparePickingInfo;
  71383. private static smallnum;
  71384. private static rayl;
  71385. /**
  71386. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71387. * @param sega the first point of the segment to test the intersection against
  71388. * @param segb the second point of the segment to test the intersection against
  71389. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71390. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71391. */
  71392. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71393. /**
  71394. * Update the ray from viewport position
  71395. * @param x position
  71396. * @param y y position
  71397. * @param viewportWidth viewport width
  71398. * @param viewportHeight viewport height
  71399. * @param world world matrix
  71400. * @param view view matrix
  71401. * @param projection projection matrix
  71402. * @returns this ray updated
  71403. */
  71404. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71405. /**
  71406. * Creates a ray with origin and direction of 0,0,0
  71407. * @returns the new ray
  71408. */
  71409. static Zero(): Ray;
  71410. /**
  71411. * Creates a new ray from screen space and viewport
  71412. * @param x position
  71413. * @param y y position
  71414. * @param viewportWidth viewport width
  71415. * @param viewportHeight viewport height
  71416. * @param world world matrix
  71417. * @param view view matrix
  71418. * @param projection projection matrix
  71419. * @returns new ray
  71420. */
  71421. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71422. /**
  71423. * 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
  71424. * transformed to the given world matrix.
  71425. * @param origin The origin point
  71426. * @param end The end point
  71427. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71428. * @returns the new ray
  71429. */
  71430. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71431. /**
  71432. * Transforms a ray by a matrix
  71433. * @param ray ray to transform
  71434. * @param matrix matrix to apply
  71435. * @returns the resulting new ray
  71436. */
  71437. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71438. /**
  71439. * Transforms a ray by a matrix
  71440. * @param ray ray to transform
  71441. * @param matrix matrix to apply
  71442. * @param result ray to store result in
  71443. */
  71444. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71445. /**
  71446. * Unproject a ray from screen space to object space
  71447. * @param sourceX defines the screen space x coordinate to use
  71448. * @param sourceY defines the screen space y coordinate to use
  71449. * @param viewportWidth defines the current width of the viewport
  71450. * @param viewportHeight defines the current height of the viewport
  71451. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71452. * @param view defines the view matrix to use
  71453. * @param projection defines the projection matrix to use
  71454. */
  71455. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71456. }
  71457. /**
  71458. * Type used to define predicate used to select faces when a mesh intersection is detected
  71459. */
  71460. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71461. interface Scene {
  71462. /** @hidden */
  71463. _tempPickingRay: Nullable<Ray>;
  71464. /** @hidden */
  71465. _cachedRayForTransform: Ray;
  71466. /** @hidden */
  71467. _pickWithRayInverseMatrix: Matrix;
  71468. /** @hidden */
  71469. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71470. /** @hidden */
  71471. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71472. }
  71473. }
  71474. declare module BABYLON {
  71475. /**
  71476. * Groups all the scene component constants in one place to ease maintenance.
  71477. * @hidden
  71478. */
  71479. export class SceneComponentConstants {
  71480. static readonly NAME_EFFECTLAYER: string;
  71481. static readonly NAME_LAYER: string;
  71482. static readonly NAME_LENSFLARESYSTEM: string;
  71483. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71484. static readonly NAME_PARTICLESYSTEM: string;
  71485. static readonly NAME_GAMEPAD: string;
  71486. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71487. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71488. static readonly NAME_DEPTHRENDERER: string;
  71489. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71490. static readonly NAME_SPRITE: string;
  71491. static readonly NAME_OUTLINERENDERER: string;
  71492. static readonly NAME_PROCEDURALTEXTURE: string;
  71493. static readonly NAME_SHADOWGENERATOR: string;
  71494. static readonly NAME_OCTREE: string;
  71495. static readonly NAME_PHYSICSENGINE: string;
  71496. static readonly NAME_AUDIO: string;
  71497. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71498. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71499. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71500. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71501. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71502. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71503. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71504. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71505. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71506. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71507. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71508. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71509. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71510. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71511. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71512. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71513. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71514. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71515. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71516. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71517. static readonly STEP_AFTERRENDER_AUDIO: number;
  71518. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71519. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71520. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71521. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71522. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71523. static readonly STEP_POINTERMOVE_SPRITE: number;
  71524. static readonly STEP_POINTERDOWN_SPRITE: number;
  71525. static readonly STEP_POINTERUP_SPRITE: number;
  71526. }
  71527. /**
  71528. * This represents a scene component.
  71529. *
  71530. * This is used to decouple the dependency the scene is having on the different workloads like
  71531. * layers, post processes...
  71532. */
  71533. export interface ISceneComponent {
  71534. /**
  71535. * The name of the component. Each component must have a unique name.
  71536. */
  71537. name: string;
  71538. /**
  71539. * The scene the component belongs to.
  71540. */
  71541. scene: Scene;
  71542. /**
  71543. * Register the component to one instance of a scene.
  71544. */
  71545. register(): void;
  71546. /**
  71547. * Rebuilds the elements related to this component in case of
  71548. * context lost for instance.
  71549. */
  71550. rebuild(): void;
  71551. /**
  71552. * Disposes the component and the associated ressources.
  71553. */
  71554. dispose(): void;
  71555. }
  71556. /**
  71557. * This represents a SERIALIZABLE scene component.
  71558. *
  71559. * This extends Scene Component to add Serialization methods on top.
  71560. */
  71561. export interface ISceneSerializableComponent extends ISceneComponent {
  71562. /**
  71563. * Adds all the element from the container to the scene
  71564. * @param container the container holding the elements
  71565. */
  71566. addFromContainer(container: AbstractScene): void;
  71567. /**
  71568. * Removes all the elements in the container from the scene
  71569. * @param container contains the elements to remove
  71570. * @param dispose if the removed element should be disposed (default: false)
  71571. */
  71572. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71573. /**
  71574. * Serializes the component data to the specified json object
  71575. * @param serializationObject The object to serialize to
  71576. */
  71577. serialize(serializationObject: any): void;
  71578. }
  71579. /**
  71580. * Strong typing of a Mesh related stage step action
  71581. */
  71582. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71583. /**
  71584. * Strong typing of a Evaluate Sub Mesh related stage step action
  71585. */
  71586. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71587. /**
  71588. * Strong typing of a Active Mesh related stage step action
  71589. */
  71590. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71591. /**
  71592. * Strong typing of a Camera related stage step action
  71593. */
  71594. export type CameraStageAction = (camera: Camera) => void;
  71595. /**
  71596. * Strong typing of a Camera Frame buffer related stage step action
  71597. */
  71598. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71599. /**
  71600. * Strong typing of a Render Target related stage step action
  71601. */
  71602. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71603. /**
  71604. * Strong typing of a RenderingGroup related stage step action
  71605. */
  71606. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71607. /**
  71608. * Strong typing of a Mesh Render related stage step action
  71609. */
  71610. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71611. /**
  71612. * Strong typing of a simple stage step action
  71613. */
  71614. export type SimpleStageAction = () => void;
  71615. /**
  71616. * Strong typing of a render target action.
  71617. */
  71618. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71619. /**
  71620. * Strong typing of a pointer move action.
  71621. */
  71622. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71623. /**
  71624. * Strong typing of a pointer up/down action.
  71625. */
  71626. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71627. /**
  71628. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71629. * @hidden
  71630. */
  71631. export class Stage<T extends Function> extends Array<{
  71632. index: number;
  71633. component: ISceneComponent;
  71634. action: T;
  71635. }> {
  71636. /**
  71637. * Hide ctor from the rest of the world.
  71638. * @param items The items to add.
  71639. */
  71640. private constructor();
  71641. /**
  71642. * Creates a new Stage.
  71643. * @returns A new instance of a Stage
  71644. */
  71645. static Create<T extends Function>(): Stage<T>;
  71646. /**
  71647. * Registers a step in an ordered way in the targeted stage.
  71648. * @param index Defines the position to register the step in
  71649. * @param component Defines the component attached to the step
  71650. * @param action Defines the action to launch during the step
  71651. */
  71652. registerStep(index: number, component: ISceneComponent, action: T): void;
  71653. /**
  71654. * Clears all the steps from the stage.
  71655. */
  71656. clear(): void;
  71657. }
  71658. }
  71659. declare module BABYLON {
  71660. interface Scene {
  71661. /** @hidden */
  71662. _pointerOverSprite: Nullable<Sprite>;
  71663. /** @hidden */
  71664. _pickedDownSprite: Nullable<Sprite>;
  71665. /** @hidden */
  71666. _tempSpritePickingRay: Nullable<Ray>;
  71667. /**
  71668. * All of the sprite managers added to this scene
  71669. * @see http://doc.babylonjs.com/babylon101/sprites
  71670. */
  71671. spriteManagers: Array<ISpriteManager>;
  71672. /**
  71673. * An event triggered when sprites rendering is about to start
  71674. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71675. */
  71676. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71677. /**
  71678. * An event triggered when sprites rendering is done
  71679. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71680. */
  71681. onAfterSpritesRenderingObservable: Observable<Scene>;
  71682. /** @hidden */
  71683. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71684. /** Launch a ray to try to pick a sprite in the scene
  71685. * @param x position on screen
  71686. * @param y position on screen
  71687. * @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
  71688. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71689. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71690. * @returns a PickingInfo
  71691. */
  71692. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71693. /** Use the given ray to pick a sprite in the scene
  71694. * @param ray The ray (in world space) to use to pick meshes
  71695. * @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
  71696. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71697. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71698. * @returns a PickingInfo
  71699. */
  71700. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71701. /**
  71702. * Force the sprite under the pointer
  71703. * @param sprite defines the sprite to use
  71704. */
  71705. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71706. /**
  71707. * Gets the sprite under the pointer
  71708. * @returns a Sprite or null if no sprite is under the pointer
  71709. */
  71710. getPointerOverSprite(): Nullable<Sprite>;
  71711. }
  71712. /**
  71713. * Defines the sprite scene component responsible to manage sprites
  71714. * in a given scene.
  71715. */
  71716. export class SpriteSceneComponent implements ISceneComponent {
  71717. /**
  71718. * The component name helpfull to identify the component in the list of scene components.
  71719. */
  71720. readonly name: string;
  71721. /**
  71722. * The scene the component belongs to.
  71723. */
  71724. scene: Scene;
  71725. /** @hidden */
  71726. private _spritePredicate;
  71727. /**
  71728. * Creates a new instance of the component for the given scene
  71729. * @param scene Defines the scene to register the component in
  71730. */
  71731. constructor(scene: Scene);
  71732. /**
  71733. * Registers the component in a given scene
  71734. */
  71735. register(): void;
  71736. /**
  71737. * Rebuilds the elements related to this component in case of
  71738. * context lost for instance.
  71739. */
  71740. rebuild(): void;
  71741. /**
  71742. * Disposes the component and the associated ressources.
  71743. */
  71744. dispose(): void;
  71745. private _pickSpriteButKeepRay;
  71746. private _pointerMove;
  71747. private _pointerDown;
  71748. private _pointerUp;
  71749. }
  71750. }
  71751. declare module BABYLON {
  71752. /** @hidden */
  71753. export var fogFragmentDeclaration: {
  71754. name: string;
  71755. shader: string;
  71756. };
  71757. }
  71758. declare module BABYLON {
  71759. /** @hidden */
  71760. export var fogFragment: {
  71761. name: string;
  71762. shader: string;
  71763. };
  71764. }
  71765. declare module BABYLON {
  71766. /** @hidden */
  71767. export var spritesPixelShader: {
  71768. name: string;
  71769. shader: string;
  71770. };
  71771. }
  71772. declare module BABYLON {
  71773. /** @hidden */
  71774. export var fogVertexDeclaration: {
  71775. name: string;
  71776. shader: string;
  71777. };
  71778. }
  71779. declare module BABYLON {
  71780. /** @hidden */
  71781. export var spritesVertexShader: {
  71782. name: string;
  71783. shader: string;
  71784. };
  71785. }
  71786. declare module BABYLON {
  71787. /**
  71788. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71789. */
  71790. export interface ISpriteManager extends IDisposable {
  71791. /**
  71792. * Restricts the camera to viewing objects with the same layerMask.
  71793. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71794. */
  71795. layerMask: number;
  71796. /**
  71797. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71798. */
  71799. isPickable: boolean;
  71800. /**
  71801. * Specifies the rendering group id for this mesh (0 by default)
  71802. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71803. */
  71804. renderingGroupId: number;
  71805. /**
  71806. * Defines the list of sprites managed by the manager.
  71807. */
  71808. sprites: Array<Sprite>;
  71809. /**
  71810. * Tests the intersection of a sprite with a specific ray.
  71811. * @param ray The ray we are sending to test the collision
  71812. * @param camera The camera space we are sending rays in
  71813. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71814. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71815. * @returns picking info or null.
  71816. */
  71817. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71818. /**
  71819. * Renders the list of sprites on screen.
  71820. */
  71821. render(): void;
  71822. }
  71823. /**
  71824. * Class used to manage multiple sprites on the same spritesheet
  71825. * @see http://doc.babylonjs.com/babylon101/sprites
  71826. */
  71827. export class SpriteManager implements ISpriteManager {
  71828. /** defines the manager's name */
  71829. name: string;
  71830. /** Gets the list of sprites */
  71831. sprites: Sprite[];
  71832. /** Gets or sets the rendering group id (0 by default) */
  71833. renderingGroupId: number;
  71834. /** Gets or sets camera layer mask */
  71835. layerMask: number;
  71836. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71837. fogEnabled: boolean;
  71838. /** Gets or sets a boolean indicating if the sprites are pickable */
  71839. isPickable: boolean;
  71840. /** Defines the default width of a cell in the spritesheet */
  71841. cellWidth: number;
  71842. /** Defines the default height of a cell in the spritesheet */
  71843. cellHeight: number;
  71844. /**
  71845. * An event triggered when the manager is disposed.
  71846. */
  71847. onDisposeObservable: Observable<SpriteManager>;
  71848. private _onDisposeObserver;
  71849. /**
  71850. * Callback called when the manager is disposed
  71851. */
  71852. onDispose: () => void;
  71853. private _capacity;
  71854. private _spriteTexture;
  71855. private _epsilon;
  71856. private _scene;
  71857. private _vertexData;
  71858. private _buffer;
  71859. private _vertexBuffers;
  71860. private _indexBuffer;
  71861. private _effectBase;
  71862. private _effectFog;
  71863. /**
  71864. * Gets or sets the spritesheet texture
  71865. */
  71866. texture: Texture;
  71867. /**
  71868. * Creates a new sprite manager
  71869. * @param name defines the manager's name
  71870. * @param imgUrl defines the sprite sheet url
  71871. * @param capacity defines the maximum allowed number of sprites
  71872. * @param cellSize defines the size of a sprite cell
  71873. * @param scene defines the hosting scene
  71874. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71875. * @param samplingMode defines the smapling mode to use with spritesheet
  71876. */
  71877. constructor(
  71878. /** defines the manager's name */
  71879. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71880. private _appendSpriteVertex;
  71881. /**
  71882. * Intersects the sprites with a ray
  71883. * @param ray defines the ray to intersect with
  71884. * @param camera defines the current active camera
  71885. * @param predicate defines a predicate used to select candidate sprites
  71886. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71887. * @returns null if no hit or a PickingInfo
  71888. */
  71889. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71890. /**
  71891. * Render all child sprites
  71892. */
  71893. render(): void;
  71894. /**
  71895. * Release associated resources
  71896. */
  71897. dispose(): void;
  71898. }
  71899. }
  71900. declare module BABYLON {
  71901. /**
  71902. * Class used to represent a sprite
  71903. * @see http://doc.babylonjs.com/babylon101/sprites
  71904. */
  71905. export class Sprite {
  71906. /** defines the name */
  71907. name: string;
  71908. /** Gets or sets the current world position */
  71909. position: Vector3;
  71910. /** Gets or sets the main color */
  71911. color: Color4;
  71912. /** Gets or sets the width */
  71913. width: number;
  71914. /** Gets or sets the height */
  71915. height: number;
  71916. /** Gets or sets rotation angle */
  71917. angle: number;
  71918. /** Gets or sets the cell index in the sprite sheet */
  71919. cellIndex: number;
  71920. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71921. invertU: number;
  71922. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71923. invertV: number;
  71924. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71925. disposeWhenFinishedAnimating: boolean;
  71926. /** Gets the list of attached animations */
  71927. animations: Animation[];
  71928. /** Gets or sets a boolean indicating if the sprite can be picked */
  71929. isPickable: boolean;
  71930. /**
  71931. * Gets or sets the associated action manager
  71932. */
  71933. actionManager: Nullable<ActionManager>;
  71934. private _animationStarted;
  71935. private _loopAnimation;
  71936. private _fromIndex;
  71937. private _toIndex;
  71938. private _delay;
  71939. private _direction;
  71940. private _manager;
  71941. private _time;
  71942. private _onAnimationEnd;
  71943. /**
  71944. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71945. */
  71946. isVisible: boolean;
  71947. /**
  71948. * Gets or sets the sprite size
  71949. */
  71950. size: number;
  71951. /**
  71952. * Creates a new Sprite
  71953. * @param name defines the name
  71954. * @param manager defines the manager
  71955. */
  71956. constructor(
  71957. /** defines the name */
  71958. name: string, manager: ISpriteManager);
  71959. /**
  71960. * Starts an animation
  71961. * @param from defines the initial key
  71962. * @param to defines the end key
  71963. * @param loop defines if the animation must loop
  71964. * @param delay defines the start delay (in ms)
  71965. * @param onAnimationEnd defines a callback to call when animation ends
  71966. */
  71967. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71968. /** Stops current animation (if any) */
  71969. stopAnimation(): void;
  71970. /** @hidden */
  71971. _animate(deltaTime: number): void;
  71972. /** Release associated resources */
  71973. dispose(): void;
  71974. }
  71975. }
  71976. declare module BABYLON {
  71977. /**
  71978. * Information about the result of picking within a scene
  71979. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71980. */
  71981. export class PickingInfo {
  71982. /** @hidden */
  71983. _pickingUnavailable: boolean;
  71984. /**
  71985. * If the pick collided with an object
  71986. */
  71987. hit: boolean;
  71988. /**
  71989. * Distance away where the pick collided
  71990. */
  71991. distance: number;
  71992. /**
  71993. * The location of pick collision
  71994. */
  71995. pickedPoint: Nullable<Vector3>;
  71996. /**
  71997. * The mesh corresponding the the pick collision
  71998. */
  71999. pickedMesh: Nullable<AbstractMesh>;
  72000. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  72001. bu: number;
  72002. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  72003. bv: number;
  72004. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  72005. faceId: number;
  72006. /** Id of the the submesh that was picked */
  72007. subMeshId: number;
  72008. /** If a sprite was picked, this will be the sprite the pick collided with */
  72009. pickedSprite: Nullable<Sprite>;
  72010. /**
  72011. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  72012. */
  72013. originMesh: Nullable<AbstractMesh>;
  72014. /**
  72015. * The ray that was used to perform the picking.
  72016. */
  72017. ray: Nullable<Ray>;
  72018. /**
  72019. * Gets the normal correspodning to the face the pick collided with
  72020. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  72021. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  72022. * @returns The normal correspodning to the face the pick collided with
  72023. */
  72024. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  72025. /**
  72026. * Gets the texture coordinates of where the pick occured
  72027. * @returns the vector containing the coordnates of the texture
  72028. */
  72029. getTextureCoordinates(): Nullable<Vector2>;
  72030. }
  72031. }
  72032. declare module BABYLON {
  72033. /**
  72034. * Gather the list of pointer event types as constants.
  72035. */
  72036. export class PointerEventTypes {
  72037. /**
  72038. * 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.
  72039. */
  72040. static readonly POINTERDOWN: number;
  72041. /**
  72042. * The pointerup event is fired when a pointer is no longer active.
  72043. */
  72044. static readonly POINTERUP: number;
  72045. /**
  72046. * The pointermove event is fired when a pointer changes coordinates.
  72047. */
  72048. static readonly POINTERMOVE: number;
  72049. /**
  72050. * The pointerwheel event is fired when a mouse wheel has been rotated.
  72051. */
  72052. static readonly POINTERWHEEL: number;
  72053. /**
  72054. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  72055. */
  72056. static readonly POINTERPICK: number;
  72057. /**
  72058. * The pointertap event is fired when a the object has been touched and released without drag.
  72059. */
  72060. static readonly POINTERTAP: number;
  72061. /**
  72062. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  72063. */
  72064. static readonly POINTERDOUBLETAP: number;
  72065. }
  72066. /**
  72067. * Base class of pointer info types.
  72068. */
  72069. export class PointerInfoBase {
  72070. /**
  72071. * Defines the type of event (PointerEventTypes)
  72072. */
  72073. type: number;
  72074. /**
  72075. * Defines the related dom event
  72076. */
  72077. event: PointerEvent | MouseWheelEvent;
  72078. /**
  72079. * Instantiates the base class of pointers info.
  72080. * @param type Defines the type of event (PointerEventTypes)
  72081. * @param event Defines the related dom event
  72082. */
  72083. constructor(
  72084. /**
  72085. * Defines the type of event (PointerEventTypes)
  72086. */
  72087. type: number,
  72088. /**
  72089. * Defines the related dom event
  72090. */
  72091. event: PointerEvent | MouseWheelEvent);
  72092. }
  72093. /**
  72094. * This class is used to store pointer related info for the onPrePointerObservable event.
  72095. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  72096. */
  72097. export class PointerInfoPre extends PointerInfoBase {
  72098. /**
  72099. * Ray from a pointer if availible (eg. 6dof controller)
  72100. */
  72101. ray: Nullable<Ray>;
  72102. /**
  72103. * Defines the local position of the pointer on the canvas.
  72104. */
  72105. localPosition: Vector2;
  72106. /**
  72107. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  72108. */
  72109. skipOnPointerObservable: boolean;
  72110. /**
  72111. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  72112. * @param type Defines the type of event (PointerEventTypes)
  72113. * @param event Defines the related dom event
  72114. * @param localX Defines the local x coordinates of the pointer when the event occured
  72115. * @param localY Defines the local y coordinates of the pointer when the event occured
  72116. */
  72117. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  72118. }
  72119. /**
  72120. * This type contains all the data related to a pointer event in Babylon.js.
  72121. * 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.
  72122. */
  72123. export class PointerInfo extends PointerInfoBase {
  72124. /**
  72125. * Defines the picking info associated to the info (if any)\
  72126. */
  72127. pickInfo: Nullable<PickingInfo>;
  72128. /**
  72129. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  72130. * @param type Defines the type of event (PointerEventTypes)
  72131. * @param event Defines the related dom event
  72132. * @param pickInfo Defines the picking info associated to the info (if any)\
  72133. */
  72134. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  72135. /**
  72136. * Defines the picking info associated to the info (if any)\
  72137. */
  72138. pickInfo: Nullable<PickingInfo>);
  72139. }
  72140. /**
  72141. * Data relating to a touch event on the screen.
  72142. */
  72143. export interface PointerTouch {
  72144. /**
  72145. * X coordinate of touch.
  72146. */
  72147. x: number;
  72148. /**
  72149. * Y coordinate of touch.
  72150. */
  72151. y: number;
  72152. /**
  72153. * Id of touch. Unique for each finger.
  72154. */
  72155. pointerId: number;
  72156. /**
  72157. * Event type passed from DOM.
  72158. */
  72159. type: any;
  72160. }
  72161. }
  72162. declare module BABYLON {
  72163. /**
  72164. * Manage the mouse inputs to control the movement of a free camera.
  72165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72166. */
  72167. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  72168. /**
  72169. * Define if touch is enabled in the mouse input
  72170. */
  72171. touchEnabled: boolean;
  72172. /**
  72173. * Defines the camera the input is attached to.
  72174. */
  72175. camera: FreeCamera;
  72176. /**
  72177. * Defines the buttons associated with the input to handle camera move.
  72178. */
  72179. buttons: number[];
  72180. /**
  72181. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  72182. */
  72183. angularSensibility: number;
  72184. private _pointerInput;
  72185. private _onMouseMove;
  72186. private _observer;
  72187. private previousPosition;
  72188. /**
  72189. * Observable for when a pointer move event occurs containing the move offset
  72190. */
  72191. onPointerMovedObservable: Observable<{
  72192. offsetX: number;
  72193. offsetY: number;
  72194. }>;
  72195. /**
  72196. * @hidden
  72197. * If the camera should be rotated automatically based on pointer movement
  72198. */
  72199. _allowCameraRotation: boolean;
  72200. /**
  72201. * Manage the mouse inputs to control the movement of a free camera.
  72202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72203. * @param touchEnabled Defines if touch is enabled or not
  72204. */
  72205. constructor(
  72206. /**
  72207. * Define if touch is enabled in the mouse input
  72208. */
  72209. touchEnabled?: boolean);
  72210. /**
  72211. * Attach the input controls to a specific dom element to get the input from.
  72212. * @param element Defines the element the controls should be listened from
  72213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72214. */
  72215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72216. /**
  72217. * Called on JS contextmenu event.
  72218. * Override this method to provide functionality.
  72219. */
  72220. protected onContextMenu(evt: PointerEvent): void;
  72221. /**
  72222. * Detach the current controls from the specified dom element.
  72223. * @param element Defines the element to stop listening the inputs from
  72224. */
  72225. detachControl(element: Nullable<HTMLElement>): void;
  72226. /**
  72227. * Gets the class name of the current intput.
  72228. * @returns the class name
  72229. */
  72230. getClassName(): string;
  72231. /**
  72232. * Get the friendly name associated with the input class.
  72233. * @returns the input friendly name
  72234. */
  72235. getSimpleName(): string;
  72236. }
  72237. }
  72238. declare module BABYLON {
  72239. /**
  72240. * Manage the touch inputs to control the movement of a free camera.
  72241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72242. */
  72243. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72244. /**
  72245. * Defines the camera the input is attached to.
  72246. */
  72247. camera: FreeCamera;
  72248. /**
  72249. * Defines the touch sensibility for rotation.
  72250. * The higher the faster.
  72251. */
  72252. touchAngularSensibility: number;
  72253. /**
  72254. * Defines the touch sensibility for move.
  72255. * The higher the faster.
  72256. */
  72257. touchMoveSensibility: number;
  72258. private _offsetX;
  72259. private _offsetY;
  72260. private _pointerPressed;
  72261. private _pointerInput;
  72262. private _observer;
  72263. private _onLostFocus;
  72264. /**
  72265. * Attach the input controls to a specific dom element to get the input from.
  72266. * @param element Defines the element the controls should be listened from
  72267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72268. */
  72269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72270. /**
  72271. * Detach the current controls from the specified dom element.
  72272. * @param element Defines the element to stop listening the inputs from
  72273. */
  72274. detachControl(element: Nullable<HTMLElement>): void;
  72275. /**
  72276. * Update the current camera state depending on the inputs that have been used this frame.
  72277. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72278. */
  72279. checkInputs(): void;
  72280. /**
  72281. * Gets the class name of the current intput.
  72282. * @returns the class name
  72283. */
  72284. getClassName(): string;
  72285. /**
  72286. * Get the friendly name associated with the input class.
  72287. * @returns the input friendly name
  72288. */
  72289. getSimpleName(): string;
  72290. }
  72291. }
  72292. declare module BABYLON {
  72293. /**
  72294. * Default Inputs manager for the FreeCamera.
  72295. * It groups all the default supported inputs for ease of use.
  72296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72297. */
  72298. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72299. /**
  72300. * @hidden
  72301. */
  72302. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  72303. /**
  72304. * @hidden
  72305. */
  72306. _mouseInput: Nullable<FreeCameraMouseInput>;
  72307. /**
  72308. * Instantiates a new FreeCameraInputsManager.
  72309. * @param camera Defines the camera the inputs belong to
  72310. */
  72311. constructor(camera: FreeCamera);
  72312. /**
  72313. * Add keyboard input support to the input manager.
  72314. * @returns the current input manager
  72315. */
  72316. addKeyboard(): FreeCameraInputsManager;
  72317. /**
  72318. * Add mouse input support to the input manager.
  72319. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72320. * @returns the current input manager
  72321. */
  72322. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72323. /**
  72324. * Removes the mouse input support from the manager
  72325. * @returns the current input manager
  72326. */
  72327. removeMouse(): FreeCameraInputsManager;
  72328. /**
  72329. * Add touch input support to the input manager.
  72330. * @returns the current input manager
  72331. */
  72332. addTouch(): FreeCameraInputsManager;
  72333. }
  72334. }
  72335. declare module BABYLON {
  72336. /**
  72337. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72338. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72339. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72340. */
  72341. export class FreeCamera extends TargetCamera {
  72342. /**
  72343. * Define the collision ellipsoid of the camera.
  72344. * This is helpful to simulate a camera body like the player body around the camera
  72345. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72346. */
  72347. ellipsoid: Vector3;
  72348. /**
  72349. * Define an offset for the position of the ellipsoid around the camera.
  72350. * This can be helpful to determine the center of the body near the gravity center of the body
  72351. * instead of its head.
  72352. */
  72353. ellipsoidOffset: Vector3;
  72354. /**
  72355. * Enable or disable collisions of the camera with the rest of the scene objects.
  72356. */
  72357. checkCollisions: boolean;
  72358. /**
  72359. * Enable or disable gravity on the camera.
  72360. */
  72361. applyGravity: boolean;
  72362. /**
  72363. * Define the input manager associated to the camera.
  72364. */
  72365. inputs: FreeCameraInputsManager;
  72366. /**
  72367. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72368. * Higher values reduce sensitivity.
  72369. */
  72370. /**
  72371. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72372. * Higher values reduce sensitivity.
  72373. */
  72374. angularSensibility: number;
  72375. /**
  72376. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72377. */
  72378. keysUp: number[];
  72379. /**
  72380. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72381. */
  72382. keysDown: number[];
  72383. /**
  72384. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72385. */
  72386. keysLeft: number[];
  72387. /**
  72388. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72389. */
  72390. keysRight: number[];
  72391. /**
  72392. * Event raised when the camera collide with a mesh in the scene.
  72393. */
  72394. onCollide: (collidedMesh: AbstractMesh) => void;
  72395. private _collider;
  72396. private _needMoveForGravity;
  72397. private _oldPosition;
  72398. private _diffPosition;
  72399. private _newPosition;
  72400. /** @hidden */
  72401. _localDirection: Vector3;
  72402. /** @hidden */
  72403. _transformedDirection: Vector3;
  72404. /**
  72405. * Instantiates a Free Camera.
  72406. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72407. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72408. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72409. * @param name Define the name of the camera in the scene
  72410. * @param position Define the start position of the camera in the scene
  72411. * @param scene Define the scene the camera belongs to
  72412. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72413. */
  72414. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72415. /**
  72416. * Attached controls to the current camera.
  72417. * @param element Defines the element the controls should be listened from
  72418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72419. */
  72420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72421. /**
  72422. * Detach the current controls from the camera.
  72423. * The camera will stop reacting to inputs.
  72424. * @param element Defines the element to stop listening the inputs from
  72425. */
  72426. detachControl(element: HTMLElement): void;
  72427. private _collisionMask;
  72428. /**
  72429. * Define a collision mask to limit the list of object the camera can collide with
  72430. */
  72431. collisionMask: number;
  72432. /** @hidden */
  72433. _collideWithWorld(displacement: Vector3): void;
  72434. private _onCollisionPositionChange;
  72435. /** @hidden */
  72436. _checkInputs(): void;
  72437. /** @hidden */
  72438. _decideIfNeedsToMove(): boolean;
  72439. /** @hidden */
  72440. _updatePosition(): void;
  72441. /**
  72442. * Destroy the camera and release the current resources hold by it.
  72443. */
  72444. dispose(): void;
  72445. /**
  72446. * Gets the current object class name.
  72447. * @return the class name
  72448. */
  72449. getClassName(): string;
  72450. }
  72451. }
  72452. declare module BABYLON {
  72453. /**
  72454. * Represents a gamepad control stick position
  72455. */
  72456. export class StickValues {
  72457. /**
  72458. * The x component of the control stick
  72459. */
  72460. x: number;
  72461. /**
  72462. * The y component of the control stick
  72463. */
  72464. y: number;
  72465. /**
  72466. * Initializes the gamepad x and y control stick values
  72467. * @param x The x component of the gamepad control stick value
  72468. * @param y The y component of the gamepad control stick value
  72469. */
  72470. constructor(
  72471. /**
  72472. * The x component of the control stick
  72473. */
  72474. x: number,
  72475. /**
  72476. * The y component of the control stick
  72477. */
  72478. y: number);
  72479. }
  72480. /**
  72481. * An interface which manages callbacks for gamepad button changes
  72482. */
  72483. export interface GamepadButtonChanges {
  72484. /**
  72485. * Called when a gamepad has been changed
  72486. */
  72487. changed: boolean;
  72488. /**
  72489. * Called when a gamepad press event has been triggered
  72490. */
  72491. pressChanged: boolean;
  72492. /**
  72493. * Called when a touch event has been triggered
  72494. */
  72495. touchChanged: boolean;
  72496. /**
  72497. * Called when a value has changed
  72498. */
  72499. valueChanged: boolean;
  72500. }
  72501. /**
  72502. * Represents a gamepad
  72503. */
  72504. export class Gamepad {
  72505. /**
  72506. * The id of the gamepad
  72507. */
  72508. id: string;
  72509. /**
  72510. * The index of the gamepad
  72511. */
  72512. index: number;
  72513. /**
  72514. * The browser gamepad
  72515. */
  72516. browserGamepad: any;
  72517. /**
  72518. * Specifies what type of gamepad this represents
  72519. */
  72520. type: number;
  72521. private _leftStick;
  72522. private _rightStick;
  72523. /** @hidden */
  72524. _isConnected: boolean;
  72525. private _leftStickAxisX;
  72526. private _leftStickAxisY;
  72527. private _rightStickAxisX;
  72528. private _rightStickAxisY;
  72529. /**
  72530. * Triggered when the left control stick has been changed
  72531. */
  72532. private _onleftstickchanged;
  72533. /**
  72534. * Triggered when the right control stick has been changed
  72535. */
  72536. private _onrightstickchanged;
  72537. /**
  72538. * Represents a gamepad controller
  72539. */
  72540. static GAMEPAD: number;
  72541. /**
  72542. * Represents a generic controller
  72543. */
  72544. static GENERIC: number;
  72545. /**
  72546. * Represents an XBox controller
  72547. */
  72548. static XBOX: number;
  72549. /**
  72550. * Represents a pose-enabled controller
  72551. */
  72552. static POSE_ENABLED: number;
  72553. /**
  72554. * Specifies whether the left control stick should be Y-inverted
  72555. */
  72556. protected _invertLeftStickY: boolean;
  72557. /**
  72558. * Specifies if the gamepad has been connected
  72559. */
  72560. readonly isConnected: boolean;
  72561. /**
  72562. * Initializes the gamepad
  72563. * @param id The id of the gamepad
  72564. * @param index The index of the gamepad
  72565. * @param browserGamepad The browser gamepad
  72566. * @param leftStickX The x component of the left joystick
  72567. * @param leftStickY The y component of the left joystick
  72568. * @param rightStickX The x component of the right joystick
  72569. * @param rightStickY The y component of the right joystick
  72570. */
  72571. constructor(
  72572. /**
  72573. * The id of the gamepad
  72574. */
  72575. id: string,
  72576. /**
  72577. * The index of the gamepad
  72578. */
  72579. index: number,
  72580. /**
  72581. * The browser gamepad
  72582. */
  72583. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72584. /**
  72585. * Callback triggered when the left joystick has changed
  72586. * @param callback
  72587. */
  72588. onleftstickchanged(callback: (values: StickValues) => void): void;
  72589. /**
  72590. * Callback triggered when the right joystick has changed
  72591. * @param callback
  72592. */
  72593. onrightstickchanged(callback: (values: StickValues) => void): void;
  72594. /**
  72595. * Gets the left joystick
  72596. */
  72597. /**
  72598. * Sets the left joystick values
  72599. */
  72600. leftStick: StickValues;
  72601. /**
  72602. * Gets the right joystick
  72603. */
  72604. /**
  72605. * Sets the right joystick value
  72606. */
  72607. rightStick: StickValues;
  72608. /**
  72609. * Updates the gamepad joystick positions
  72610. */
  72611. update(): void;
  72612. /**
  72613. * Disposes the gamepad
  72614. */
  72615. dispose(): void;
  72616. }
  72617. /**
  72618. * Represents a generic gamepad
  72619. */
  72620. export class GenericPad extends Gamepad {
  72621. private _buttons;
  72622. private _onbuttondown;
  72623. private _onbuttonup;
  72624. /**
  72625. * Observable triggered when a button has been pressed
  72626. */
  72627. onButtonDownObservable: Observable<number>;
  72628. /**
  72629. * Observable triggered when a button has been released
  72630. */
  72631. onButtonUpObservable: Observable<number>;
  72632. /**
  72633. * Callback triggered when a button has been pressed
  72634. * @param callback Called when a button has been pressed
  72635. */
  72636. onbuttondown(callback: (buttonPressed: number) => void): void;
  72637. /**
  72638. * Callback triggered when a button has been released
  72639. * @param callback Called when a button has been released
  72640. */
  72641. onbuttonup(callback: (buttonReleased: number) => void): void;
  72642. /**
  72643. * Initializes the generic gamepad
  72644. * @param id The id of the generic gamepad
  72645. * @param index The index of the generic gamepad
  72646. * @param browserGamepad The browser gamepad
  72647. */
  72648. constructor(id: string, index: number, browserGamepad: any);
  72649. private _setButtonValue;
  72650. /**
  72651. * Updates the generic gamepad
  72652. */
  72653. update(): void;
  72654. /**
  72655. * Disposes the generic gamepad
  72656. */
  72657. dispose(): void;
  72658. }
  72659. }
  72660. declare module BABYLON {
  72661. /**
  72662. * Defines the types of pose enabled controllers that are supported
  72663. */
  72664. export enum PoseEnabledControllerType {
  72665. /**
  72666. * HTC Vive
  72667. */
  72668. VIVE = 0,
  72669. /**
  72670. * Oculus Rift
  72671. */
  72672. OCULUS = 1,
  72673. /**
  72674. * Windows mixed reality
  72675. */
  72676. WINDOWS = 2,
  72677. /**
  72678. * Samsung gear VR
  72679. */
  72680. GEAR_VR = 3,
  72681. /**
  72682. * Google Daydream
  72683. */
  72684. DAYDREAM = 4,
  72685. /**
  72686. * Generic
  72687. */
  72688. GENERIC = 5
  72689. }
  72690. /**
  72691. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72692. */
  72693. export interface MutableGamepadButton {
  72694. /**
  72695. * Value of the button/trigger
  72696. */
  72697. value: number;
  72698. /**
  72699. * If the button/trigger is currently touched
  72700. */
  72701. touched: boolean;
  72702. /**
  72703. * If the button/trigger is currently pressed
  72704. */
  72705. pressed: boolean;
  72706. }
  72707. /**
  72708. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72709. * @hidden
  72710. */
  72711. export interface ExtendedGamepadButton extends GamepadButton {
  72712. /**
  72713. * If the button/trigger is currently pressed
  72714. */
  72715. readonly pressed: boolean;
  72716. /**
  72717. * If the button/trigger is currently touched
  72718. */
  72719. readonly touched: boolean;
  72720. /**
  72721. * Value of the button/trigger
  72722. */
  72723. readonly value: number;
  72724. }
  72725. /** @hidden */
  72726. export interface _GamePadFactory {
  72727. /**
  72728. * Returns wether or not the current gamepad can be created for this type of controller.
  72729. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72730. * @returns true if it can be created, otherwise false
  72731. */
  72732. canCreate(gamepadInfo: any): boolean;
  72733. /**
  72734. * Creates a new instance of the Gamepad.
  72735. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72736. * @returns the new gamepad instance
  72737. */
  72738. create(gamepadInfo: any): Gamepad;
  72739. }
  72740. /**
  72741. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72742. */
  72743. export class PoseEnabledControllerHelper {
  72744. /** @hidden */
  72745. static _ControllerFactories: _GamePadFactory[];
  72746. /** @hidden */
  72747. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72748. /**
  72749. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72750. * @param vrGamepad the gamepad to initialized
  72751. * @returns a vr controller of the type the gamepad identified as
  72752. */
  72753. static InitiateController(vrGamepad: any): Gamepad;
  72754. }
  72755. /**
  72756. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72757. */
  72758. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72759. private _deviceRoomPosition;
  72760. private _deviceRoomRotationQuaternion;
  72761. /**
  72762. * The device position in babylon space
  72763. */
  72764. devicePosition: Vector3;
  72765. /**
  72766. * The device rotation in babylon space
  72767. */
  72768. deviceRotationQuaternion: Quaternion;
  72769. /**
  72770. * The scale factor of the device in babylon space
  72771. */
  72772. deviceScaleFactor: number;
  72773. /**
  72774. * (Likely devicePosition should be used instead) The device position in its room space
  72775. */
  72776. position: Vector3;
  72777. /**
  72778. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72779. */
  72780. rotationQuaternion: Quaternion;
  72781. /**
  72782. * The type of controller (Eg. Windows mixed reality)
  72783. */
  72784. controllerType: PoseEnabledControllerType;
  72785. protected _calculatedPosition: Vector3;
  72786. private _calculatedRotation;
  72787. /**
  72788. * The raw pose from the device
  72789. */
  72790. rawPose: DevicePose;
  72791. private _trackPosition;
  72792. private _maxRotationDistFromHeadset;
  72793. private _draggedRoomRotation;
  72794. /**
  72795. * @hidden
  72796. */
  72797. _disableTrackPosition(fixedPosition: Vector3): void;
  72798. /**
  72799. * Internal, the mesh attached to the controller
  72800. * @hidden
  72801. */
  72802. _mesh: Nullable<AbstractMesh>;
  72803. private _poseControlledCamera;
  72804. private _leftHandSystemQuaternion;
  72805. /**
  72806. * Internal, matrix used to convert room space to babylon space
  72807. * @hidden
  72808. */
  72809. _deviceToWorld: Matrix;
  72810. /**
  72811. * Node to be used when casting a ray from the controller
  72812. * @hidden
  72813. */
  72814. _pointingPoseNode: Nullable<TransformNode>;
  72815. /**
  72816. * Name of the child mesh that can be used to cast a ray from the controller
  72817. */
  72818. static readonly POINTING_POSE: string;
  72819. /**
  72820. * Creates a new PoseEnabledController from a gamepad
  72821. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72822. */
  72823. constructor(browserGamepad: any);
  72824. private _workingMatrix;
  72825. /**
  72826. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72827. */
  72828. update(): void;
  72829. /**
  72830. * Updates only the pose device and mesh without doing any button event checking
  72831. */
  72832. protected _updatePoseAndMesh(): void;
  72833. /**
  72834. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72835. * @param poseData raw pose fromthe device
  72836. */
  72837. updateFromDevice(poseData: DevicePose): void;
  72838. /**
  72839. * @hidden
  72840. */
  72841. _meshAttachedObservable: Observable<AbstractMesh>;
  72842. /**
  72843. * Attaches a mesh to the controller
  72844. * @param mesh the mesh to be attached
  72845. */
  72846. attachToMesh(mesh: AbstractMesh): void;
  72847. /**
  72848. * Attaches the controllers mesh to a camera
  72849. * @param camera the camera the mesh should be attached to
  72850. */
  72851. attachToPoseControlledCamera(camera: TargetCamera): void;
  72852. /**
  72853. * Disposes of the controller
  72854. */
  72855. dispose(): void;
  72856. /**
  72857. * The mesh that is attached to the controller
  72858. */
  72859. readonly mesh: Nullable<AbstractMesh>;
  72860. /**
  72861. * Gets the ray of the controller in the direction the controller is pointing
  72862. * @param length the length the resulting ray should be
  72863. * @returns a ray in the direction the controller is pointing
  72864. */
  72865. getForwardRay(length?: number): Ray;
  72866. }
  72867. }
  72868. declare module BABYLON {
  72869. /**
  72870. * Defines the WebVRController object that represents controllers tracked in 3D space
  72871. */
  72872. export abstract class WebVRController extends PoseEnabledController {
  72873. /**
  72874. * Internal, the default controller model for the controller
  72875. */
  72876. protected _defaultModel: AbstractMesh;
  72877. /**
  72878. * Fired when the trigger state has changed
  72879. */
  72880. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72881. /**
  72882. * Fired when the main button state has changed
  72883. */
  72884. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72885. /**
  72886. * Fired when the secondary button state has changed
  72887. */
  72888. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72889. /**
  72890. * Fired when the pad state has changed
  72891. */
  72892. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72893. /**
  72894. * Fired when controllers stick values have changed
  72895. */
  72896. onPadValuesChangedObservable: Observable<StickValues>;
  72897. /**
  72898. * Array of button availible on the controller
  72899. */
  72900. protected _buttons: Array<MutableGamepadButton>;
  72901. private _onButtonStateChange;
  72902. /**
  72903. * Fired when a controller button's state has changed
  72904. * @param callback the callback containing the button that was modified
  72905. */
  72906. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72907. /**
  72908. * X and Y axis corrisponding to the controllers joystick
  72909. */
  72910. pad: StickValues;
  72911. /**
  72912. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72913. */
  72914. hand: string;
  72915. /**
  72916. * The default controller model for the controller
  72917. */
  72918. readonly defaultModel: AbstractMesh;
  72919. /**
  72920. * Creates a new WebVRController from a gamepad
  72921. * @param vrGamepad the gamepad that the WebVRController should be created from
  72922. */
  72923. constructor(vrGamepad: any);
  72924. /**
  72925. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72926. */
  72927. update(): void;
  72928. /**
  72929. * Function to be called when a button is modified
  72930. */
  72931. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72932. /**
  72933. * Loads a mesh and attaches it to the controller
  72934. * @param scene the scene the mesh should be added to
  72935. * @param meshLoaded callback for when the mesh has been loaded
  72936. */
  72937. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72938. private _setButtonValue;
  72939. private _changes;
  72940. private _checkChanges;
  72941. /**
  72942. * Disposes of th webVRCOntroller
  72943. */
  72944. dispose(): void;
  72945. }
  72946. }
  72947. declare module BABYLON {
  72948. /**
  72949. * The HemisphericLight simulates the ambient environment light,
  72950. * so the passed direction is the light reflection direction, not the incoming direction.
  72951. */
  72952. export class HemisphericLight extends Light {
  72953. /**
  72954. * The groundColor is the light in the opposite direction to the one specified during creation.
  72955. * 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.
  72956. */
  72957. groundColor: Color3;
  72958. /**
  72959. * The light reflection direction, not the incoming direction.
  72960. */
  72961. direction: Vector3;
  72962. /**
  72963. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72964. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72965. * The HemisphericLight can't cast shadows.
  72966. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72967. * @param name The friendly name of the light
  72968. * @param direction The direction of the light reflection
  72969. * @param scene The scene the light belongs to
  72970. */
  72971. constructor(name: string, direction: Vector3, scene: Scene);
  72972. protected _buildUniformLayout(): void;
  72973. /**
  72974. * Returns the string "HemisphericLight".
  72975. * @return The class name
  72976. */
  72977. getClassName(): string;
  72978. /**
  72979. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72980. * Returns the updated direction.
  72981. * @param target The target the direction should point to
  72982. * @return The computed direction
  72983. */
  72984. setDirectionToTarget(target: Vector3): Vector3;
  72985. /**
  72986. * Returns the shadow generator associated to the light.
  72987. * @returns Always null for hemispheric lights because it does not support shadows.
  72988. */
  72989. getShadowGenerator(): Nullable<IShadowGenerator>;
  72990. /**
  72991. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72992. * @param effect The effect to update
  72993. * @param lightIndex The index of the light in the effect to update
  72994. * @returns The hemispheric light
  72995. */
  72996. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72997. /**
  72998. * Computes the world matrix of the node
  72999. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73000. * @param useWasUpdatedFlag defines a reserved property
  73001. * @returns the world matrix
  73002. */
  73003. computeWorldMatrix(): Matrix;
  73004. /**
  73005. * Returns the integer 3.
  73006. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73007. */
  73008. getTypeID(): number;
  73009. /**
  73010. * Prepares the list of defines specific to the light type.
  73011. * @param defines the list of defines
  73012. * @param lightIndex defines the index of the light for the effect
  73013. */
  73014. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73015. }
  73016. }
  73017. declare module BABYLON {
  73018. /** @hidden */
  73019. export var vrMultiviewToSingleviewPixelShader: {
  73020. name: string;
  73021. shader: string;
  73022. };
  73023. }
  73024. declare module BABYLON {
  73025. /**
  73026. * Renders to multiple views with a single draw call
  73027. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  73028. */
  73029. export class MultiviewRenderTarget extends RenderTargetTexture {
  73030. /**
  73031. * Creates a multiview render target
  73032. * @param scene scene used with the render target
  73033. * @param size the size of the render target (used for each view)
  73034. */
  73035. constructor(scene: Scene, size?: number | {
  73036. width: number;
  73037. height: number;
  73038. } | {
  73039. ratio: number;
  73040. });
  73041. /**
  73042. * @hidden
  73043. * @param faceIndex the face index, if its a cube texture
  73044. */
  73045. _bindFrameBuffer(faceIndex?: number): void;
  73046. /**
  73047. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  73048. * @returns the view count
  73049. */
  73050. getViewCount(): number;
  73051. }
  73052. }
  73053. declare module BABYLON {
  73054. interface Engine {
  73055. /**
  73056. * Creates a new multiview render target
  73057. * @param width defines the width of the texture
  73058. * @param height defines the height of the texture
  73059. * @returns the created multiview texture
  73060. */
  73061. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  73062. /**
  73063. * Binds a multiview framebuffer to be drawn to
  73064. * @param multiviewTexture texture to bind
  73065. */
  73066. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  73067. }
  73068. interface Camera {
  73069. /**
  73070. * @hidden
  73071. * 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)
  73072. */
  73073. _useMultiviewToSingleView: boolean;
  73074. /**
  73075. * @hidden
  73076. * 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)
  73077. */
  73078. _multiviewTexture: Nullable<RenderTargetTexture>;
  73079. /**
  73080. * @hidden
  73081. * ensures the multiview texture of the camera exists and has the specified width/height
  73082. * @param width height to set on the multiview texture
  73083. * @param height width to set on the multiview texture
  73084. */
  73085. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  73086. }
  73087. interface Scene {
  73088. /** @hidden */
  73089. _transformMatrixR: Matrix;
  73090. /** @hidden */
  73091. _multiviewSceneUbo: Nullable<UniformBuffer>;
  73092. /** @hidden */
  73093. _createMultiviewUbo(): void;
  73094. /** @hidden */
  73095. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  73096. /** @hidden */
  73097. _renderMultiviewToSingleView(camera: Camera): void;
  73098. }
  73099. }
  73100. declare module BABYLON {
  73101. /**
  73102. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  73103. * This will not be used for webXR as it supports displaying texture arrays directly
  73104. */
  73105. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  73106. /**
  73107. * Initializes a VRMultiviewToSingleview
  73108. * @param name name of the post process
  73109. * @param camera camera to be applied to
  73110. * @param scaleFactor scaling factor to the size of the output texture
  73111. */
  73112. constructor(name: string, camera: Camera, scaleFactor: number);
  73113. }
  73114. }
  73115. declare module BABYLON {
  73116. /**
  73117. * Defines the interface used by display changed events
  73118. */
  73119. interface IDisplayChangedEventArgs {
  73120. /** Gets the vrDisplay object (if any) */
  73121. vrDisplay: Nullable<any>;
  73122. /** Gets a boolean indicating if webVR is supported */
  73123. vrSupported: boolean;
  73124. }
  73125. interface Engine {
  73126. /** @hidden */
  73127. _vrDisplay: any;
  73128. /** @hidden */
  73129. _vrSupported: boolean;
  73130. /** @hidden */
  73131. _oldSize: Size;
  73132. /** @hidden */
  73133. _oldHardwareScaleFactor: number;
  73134. /** @hidden */
  73135. _vrExclusivePointerMode: boolean;
  73136. /** @hidden */
  73137. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  73138. /** @hidden */
  73139. _onVRDisplayPointerRestricted: () => void;
  73140. /** @hidden */
  73141. _onVRDisplayPointerUnrestricted: () => void;
  73142. /** @hidden */
  73143. _onVrDisplayConnect: Nullable<(display: any) => void>;
  73144. /** @hidden */
  73145. _onVrDisplayDisconnect: Nullable<() => void>;
  73146. /** @hidden */
  73147. _onVrDisplayPresentChange: Nullable<() => void>;
  73148. /**
  73149. * Observable signaled when VR display mode changes
  73150. */
  73151. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  73152. /**
  73153. * Observable signaled when VR request present is complete
  73154. */
  73155. onVRRequestPresentComplete: Observable<boolean>;
  73156. /**
  73157. * Observable signaled when VR request present starts
  73158. */
  73159. onVRRequestPresentStart: Observable<Engine>;
  73160. /**
  73161. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  73162. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  73163. */
  73164. isInVRExclusivePointerMode: boolean;
  73165. /**
  73166. * Gets a boolean indicating if a webVR device was detected
  73167. * @returns true if a webVR device was detected
  73168. */
  73169. isVRDevicePresent(): boolean;
  73170. /**
  73171. * Gets the current webVR device
  73172. * @returns the current webVR device (or null)
  73173. */
  73174. getVRDevice(): any;
  73175. /**
  73176. * Initializes a webVR display and starts listening to display change events
  73177. * The onVRDisplayChangedObservable will be notified upon these changes
  73178. * @returns A promise containing a VRDisplay and if vr is supported
  73179. */
  73180. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  73181. /** @hidden */
  73182. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  73183. /**
  73184. * Call this function to switch to webVR mode
  73185. * Will do nothing if webVR is not supported or if there is no webVR device
  73186. * @see http://doc.babylonjs.com/how_to/webvr_camera
  73187. */
  73188. enableVR(): void;
  73189. /** @hidden */
  73190. _onVRFullScreenTriggered(): void;
  73191. }
  73192. }
  73193. declare module BABYLON {
  73194. /**
  73195. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  73196. * IMPORTANT!! The data is right-hand data.
  73197. * @export
  73198. * @interface DevicePose
  73199. */
  73200. export interface DevicePose {
  73201. /**
  73202. * The position of the device, values in array are [x,y,z].
  73203. */
  73204. readonly position: Nullable<Float32Array>;
  73205. /**
  73206. * The linearVelocity of the device, values in array are [x,y,z].
  73207. */
  73208. readonly linearVelocity: Nullable<Float32Array>;
  73209. /**
  73210. * The linearAcceleration of the device, values in array are [x,y,z].
  73211. */
  73212. readonly linearAcceleration: Nullable<Float32Array>;
  73213. /**
  73214. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  73215. */
  73216. readonly orientation: Nullable<Float32Array>;
  73217. /**
  73218. * The angularVelocity of the device, values in array are [x,y,z].
  73219. */
  73220. readonly angularVelocity: Nullable<Float32Array>;
  73221. /**
  73222. * The angularAcceleration of the device, values in array are [x,y,z].
  73223. */
  73224. readonly angularAcceleration: Nullable<Float32Array>;
  73225. }
  73226. /**
  73227. * Interface representing a pose controlled object in Babylon.
  73228. * A pose controlled object has both regular pose values as well as pose values
  73229. * from an external device such as a VR head mounted display
  73230. */
  73231. export interface PoseControlled {
  73232. /**
  73233. * The position of the object in babylon space.
  73234. */
  73235. position: Vector3;
  73236. /**
  73237. * The rotation quaternion of the object in babylon space.
  73238. */
  73239. rotationQuaternion: Quaternion;
  73240. /**
  73241. * The position of the device in babylon space.
  73242. */
  73243. devicePosition?: Vector3;
  73244. /**
  73245. * The rotation quaternion of the device in babylon space.
  73246. */
  73247. deviceRotationQuaternion: Quaternion;
  73248. /**
  73249. * The raw pose coming from the device.
  73250. */
  73251. rawPose: Nullable<DevicePose>;
  73252. /**
  73253. * The scale of the device to be used when translating from device space to babylon space.
  73254. */
  73255. deviceScaleFactor: number;
  73256. /**
  73257. * Updates the poseControlled values based on the input device pose.
  73258. * @param poseData the pose data to update the object with
  73259. */
  73260. updateFromDevice(poseData: DevicePose): void;
  73261. }
  73262. /**
  73263. * Set of options to customize the webVRCamera
  73264. */
  73265. export interface WebVROptions {
  73266. /**
  73267. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  73268. */
  73269. trackPosition?: boolean;
  73270. /**
  73271. * Sets the scale of the vrDevice in babylon space. (default: 1)
  73272. */
  73273. positionScale?: number;
  73274. /**
  73275. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  73276. */
  73277. displayName?: string;
  73278. /**
  73279. * Should the native controller meshes be initialized. (default: true)
  73280. */
  73281. controllerMeshes?: boolean;
  73282. /**
  73283. * Creating a default HemiLight only on controllers. (default: true)
  73284. */
  73285. defaultLightingOnControllers?: boolean;
  73286. /**
  73287. * If you don't want to use the default VR button of the helper. (default: false)
  73288. */
  73289. useCustomVRButton?: boolean;
  73290. /**
  73291. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  73292. */
  73293. customVRButton?: HTMLButtonElement;
  73294. /**
  73295. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  73296. */
  73297. rayLength?: number;
  73298. /**
  73299. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  73300. */
  73301. defaultHeight?: number;
  73302. /**
  73303. * If multiview should be used if availible (default: false)
  73304. */
  73305. useMultiview?: boolean;
  73306. }
  73307. /**
  73308. * This represents a WebVR camera.
  73309. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73310. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73311. */
  73312. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73313. private webVROptions;
  73314. /**
  73315. * @hidden
  73316. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73317. */
  73318. _vrDevice: any;
  73319. /**
  73320. * The rawPose of the vrDevice.
  73321. */
  73322. rawPose: Nullable<DevicePose>;
  73323. private _onVREnabled;
  73324. private _specsVersion;
  73325. private _attached;
  73326. private _frameData;
  73327. protected _descendants: Array<Node>;
  73328. private _deviceRoomPosition;
  73329. /** @hidden */
  73330. _deviceRoomRotationQuaternion: Quaternion;
  73331. private _standingMatrix;
  73332. /**
  73333. * Represents device position in babylon space.
  73334. */
  73335. devicePosition: Vector3;
  73336. /**
  73337. * Represents device rotation in babylon space.
  73338. */
  73339. deviceRotationQuaternion: Quaternion;
  73340. /**
  73341. * The scale of the device to be used when translating from device space to babylon space.
  73342. */
  73343. deviceScaleFactor: number;
  73344. private _deviceToWorld;
  73345. private _worldToDevice;
  73346. /**
  73347. * References to the webVR controllers for the vrDevice.
  73348. */
  73349. controllers: Array<WebVRController>;
  73350. /**
  73351. * Emits an event when a controller is attached.
  73352. */
  73353. onControllersAttachedObservable: Observable<WebVRController[]>;
  73354. /**
  73355. * Emits an event when a controller's mesh has been loaded;
  73356. */
  73357. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73358. /**
  73359. * Emits an event when the HMD's pose has been updated.
  73360. */
  73361. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73362. private _poseSet;
  73363. /**
  73364. * If the rig cameras be used as parent instead of this camera.
  73365. */
  73366. rigParenting: boolean;
  73367. private _lightOnControllers;
  73368. private _defaultHeight?;
  73369. /**
  73370. * Instantiates a WebVRFreeCamera.
  73371. * @param name The name of the WebVRFreeCamera
  73372. * @param position The starting anchor position for the camera
  73373. * @param scene The scene the camera belongs to
  73374. * @param webVROptions a set of customizable options for the webVRCamera
  73375. */
  73376. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73377. /**
  73378. * Gets the device distance from the ground in meters.
  73379. * @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.
  73380. */
  73381. deviceDistanceToRoomGround(): number;
  73382. /**
  73383. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73384. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73385. */
  73386. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73387. /**
  73388. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73389. * @returns A promise with a boolean set to if the standing matrix is supported.
  73390. */
  73391. useStandingMatrixAsync(): Promise<boolean>;
  73392. /**
  73393. * Disposes the camera
  73394. */
  73395. dispose(): void;
  73396. /**
  73397. * Gets a vrController by name.
  73398. * @param name The name of the controller to retreive
  73399. * @returns the controller matching the name specified or null if not found
  73400. */
  73401. getControllerByName(name: string): Nullable<WebVRController>;
  73402. private _leftController;
  73403. /**
  73404. * The controller corrisponding to the users left hand.
  73405. */
  73406. readonly leftController: Nullable<WebVRController>;
  73407. private _rightController;
  73408. /**
  73409. * The controller corrisponding to the users right hand.
  73410. */
  73411. readonly rightController: Nullable<WebVRController>;
  73412. /**
  73413. * Casts a ray forward from the vrCamera's gaze.
  73414. * @param length Length of the ray (default: 100)
  73415. * @returns the ray corrisponding to the gaze
  73416. */
  73417. getForwardRay(length?: number): Ray;
  73418. /**
  73419. * @hidden
  73420. * Updates the camera based on device's frame data
  73421. */
  73422. _checkInputs(): void;
  73423. /**
  73424. * Updates the poseControlled values based on the input device pose.
  73425. * @param poseData Pose coming from the device
  73426. */
  73427. updateFromDevice(poseData: DevicePose): void;
  73428. private _htmlElementAttached;
  73429. private _detachIfAttached;
  73430. /**
  73431. * WebVR's attach control will start broadcasting frames to the device.
  73432. * Note that in certain browsers (chrome for example) this function must be called
  73433. * within a user-interaction callback. Example:
  73434. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73435. *
  73436. * @param element html element to attach the vrDevice to
  73437. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73438. */
  73439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73440. /**
  73441. * Detaches the camera from the html element and disables VR
  73442. *
  73443. * @param element html element to detach from
  73444. */
  73445. detachControl(element: HTMLElement): void;
  73446. /**
  73447. * @returns the name of this class
  73448. */
  73449. getClassName(): string;
  73450. /**
  73451. * Calls resetPose on the vrDisplay
  73452. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73453. */
  73454. resetToCurrentRotation(): void;
  73455. /**
  73456. * @hidden
  73457. * Updates the rig cameras (left and right eye)
  73458. */
  73459. _updateRigCameras(): void;
  73460. private _workingVector;
  73461. private _oneVector;
  73462. private _workingMatrix;
  73463. private updateCacheCalled;
  73464. private _correctPositionIfNotTrackPosition;
  73465. /**
  73466. * @hidden
  73467. * Updates the cached values of the camera
  73468. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73469. */
  73470. _updateCache(ignoreParentClass?: boolean): void;
  73471. /**
  73472. * @hidden
  73473. * Get current device position in babylon world
  73474. */
  73475. _computeDevicePosition(): void;
  73476. /**
  73477. * Updates the current device position and rotation in the babylon world
  73478. */
  73479. update(): void;
  73480. /**
  73481. * @hidden
  73482. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73483. * @returns an identity matrix
  73484. */
  73485. _getViewMatrix(): Matrix;
  73486. private _tmpMatrix;
  73487. /**
  73488. * This function is called by the two RIG cameras.
  73489. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73490. * @hidden
  73491. */
  73492. _getWebVRViewMatrix(): Matrix;
  73493. /** @hidden */
  73494. _getWebVRProjectionMatrix(): Matrix;
  73495. private _onGamepadConnectedObserver;
  73496. private _onGamepadDisconnectedObserver;
  73497. private _updateCacheWhenTrackingDisabledObserver;
  73498. /**
  73499. * Initializes the controllers and their meshes
  73500. */
  73501. initControllers(): void;
  73502. }
  73503. }
  73504. declare module BABYLON {
  73505. /**
  73506. * Size options for a post process
  73507. */
  73508. export type PostProcessOptions = {
  73509. width: number;
  73510. height: number;
  73511. };
  73512. /**
  73513. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73514. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73515. */
  73516. export class PostProcess {
  73517. /** Name of the PostProcess. */
  73518. name: string;
  73519. /**
  73520. * Gets or sets the unique id of the post process
  73521. */
  73522. uniqueId: number;
  73523. /**
  73524. * Width of the texture to apply the post process on
  73525. */
  73526. width: number;
  73527. /**
  73528. * Height of the texture to apply the post process on
  73529. */
  73530. height: number;
  73531. /**
  73532. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73533. * @hidden
  73534. */
  73535. _outputTexture: Nullable<InternalTexture>;
  73536. /**
  73537. * Sampling mode used by the shader
  73538. * See https://doc.babylonjs.com/classes/3.1/texture
  73539. */
  73540. renderTargetSamplingMode: number;
  73541. /**
  73542. * Clear color to use when screen clearing
  73543. */
  73544. clearColor: Color4;
  73545. /**
  73546. * If the buffer needs to be cleared before applying the post process. (default: true)
  73547. * Should be set to false if shader will overwrite all previous pixels.
  73548. */
  73549. autoClear: boolean;
  73550. /**
  73551. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73552. */
  73553. alphaMode: number;
  73554. /**
  73555. * Sets the setAlphaBlendConstants of the babylon engine
  73556. */
  73557. alphaConstants: Color4;
  73558. /**
  73559. * Animations to be used for the post processing
  73560. */
  73561. animations: Animation[];
  73562. /**
  73563. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73564. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73565. */
  73566. enablePixelPerfectMode: boolean;
  73567. /**
  73568. * Force the postprocess to be applied without taking in account viewport
  73569. */
  73570. forceFullscreenViewport: boolean;
  73571. /**
  73572. * List of inspectable custom properties (used by the Inspector)
  73573. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73574. */
  73575. inspectableCustomProperties: IInspectable[];
  73576. /**
  73577. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73578. *
  73579. * | Value | Type | Description |
  73580. * | ----- | ----------------------------------- | ----------- |
  73581. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73582. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73583. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73584. *
  73585. */
  73586. scaleMode: number;
  73587. /**
  73588. * Force textures to be a power of two (default: false)
  73589. */
  73590. alwaysForcePOT: boolean;
  73591. private _samples;
  73592. /**
  73593. * Number of sample textures (default: 1)
  73594. */
  73595. samples: number;
  73596. /**
  73597. * Modify the scale of the post process to be the same as the viewport (default: false)
  73598. */
  73599. adaptScaleToCurrentViewport: boolean;
  73600. private _camera;
  73601. private _scene;
  73602. private _engine;
  73603. private _options;
  73604. private _reusable;
  73605. private _textureType;
  73606. /**
  73607. * Smart array of input and output textures for the post process.
  73608. * @hidden
  73609. */
  73610. _textures: SmartArray<InternalTexture>;
  73611. /**
  73612. * The index in _textures that corresponds to the output texture.
  73613. * @hidden
  73614. */
  73615. _currentRenderTextureInd: number;
  73616. private _effect;
  73617. private _samplers;
  73618. private _fragmentUrl;
  73619. private _vertexUrl;
  73620. private _parameters;
  73621. private _scaleRatio;
  73622. protected _indexParameters: any;
  73623. private _shareOutputWithPostProcess;
  73624. private _texelSize;
  73625. private _forcedOutputTexture;
  73626. /**
  73627. * Returns the fragment url or shader name used in the post process.
  73628. * @returns the fragment url or name in the shader store.
  73629. */
  73630. getEffectName(): string;
  73631. /**
  73632. * An event triggered when the postprocess is activated.
  73633. */
  73634. onActivateObservable: Observable<Camera>;
  73635. private _onActivateObserver;
  73636. /**
  73637. * A function that is added to the onActivateObservable
  73638. */
  73639. onActivate: Nullable<(camera: Camera) => void>;
  73640. /**
  73641. * An event triggered when the postprocess changes its size.
  73642. */
  73643. onSizeChangedObservable: Observable<PostProcess>;
  73644. private _onSizeChangedObserver;
  73645. /**
  73646. * A function that is added to the onSizeChangedObservable
  73647. */
  73648. onSizeChanged: (postProcess: PostProcess) => void;
  73649. /**
  73650. * An event triggered when the postprocess applies its effect.
  73651. */
  73652. onApplyObservable: Observable<Effect>;
  73653. private _onApplyObserver;
  73654. /**
  73655. * A function that is added to the onApplyObservable
  73656. */
  73657. onApply: (effect: Effect) => void;
  73658. /**
  73659. * An event triggered before rendering the postprocess
  73660. */
  73661. onBeforeRenderObservable: Observable<Effect>;
  73662. private _onBeforeRenderObserver;
  73663. /**
  73664. * A function that is added to the onBeforeRenderObservable
  73665. */
  73666. onBeforeRender: (effect: Effect) => void;
  73667. /**
  73668. * An event triggered after rendering the postprocess
  73669. */
  73670. onAfterRenderObservable: Observable<Effect>;
  73671. private _onAfterRenderObserver;
  73672. /**
  73673. * A function that is added to the onAfterRenderObservable
  73674. */
  73675. onAfterRender: (efect: Effect) => void;
  73676. /**
  73677. * 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
  73678. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73679. */
  73680. inputTexture: InternalTexture;
  73681. /**
  73682. * Gets the camera which post process is applied to.
  73683. * @returns The camera the post process is applied to.
  73684. */
  73685. getCamera(): Camera;
  73686. /**
  73687. * Gets the texel size of the postprocess.
  73688. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73689. */
  73690. readonly texelSize: Vector2;
  73691. /**
  73692. * Creates a new instance PostProcess
  73693. * @param name The name of the PostProcess.
  73694. * @param fragmentUrl The url of the fragment shader to be used.
  73695. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73696. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73697. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73698. * @param camera The camera to apply the render pass to.
  73699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73700. * @param engine The engine which the post process will be applied. (default: current engine)
  73701. * @param reusable If the post process can be reused on the same frame. (default: false)
  73702. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73703. * @param textureType Type of textures used when performing the post process. (default: 0)
  73704. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73705. * @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
  73706. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73707. */
  73708. constructor(
  73709. /** Name of the PostProcess. */
  73710. 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);
  73711. /**
  73712. * Gets a string idenfifying the name of the class
  73713. * @returns "PostProcess" string
  73714. */
  73715. getClassName(): string;
  73716. /**
  73717. * Gets the engine which this post process belongs to.
  73718. * @returns The engine the post process was enabled with.
  73719. */
  73720. getEngine(): Engine;
  73721. /**
  73722. * The effect that is created when initializing the post process.
  73723. * @returns The created effect corrisponding the the postprocess.
  73724. */
  73725. getEffect(): Effect;
  73726. /**
  73727. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73728. * @param postProcess The post process to share the output with.
  73729. * @returns This post process.
  73730. */
  73731. shareOutputWith(postProcess: PostProcess): PostProcess;
  73732. /**
  73733. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73734. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73735. */
  73736. useOwnOutput(): void;
  73737. /**
  73738. * Updates the effect with the current post process compile time values and recompiles the shader.
  73739. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73740. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73741. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73742. * @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
  73743. * @param onCompiled Called when the shader has been compiled.
  73744. * @param onError Called if there is an error when compiling a shader.
  73745. */
  73746. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73747. /**
  73748. * The post process is reusable if it can be used multiple times within one frame.
  73749. * @returns If the post process is reusable
  73750. */
  73751. isReusable(): boolean;
  73752. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73753. markTextureDirty(): void;
  73754. /**
  73755. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73756. * 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.
  73757. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73758. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73759. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73760. * @returns The target texture that was bound to be written to.
  73761. */
  73762. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73763. /**
  73764. * If the post process is supported.
  73765. */
  73766. readonly isSupported: boolean;
  73767. /**
  73768. * The aspect ratio of the output texture.
  73769. */
  73770. readonly aspectRatio: number;
  73771. /**
  73772. * Get a value indicating if the post-process is ready to be used
  73773. * @returns true if the post-process is ready (shader is compiled)
  73774. */
  73775. isReady(): boolean;
  73776. /**
  73777. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73778. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73779. */
  73780. apply(): Nullable<Effect>;
  73781. private _disposeTextures;
  73782. /**
  73783. * Disposes the post process.
  73784. * @param camera The camera to dispose the post process on.
  73785. */
  73786. dispose(camera?: Camera): void;
  73787. }
  73788. }
  73789. declare module BABYLON {
  73790. /**
  73791. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73792. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73793. */
  73794. export class PostProcessManager {
  73795. private _scene;
  73796. private _indexBuffer;
  73797. private _vertexBuffers;
  73798. /**
  73799. * Creates a new instance PostProcess
  73800. * @param scene The scene that the post process is associated with.
  73801. */
  73802. constructor(scene: Scene);
  73803. private _prepareBuffers;
  73804. private _buildIndexBuffer;
  73805. /**
  73806. * Rebuilds the vertex buffers of the manager.
  73807. * @hidden
  73808. */
  73809. _rebuild(): void;
  73810. /**
  73811. * Prepares a frame to be run through a post process.
  73812. * @param sourceTexture The input texture to the post procesess. (default: null)
  73813. * @param postProcesses An array of post processes to be run. (default: null)
  73814. * @returns True if the post processes were able to be run.
  73815. * @hidden
  73816. */
  73817. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73818. /**
  73819. * Manually render a set of post processes to a texture.
  73820. * @param postProcesses An array of post processes to be run.
  73821. * @param targetTexture The target texture to render to.
  73822. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73823. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73824. * @param lodLevel defines which lod of the texture to render to
  73825. */
  73826. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73827. /**
  73828. * Finalize the result of the output of the postprocesses.
  73829. * @param doNotPresent If true the result will not be displayed to the screen.
  73830. * @param targetTexture The target texture to render to.
  73831. * @param faceIndex The index of the face to bind the target texture to.
  73832. * @param postProcesses The array of post processes to render.
  73833. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73834. * @hidden
  73835. */
  73836. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73837. /**
  73838. * Disposes of the post process manager.
  73839. */
  73840. dispose(): void;
  73841. }
  73842. }
  73843. declare module BABYLON {
  73844. interface AbstractScene {
  73845. /**
  73846. * The list of layers (background and foreground) of the scene
  73847. */
  73848. layers: Array<Layer>;
  73849. }
  73850. /**
  73851. * Defines the layer scene component responsible to manage any layers
  73852. * in a given scene.
  73853. */
  73854. export class LayerSceneComponent implements ISceneComponent {
  73855. /**
  73856. * The component name helpfull to identify the component in the list of scene components.
  73857. */
  73858. readonly name: string;
  73859. /**
  73860. * The scene the component belongs to.
  73861. */
  73862. scene: Scene;
  73863. private _engine;
  73864. /**
  73865. * Creates a new instance of the component for the given scene
  73866. * @param scene Defines the scene to register the component in
  73867. */
  73868. constructor(scene: Scene);
  73869. /**
  73870. * Registers the component in a given scene
  73871. */
  73872. register(): void;
  73873. /**
  73874. * Rebuilds the elements related to this component in case of
  73875. * context lost for instance.
  73876. */
  73877. rebuild(): void;
  73878. /**
  73879. * Disposes the component and the associated ressources.
  73880. */
  73881. dispose(): void;
  73882. private _draw;
  73883. private _drawCameraPredicate;
  73884. private _drawCameraBackground;
  73885. private _drawCameraForeground;
  73886. private _drawRenderTargetPredicate;
  73887. private _drawRenderTargetBackground;
  73888. private _drawRenderTargetForeground;
  73889. }
  73890. }
  73891. declare module BABYLON {
  73892. /** @hidden */
  73893. export var layerPixelShader: {
  73894. name: string;
  73895. shader: string;
  73896. };
  73897. }
  73898. declare module BABYLON {
  73899. /** @hidden */
  73900. export var layerVertexShader: {
  73901. name: string;
  73902. shader: string;
  73903. };
  73904. }
  73905. declare module BABYLON {
  73906. /**
  73907. * This represents a full screen 2d layer.
  73908. * This can be useful to display a picture in the background of your scene for instance.
  73909. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73910. */
  73911. export class Layer {
  73912. /**
  73913. * Define the name of the layer.
  73914. */
  73915. name: string;
  73916. /**
  73917. * Define the texture the layer should display.
  73918. */
  73919. texture: Nullable<Texture>;
  73920. /**
  73921. * Is the layer in background or foreground.
  73922. */
  73923. isBackground: boolean;
  73924. /**
  73925. * Define the color of the layer (instead of texture).
  73926. */
  73927. color: Color4;
  73928. /**
  73929. * Define the scale of the layer in order to zoom in out of the texture.
  73930. */
  73931. scale: Vector2;
  73932. /**
  73933. * Define an offset for the layer in order to shift the texture.
  73934. */
  73935. offset: Vector2;
  73936. /**
  73937. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73938. */
  73939. alphaBlendingMode: number;
  73940. /**
  73941. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73942. * Alpha test will not mix with the background color in case of transparency.
  73943. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73944. */
  73945. alphaTest: boolean;
  73946. /**
  73947. * Define a mask to restrict the layer to only some of the scene cameras.
  73948. */
  73949. layerMask: number;
  73950. /**
  73951. * Define the list of render target the layer is visible into.
  73952. */
  73953. renderTargetTextures: RenderTargetTexture[];
  73954. /**
  73955. * Define if the layer is only used in renderTarget or if it also
  73956. * renders in the main frame buffer of the canvas.
  73957. */
  73958. renderOnlyInRenderTargetTextures: boolean;
  73959. private _scene;
  73960. private _vertexBuffers;
  73961. private _indexBuffer;
  73962. private _effect;
  73963. private _alphaTestEffect;
  73964. /**
  73965. * An event triggered when the layer is disposed.
  73966. */
  73967. onDisposeObservable: Observable<Layer>;
  73968. private _onDisposeObserver;
  73969. /**
  73970. * Back compatibility with callback before the onDisposeObservable existed.
  73971. * The set callback will be triggered when the layer has been disposed.
  73972. */
  73973. onDispose: () => void;
  73974. /**
  73975. * An event triggered before rendering the scene
  73976. */
  73977. onBeforeRenderObservable: Observable<Layer>;
  73978. private _onBeforeRenderObserver;
  73979. /**
  73980. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73981. * The set callback will be triggered just before rendering the layer.
  73982. */
  73983. onBeforeRender: () => void;
  73984. /**
  73985. * An event triggered after rendering the scene
  73986. */
  73987. onAfterRenderObservable: Observable<Layer>;
  73988. private _onAfterRenderObserver;
  73989. /**
  73990. * Back compatibility with callback before the onAfterRenderObservable existed.
  73991. * The set callback will be triggered just after rendering the layer.
  73992. */
  73993. onAfterRender: () => void;
  73994. /**
  73995. * Instantiates a new layer.
  73996. * This represents a full screen 2d layer.
  73997. * This can be useful to display a picture in the background of your scene for instance.
  73998. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73999. * @param name Define the name of the layer in the scene
  74000. * @param imgUrl Define the url of the texture to display in the layer
  74001. * @param scene Define the scene the layer belongs to
  74002. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  74003. * @param color Defines a color for the layer
  74004. */
  74005. constructor(
  74006. /**
  74007. * Define the name of the layer.
  74008. */
  74009. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  74010. private _createIndexBuffer;
  74011. /** @hidden */
  74012. _rebuild(): void;
  74013. /**
  74014. * Renders the layer in the scene.
  74015. */
  74016. render(): void;
  74017. /**
  74018. * Disposes and releases the associated ressources.
  74019. */
  74020. dispose(): void;
  74021. }
  74022. }
  74023. declare module BABYLON {
  74024. interface AbstractScene {
  74025. /**
  74026. * The list of procedural textures added to the scene
  74027. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74028. */
  74029. proceduralTextures: Array<ProceduralTexture>;
  74030. }
  74031. /**
  74032. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  74033. * in a given scene.
  74034. */
  74035. export class ProceduralTextureSceneComponent implements ISceneComponent {
  74036. /**
  74037. * The component name helpfull to identify the component in the list of scene components.
  74038. */
  74039. readonly name: string;
  74040. /**
  74041. * The scene the component belongs to.
  74042. */
  74043. scene: Scene;
  74044. /**
  74045. * Creates a new instance of the component for the given scene
  74046. * @param scene Defines the scene to register the component in
  74047. */
  74048. constructor(scene: Scene);
  74049. /**
  74050. * Registers the component in a given scene
  74051. */
  74052. register(): void;
  74053. /**
  74054. * Rebuilds the elements related to this component in case of
  74055. * context lost for instance.
  74056. */
  74057. rebuild(): void;
  74058. /**
  74059. * Disposes the component and the associated ressources.
  74060. */
  74061. dispose(): void;
  74062. private _beforeClear;
  74063. }
  74064. }
  74065. declare module BABYLON {
  74066. interface Engine {
  74067. /**
  74068. * Creates a new render target cube texture
  74069. * @param size defines the size of the texture
  74070. * @param options defines the options used to create the texture
  74071. * @returns a new render target cube texture stored in an InternalTexture
  74072. */
  74073. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  74074. }
  74075. }
  74076. declare module BABYLON {
  74077. /** @hidden */
  74078. export var proceduralVertexShader: {
  74079. name: string;
  74080. shader: string;
  74081. };
  74082. }
  74083. declare module BABYLON {
  74084. /**
  74085. * 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.
  74086. * This is the base class of any Procedural texture and contains most of the shareable code.
  74087. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74088. */
  74089. export class ProceduralTexture extends Texture {
  74090. isCube: boolean;
  74091. /**
  74092. * Define if the texture is enabled or not (disabled texture will not render)
  74093. */
  74094. isEnabled: boolean;
  74095. /**
  74096. * Define if the texture must be cleared before rendering (default is true)
  74097. */
  74098. autoClear: boolean;
  74099. /**
  74100. * Callback called when the texture is generated
  74101. */
  74102. onGenerated: () => void;
  74103. /**
  74104. * Event raised when the texture is generated
  74105. */
  74106. onGeneratedObservable: Observable<ProceduralTexture>;
  74107. /** @hidden */
  74108. _generateMipMaps: boolean;
  74109. /** @hidden **/
  74110. _effect: Effect;
  74111. /** @hidden */
  74112. _textures: {
  74113. [key: string]: Texture;
  74114. };
  74115. private _size;
  74116. private _currentRefreshId;
  74117. private _refreshRate;
  74118. private _vertexBuffers;
  74119. private _indexBuffer;
  74120. private _uniforms;
  74121. private _samplers;
  74122. private _fragment;
  74123. private _floats;
  74124. private _ints;
  74125. private _floatsArrays;
  74126. private _colors3;
  74127. private _colors4;
  74128. private _vectors2;
  74129. private _vectors3;
  74130. private _matrices;
  74131. private _fallbackTexture;
  74132. private _fallbackTextureUsed;
  74133. private _engine;
  74134. private _cachedDefines;
  74135. private _contentUpdateId;
  74136. private _contentData;
  74137. /**
  74138. * Instantiates a new procedural texture.
  74139. * 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.
  74140. * This is the base class of any Procedural texture and contains most of the shareable code.
  74141. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74142. * @param name Define the name of the texture
  74143. * @param size Define the size of the texture to create
  74144. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  74145. * @param scene Define the scene the texture belongs to
  74146. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  74147. * @param generateMipMaps Define if the texture should creates mip maps or not
  74148. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  74149. */
  74150. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  74151. /**
  74152. * The effect that is created when initializing the post process.
  74153. * @returns The created effect corrisponding the the postprocess.
  74154. */
  74155. getEffect(): Effect;
  74156. /**
  74157. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  74158. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  74159. */
  74160. getContent(): Nullable<ArrayBufferView>;
  74161. private _createIndexBuffer;
  74162. /** @hidden */
  74163. _rebuild(): void;
  74164. /**
  74165. * Resets the texture in order to recreate its associated resources.
  74166. * This can be called in case of context loss
  74167. */
  74168. reset(): void;
  74169. protected _getDefines(): string;
  74170. /**
  74171. * Is the texture ready to be used ? (rendered at least once)
  74172. * @returns true if ready, otherwise, false.
  74173. */
  74174. isReady(): boolean;
  74175. /**
  74176. * Resets the refresh counter of the texture and start bak from scratch.
  74177. * Could be useful to regenerate the texture if it is setup to render only once.
  74178. */
  74179. resetRefreshCounter(): void;
  74180. /**
  74181. * Set the fragment shader to use in order to render the texture.
  74182. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  74183. */
  74184. setFragment(fragment: any): void;
  74185. /**
  74186. * Define the refresh rate of the texture or the rendering frequency.
  74187. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74188. */
  74189. refreshRate: number;
  74190. /** @hidden */
  74191. _shouldRender(): boolean;
  74192. /**
  74193. * Get the size the texture is rendering at.
  74194. * @returns the size (texture is always squared)
  74195. */
  74196. getRenderSize(): number;
  74197. /**
  74198. * Resize the texture to new value.
  74199. * @param size Define the new size the texture should have
  74200. * @param generateMipMaps Define whether the new texture should create mip maps
  74201. */
  74202. resize(size: number, generateMipMaps: boolean): void;
  74203. private _checkUniform;
  74204. /**
  74205. * Set a texture in the shader program used to render.
  74206. * @param name Define the name of the uniform samplers as defined in the shader
  74207. * @param texture Define the texture to bind to this sampler
  74208. * @return the texture itself allowing "fluent" like uniform updates
  74209. */
  74210. setTexture(name: string, texture: Texture): ProceduralTexture;
  74211. /**
  74212. * Set a float in the shader.
  74213. * @param name Define the name of the uniform as defined in the shader
  74214. * @param value Define the value to give to the uniform
  74215. * @return the texture itself allowing "fluent" like uniform updates
  74216. */
  74217. setFloat(name: string, value: number): ProceduralTexture;
  74218. /**
  74219. * Set a int in the shader.
  74220. * @param name Define the name of the uniform as defined in the shader
  74221. * @param value Define the value to give to the uniform
  74222. * @return the texture itself allowing "fluent" like uniform updates
  74223. */
  74224. setInt(name: string, value: number): ProceduralTexture;
  74225. /**
  74226. * Set an array of floats in the shader.
  74227. * @param name Define the name of the uniform as defined in the shader
  74228. * @param value Define the value to give to the uniform
  74229. * @return the texture itself allowing "fluent" like uniform updates
  74230. */
  74231. setFloats(name: string, value: number[]): ProceduralTexture;
  74232. /**
  74233. * Set a vec3 in the shader from a Color3.
  74234. * @param name Define the name of the uniform as defined in the shader
  74235. * @param value Define the value to give to the uniform
  74236. * @return the texture itself allowing "fluent" like uniform updates
  74237. */
  74238. setColor3(name: string, value: Color3): ProceduralTexture;
  74239. /**
  74240. * Set a vec4 in the shader from a Color4.
  74241. * @param name Define the name of the uniform as defined in the shader
  74242. * @param value Define the value to give to the uniform
  74243. * @return the texture itself allowing "fluent" like uniform updates
  74244. */
  74245. setColor4(name: string, value: Color4): ProceduralTexture;
  74246. /**
  74247. * Set a vec2 in the shader from a Vector2.
  74248. * @param name Define the name of the uniform as defined in the shader
  74249. * @param value Define the value to give to the uniform
  74250. * @return the texture itself allowing "fluent" like uniform updates
  74251. */
  74252. setVector2(name: string, value: Vector2): ProceduralTexture;
  74253. /**
  74254. * Set a vec3 in the shader from a Vector3.
  74255. * @param name Define the name of the uniform as defined in the shader
  74256. * @param value Define the value to give to the uniform
  74257. * @return the texture itself allowing "fluent" like uniform updates
  74258. */
  74259. setVector3(name: string, value: Vector3): ProceduralTexture;
  74260. /**
  74261. * Set a mat4 in the shader from a MAtrix.
  74262. * @param name Define the name of the uniform as defined in the shader
  74263. * @param value Define the value to give to the uniform
  74264. * @return the texture itself allowing "fluent" like uniform updates
  74265. */
  74266. setMatrix(name: string, value: Matrix): ProceduralTexture;
  74267. /**
  74268. * Render the texture to its associated render target.
  74269. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  74270. */
  74271. render(useCameraPostProcess?: boolean): void;
  74272. /**
  74273. * Clone the texture.
  74274. * @returns the cloned texture
  74275. */
  74276. clone(): ProceduralTexture;
  74277. /**
  74278. * Dispose the texture and release its asoociated resources.
  74279. */
  74280. dispose(): void;
  74281. }
  74282. }
  74283. declare module BABYLON {
  74284. /**
  74285. * This represents the base class for particle system in Babylon.
  74286. * 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.
  74287. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74288. * @example https://doc.babylonjs.com/babylon101/particles
  74289. */
  74290. export class BaseParticleSystem {
  74291. /**
  74292. * Source color is added to the destination color without alpha affecting the result
  74293. */
  74294. static BLENDMODE_ONEONE: number;
  74295. /**
  74296. * Blend current color and particle color using particle’s alpha
  74297. */
  74298. static BLENDMODE_STANDARD: number;
  74299. /**
  74300. * Add current color and particle color multiplied by particle’s alpha
  74301. */
  74302. static BLENDMODE_ADD: number;
  74303. /**
  74304. * Multiply current color with particle color
  74305. */
  74306. static BLENDMODE_MULTIPLY: number;
  74307. /**
  74308. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74309. */
  74310. static BLENDMODE_MULTIPLYADD: number;
  74311. /**
  74312. * List of animations used by the particle system.
  74313. */
  74314. animations: Animation[];
  74315. /**
  74316. * The id of the Particle system.
  74317. */
  74318. id: string;
  74319. /**
  74320. * The friendly name of the Particle system.
  74321. */
  74322. name: string;
  74323. /**
  74324. * The rendering group used by the Particle system to chose when to render.
  74325. */
  74326. renderingGroupId: number;
  74327. /**
  74328. * The emitter represents the Mesh or position we are attaching the particle system to.
  74329. */
  74330. emitter: Nullable<AbstractMesh | Vector3>;
  74331. /**
  74332. * The maximum number of particles to emit per frame
  74333. */
  74334. emitRate: number;
  74335. /**
  74336. * If you want to launch only a few particles at once, that can be done, as well.
  74337. */
  74338. manualEmitCount: number;
  74339. /**
  74340. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74341. */
  74342. updateSpeed: number;
  74343. /**
  74344. * The amount of time the particle system is running (depends of the overall update speed).
  74345. */
  74346. targetStopDuration: number;
  74347. /**
  74348. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74349. */
  74350. disposeOnStop: boolean;
  74351. /**
  74352. * Minimum power of emitting particles.
  74353. */
  74354. minEmitPower: number;
  74355. /**
  74356. * Maximum power of emitting particles.
  74357. */
  74358. maxEmitPower: number;
  74359. /**
  74360. * Minimum life time of emitting particles.
  74361. */
  74362. minLifeTime: number;
  74363. /**
  74364. * Maximum life time of emitting particles.
  74365. */
  74366. maxLifeTime: number;
  74367. /**
  74368. * Minimum Size of emitting particles.
  74369. */
  74370. minSize: number;
  74371. /**
  74372. * Maximum Size of emitting particles.
  74373. */
  74374. maxSize: number;
  74375. /**
  74376. * Minimum scale of emitting particles on X axis.
  74377. */
  74378. minScaleX: number;
  74379. /**
  74380. * Maximum scale of emitting particles on X axis.
  74381. */
  74382. maxScaleX: number;
  74383. /**
  74384. * Minimum scale of emitting particles on Y axis.
  74385. */
  74386. minScaleY: number;
  74387. /**
  74388. * Maximum scale of emitting particles on Y axis.
  74389. */
  74390. maxScaleY: number;
  74391. /**
  74392. * Gets or sets the minimal initial rotation in radians.
  74393. */
  74394. minInitialRotation: number;
  74395. /**
  74396. * Gets or sets the maximal initial rotation in radians.
  74397. */
  74398. maxInitialRotation: number;
  74399. /**
  74400. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74401. */
  74402. minAngularSpeed: number;
  74403. /**
  74404. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74405. */
  74406. maxAngularSpeed: number;
  74407. /**
  74408. * The texture used to render each particle. (this can be a spritesheet)
  74409. */
  74410. particleTexture: Nullable<Texture>;
  74411. /**
  74412. * The layer mask we are rendering the particles through.
  74413. */
  74414. layerMask: number;
  74415. /**
  74416. * This can help using your own shader to render the particle system.
  74417. * The according effect will be created
  74418. */
  74419. customShader: any;
  74420. /**
  74421. * By default particle system starts as soon as they are created. This prevents the
  74422. * automatic start to happen and let you decide when to start emitting particles.
  74423. */
  74424. preventAutoStart: boolean;
  74425. private _noiseTexture;
  74426. /**
  74427. * Gets or sets a texture used to add random noise to particle positions
  74428. */
  74429. noiseTexture: Nullable<ProceduralTexture>;
  74430. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74431. noiseStrength: Vector3;
  74432. /**
  74433. * Callback triggered when the particle animation is ending.
  74434. */
  74435. onAnimationEnd: Nullable<() => void>;
  74436. /**
  74437. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74438. */
  74439. blendMode: number;
  74440. /**
  74441. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74442. * to override the particles.
  74443. */
  74444. forceDepthWrite: boolean;
  74445. /** 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 */
  74446. preWarmCycles: number;
  74447. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74448. preWarmStepOffset: number;
  74449. /**
  74450. * 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)
  74451. */
  74452. spriteCellChangeSpeed: number;
  74453. /**
  74454. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74455. */
  74456. startSpriteCellID: number;
  74457. /**
  74458. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74459. */
  74460. endSpriteCellID: number;
  74461. /**
  74462. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74463. */
  74464. spriteCellWidth: number;
  74465. /**
  74466. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74467. */
  74468. spriteCellHeight: number;
  74469. /**
  74470. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74471. */
  74472. spriteRandomStartCell: boolean;
  74473. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74474. translationPivot: Vector2;
  74475. /** @hidden */
  74476. protected _isAnimationSheetEnabled: boolean;
  74477. /**
  74478. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74479. */
  74480. beginAnimationOnStart: boolean;
  74481. /**
  74482. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74483. */
  74484. beginAnimationFrom: number;
  74485. /**
  74486. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74487. */
  74488. beginAnimationTo: number;
  74489. /**
  74490. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74491. */
  74492. beginAnimationLoop: boolean;
  74493. /**
  74494. * Gets or sets a world offset applied to all particles
  74495. */
  74496. worldOffset: Vector3;
  74497. /**
  74498. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74499. */
  74500. isAnimationSheetEnabled: boolean;
  74501. /**
  74502. * Get hosting scene
  74503. * @returns the scene
  74504. */
  74505. getScene(): Scene;
  74506. /**
  74507. * You can use gravity if you want to give an orientation to your particles.
  74508. */
  74509. gravity: Vector3;
  74510. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74511. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74512. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74513. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74514. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74515. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74516. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74517. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74518. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74519. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74520. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74521. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74522. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74523. /**
  74524. * Defines the delay in milliseconds before starting the system (0 by default)
  74525. */
  74526. startDelay: number;
  74527. /**
  74528. * Gets the current list of drag gradients.
  74529. * You must use addDragGradient and removeDragGradient to udpate this list
  74530. * @returns the list of drag gradients
  74531. */
  74532. getDragGradients(): Nullable<Array<FactorGradient>>;
  74533. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74534. limitVelocityDamping: number;
  74535. /**
  74536. * Gets the current list of limit velocity gradients.
  74537. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74538. * @returns the list of limit velocity gradients
  74539. */
  74540. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74541. /**
  74542. * Gets the current list of color gradients.
  74543. * You must use addColorGradient and removeColorGradient to udpate this list
  74544. * @returns the list of color gradients
  74545. */
  74546. getColorGradients(): Nullable<Array<ColorGradient>>;
  74547. /**
  74548. * Gets the current list of size gradients.
  74549. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74550. * @returns the list of size gradients
  74551. */
  74552. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74553. /**
  74554. * Gets the current list of color remap gradients.
  74555. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74556. * @returns the list of color remap gradients
  74557. */
  74558. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74559. /**
  74560. * Gets the current list of alpha remap gradients.
  74561. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74562. * @returns the list of alpha remap gradients
  74563. */
  74564. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74565. /**
  74566. * Gets the current list of life time gradients.
  74567. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74568. * @returns the list of life time gradients
  74569. */
  74570. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74571. /**
  74572. * Gets the current list of angular speed gradients.
  74573. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74574. * @returns the list of angular speed gradients
  74575. */
  74576. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74577. /**
  74578. * Gets the current list of velocity gradients.
  74579. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74580. * @returns the list of velocity gradients
  74581. */
  74582. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74583. /**
  74584. * Gets the current list of start size gradients.
  74585. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74586. * @returns the list of start size gradients
  74587. */
  74588. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74589. /**
  74590. * Gets the current list of emit rate gradients.
  74591. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74592. * @returns the list of emit rate gradients
  74593. */
  74594. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74595. /**
  74596. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74597. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74598. */
  74599. direction1: Vector3;
  74600. /**
  74601. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74602. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74603. */
  74604. direction2: Vector3;
  74605. /**
  74606. * 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.
  74607. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74608. */
  74609. minEmitBox: Vector3;
  74610. /**
  74611. * 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.
  74612. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74613. */
  74614. maxEmitBox: Vector3;
  74615. /**
  74616. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74617. */
  74618. color1: Color4;
  74619. /**
  74620. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74621. */
  74622. color2: Color4;
  74623. /**
  74624. * Color the particle will have at the end of its lifetime
  74625. */
  74626. colorDead: Color4;
  74627. /**
  74628. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74629. */
  74630. textureMask: Color4;
  74631. /**
  74632. * The particle emitter type defines the emitter used by the particle system.
  74633. * It can be for example box, sphere, or cone...
  74634. */
  74635. particleEmitterType: IParticleEmitterType;
  74636. /** @hidden */
  74637. _isSubEmitter: boolean;
  74638. /**
  74639. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74640. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74641. */
  74642. billboardMode: number;
  74643. protected _isBillboardBased: boolean;
  74644. /**
  74645. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74646. */
  74647. isBillboardBased: boolean;
  74648. /**
  74649. * The scene the particle system belongs to.
  74650. */
  74651. protected _scene: Scene;
  74652. /**
  74653. * Local cache of defines for image processing.
  74654. */
  74655. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74656. /**
  74657. * Default configuration related to image processing available in the standard Material.
  74658. */
  74659. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74660. /**
  74661. * Gets the image processing configuration used either in this material.
  74662. */
  74663. /**
  74664. * Sets the Default image processing configuration used either in the this material.
  74665. *
  74666. * If sets to null, the scene one is in use.
  74667. */
  74668. imageProcessingConfiguration: ImageProcessingConfiguration;
  74669. /**
  74670. * Attaches a new image processing configuration to the Standard Material.
  74671. * @param configuration
  74672. */
  74673. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74674. /** @hidden */
  74675. protected _reset(): void;
  74676. /** @hidden */
  74677. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74678. /**
  74679. * Instantiates a particle system.
  74680. * 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.
  74681. * @param name The name of the particle system
  74682. */
  74683. constructor(name: string);
  74684. /**
  74685. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74686. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74687. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74688. * @returns the emitter
  74689. */
  74690. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74691. /**
  74692. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74693. * @param radius The radius of the hemisphere to emit from
  74694. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74695. * @returns the emitter
  74696. */
  74697. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74698. /**
  74699. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74700. * @param radius The radius of the sphere to emit from
  74701. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74702. * @returns the emitter
  74703. */
  74704. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74705. /**
  74706. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74707. * @param radius The radius of the sphere to emit from
  74708. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74709. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74710. * @returns the emitter
  74711. */
  74712. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74713. /**
  74714. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74715. * @param radius The radius of the emission cylinder
  74716. * @param height The height of the emission cylinder
  74717. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74718. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74719. * @returns the emitter
  74720. */
  74721. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74722. /**
  74723. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74724. * @param radius The radius of the cylinder to emit from
  74725. * @param height The height of the emission cylinder
  74726. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74727. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74728. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74729. * @returns the emitter
  74730. */
  74731. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74732. /**
  74733. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74734. * @param radius The radius of the cone to emit from
  74735. * @param angle The base angle of the cone
  74736. * @returns the emitter
  74737. */
  74738. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74739. /**
  74740. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74741. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74742. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74743. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74744. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74745. * @returns the emitter
  74746. */
  74747. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74748. }
  74749. }
  74750. declare module BABYLON {
  74751. /**
  74752. * Type of sub emitter
  74753. */
  74754. export enum SubEmitterType {
  74755. /**
  74756. * Attached to the particle over it's lifetime
  74757. */
  74758. ATTACHED = 0,
  74759. /**
  74760. * Created when the particle dies
  74761. */
  74762. END = 1
  74763. }
  74764. /**
  74765. * Sub emitter class used to emit particles from an existing particle
  74766. */
  74767. export class SubEmitter {
  74768. /**
  74769. * the particle system to be used by the sub emitter
  74770. */
  74771. particleSystem: ParticleSystem;
  74772. /**
  74773. * Type of the submitter (Default: END)
  74774. */
  74775. type: SubEmitterType;
  74776. /**
  74777. * 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)
  74778. * Note: This only is supported when using an emitter of type Mesh
  74779. */
  74780. inheritDirection: boolean;
  74781. /**
  74782. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74783. */
  74784. inheritedVelocityAmount: number;
  74785. /**
  74786. * Creates a sub emitter
  74787. * @param particleSystem the particle system to be used by the sub emitter
  74788. */
  74789. constructor(
  74790. /**
  74791. * the particle system to be used by the sub emitter
  74792. */
  74793. particleSystem: ParticleSystem);
  74794. /**
  74795. * Clones the sub emitter
  74796. * @returns the cloned sub emitter
  74797. */
  74798. clone(): SubEmitter;
  74799. /**
  74800. * Serialize current object to a JSON object
  74801. * @returns the serialized object
  74802. */
  74803. serialize(): any;
  74804. /** @hidden */
  74805. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74806. /**
  74807. * Creates a new SubEmitter from a serialized JSON version
  74808. * @param serializationObject defines the JSON object to read from
  74809. * @param scene defines the hosting scene
  74810. * @param rootUrl defines the rootUrl for data loading
  74811. * @returns a new SubEmitter
  74812. */
  74813. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74814. /** Release associated resources */
  74815. dispose(): void;
  74816. }
  74817. }
  74818. declare module BABYLON {
  74819. /** @hidden */
  74820. export var clipPlaneFragmentDeclaration: {
  74821. name: string;
  74822. shader: string;
  74823. };
  74824. }
  74825. declare module BABYLON {
  74826. /** @hidden */
  74827. export var imageProcessingDeclaration: {
  74828. name: string;
  74829. shader: string;
  74830. };
  74831. }
  74832. declare module BABYLON {
  74833. /** @hidden */
  74834. export var imageProcessingFunctions: {
  74835. name: string;
  74836. shader: string;
  74837. };
  74838. }
  74839. declare module BABYLON {
  74840. /** @hidden */
  74841. export var clipPlaneFragment: {
  74842. name: string;
  74843. shader: string;
  74844. };
  74845. }
  74846. declare module BABYLON {
  74847. /** @hidden */
  74848. export var particlesPixelShader: {
  74849. name: string;
  74850. shader: string;
  74851. };
  74852. }
  74853. declare module BABYLON {
  74854. /** @hidden */
  74855. export var clipPlaneVertexDeclaration: {
  74856. name: string;
  74857. shader: string;
  74858. };
  74859. }
  74860. declare module BABYLON {
  74861. /** @hidden */
  74862. export var clipPlaneVertex: {
  74863. name: string;
  74864. shader: string;
  74865. };
  74866. }
  74867. declare module BABYLON {
  74868. /** @hidden */
  74869. export var particlesVertexShader: {
  74870. name: string;
  74871. shader: string;
  74872. };
  74873. }
  74874. declare module BABYLON {
  74875. /**
  74876. * This represents a particle system in Babylon.
  74877. * 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.
  74878. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74879. * @example https://doc.babylonjs.com/babylon101/particles
  74880. */
  74881. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74882. /**
  74883. * Billboard mode will only apply to Y axis
  74884. */
  74885. static readonly BILLBOARDMODE_Y: number;
  74886. /**
  74887. * Billboard mode will apply to all axes
  74888. */
  74889. static readonly BILLBOARDMODE_ALL: number;
  74890. /**
  74891. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74892. */
  74893. static readonly BILLBOARDMODE_STRETCHED: number;
  74894. /**
  74895. * This function can be defined to provide custom update for active particles.
  74896. * This function will be called instead of regular update (age, position, color, etc.).
  74897. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74898. */
  74899. updateFunction: (particles: Particle[]) => void;
  74900. private _emitterWorldMatrix;
  74901. /**
  74902. * This function can be defined to specify initial direction for every new particle.
  74903. * It by default use the emitterType defined function
  74904. */
  74905. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74906. /**
  74907. * This function can be defined to specify initial position for every new particle.
  74908. * It by default use the emitterType defined function
  74909. */
  74910. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74911. /**
  74912. * @hidden
  74913. */
  74914. _inheritedVelocityOffset: Vector3;
  74915. /**
  74916. * An event triggered when the system is disposed
  74917. */
  74918. onDisposeObservable: Observable<ParticleSystem>;
  74919. private _onDisposeObserver;
  74920. /**
  74921. * Sets a callback that will be triggered when the system is disposed
  74922. */
  74923. onDispose: () => void;
  74924. private _particles;
  74925. private _epsilon;
  74926. private _capacity;
  74927. private _stockParticles;
  74928. private _newPartsExcess;
  74929. private _vertexData;
  74930. private _vertexBuffer;
  74931. private _vertexBuffers;
  74932. private _spriteBuffer;
  74933. private _indexBuffer;
  74934. private _effect;
  74935. private _customEffect;
  74936. private _cachedDefines;
  74937. private _scaledColorStep;
  74938. private _colorDiff;
  74939. private _scaledDirection;
  74940. private _scaledGravity;
  74941. private _currentRenderId;
  74942. private _alive;
  74943. private _useInstancing;
  74944. private _started;
  74945. private _stopped;
  74946. private _actualFrame;
  74947. private _scaledUpdateSpeed;
  74948. private _vertexBufferSize;
  74949. /** @hidden */
  74950. _currentEmitRateGradient: Nullable<FactorGradient>;
  74951. /** @hidden */
  74952. _currentEmitRate1: number;
  74953. /** @hidden */
  74954. _currentEmitRate2: number;
  74955. /** @hidden */
  74956. _currentStartSizeGradient: Nullable<FactorGradient>;
  74957. /** @hidden */
  74958. _currentStartSize1: number;
  74959. /** @hidden */
  74960. _currentStartSize2: number;
  74961. private readonly _rawTextureWidth;
  74962. private _rampGradientsTexture;
  74963. private _useRampGradients;
  74964. /** Gets or sets a boolean indicating that ramp gradients must be used
  74965. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74966. */
  74967. useRampGradients: boolean;
  74968. /**
  74969. * 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.
  74970. * 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: [])
  74971. */
  74972. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74973. private _subEmitters;
  74974. /**
  74975. * @hidden
  74976. * If the particle systems emitter should be disposed when the particle system is disposed
  74977. */
  74978. _disposeEmitterOnDispose: boolean;
  74979. /**
  74980. * The current active Sub-systems, this property is used by the root particle system only.
  74981. */
  74982. activeSubSystems: Array<ParticleSystem>;
  74983. private _rootParticleSystem;
  74984. /**
  74985. * Gets the current list of active particles
  74986. */
  74987. readonly particles: Particle[];
  74988. /**
  74989. * Returns the string "ParticleSystem"
  74990. * @returns a string containing the class name
  74991. */
  74992. getClassName(): string;
  74993. /**
  74994. * Instantiates a particle system.
  74995. * 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.
  74996. * @param name The name of the particle system
  74997. * @param capacity The max number of particles alive at the same time
  74998. * @param scene The scene the particle system belongs to
  74999. * @param customEffect a custom effect used to change the way particles are rendered by default
  75000. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  75001. * @param epsilon Offset used to render the particles
  75002. */
  75003. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  75004. private _addFactorGradient;
  75005. private _removeFactorGradient;
  75006. /**
  75007. * Adds a new life time gradient
  75008. * @param gradient defines the gradient to use (between 0 and 1)
  75009. * @param factor defines the life time factor to affect to the specified gradient
  75010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75011. * @returns the current particle system
  75012. */
  75013. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75014. /**
  75015. * Remove a specific life time gradient
  75016. * @param gradient defines the gradient to remove
  75017. * @returns the current particle system
  75018. */
  75019. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75020. /**
  75021. * Adds a new size gradient
  75022. * @param gradient defines the gradient to use (between 0 and 1)
  75023. * @param factor defines the size factor to affect to the specified gradient
  75024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75025. * @returns the current particle system
  75026. */
  75027. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75028. /**
  75029. * Remove a specific size gradient
  75030. * @param gradient defines the gradient to remove
  75031. * @returns the current particle system
  75032. */
  75033. removeSizeGradient(gradient: number): IParticleSystem;
  75034. /**
  75035. * Adds a new color remap gradient
  75036. * @param gradient defines the gradient to use (between 0 and 1)
  75037. * @param min defines the color remap minimal range
  75038. * @param max defines the color remap maximal range
  75039. * @returns the current particle system
  75040. */
  75041. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75042. /**
  75043. * Remove a specific color remap gradient
  75044. * @param gradient defines the gradient to remove
  75045. * @returns the current particle system
  75046. */
  75047. removeColorRemapGradient(gradient: number): IParticleSystem;
  75048. /**
  75049. * Adds a new alpha remap gradient
  75050. * @param gradient defines the gradient to use (between 0 and 1)
  75051. * @param min defines the alpha remap minimal range
  75052. * @param max defines the alpha remap maximal range
  75053. * @returns the current particle system
  75054. */
  75055. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75056. /**
  75057. * Remove a specific alpha remap gradient
  75058. * @param gradient defines the gradient to remove
  75059. * @returns the current particle system
  75060. */
  75061. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  75062. /**
  75063. * Adds a new angular speed gradient
  75064. * @param gradient defines the gradient to use (between 0 and 1)
  75065. * @param factor defines the angular speed to affect to the specified gradient
  75066. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75067. * @returns the current particle system
  75068. */
  75069. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75070. /**
  75071. * Remove a specific angular speed gradient
  75072. * @param gradient defines the gradient to remove
  75073. * @returns the current particle system
  75074. */
  75075. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75076. /**
  75077. * Adds a new velocity gradient
  75078. * @param gradient defines the gradient to use (between 0 and 1)
  75079. * @param factor defines the velocity to affect to the specified gradient
  75080. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75081. * @returns the current particle system
  75082. */
  75083. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75084. /**
  75085. * Remove a specific velocity gradient
  75086. * @param gradient defines the gradient to remove
  75087. * @returns the current particle system
  75088. */
  75089. removeVelocityGradient(gradient: number): IParticleSystem;
  75090. /**
  75091. * Adds a new limit velocity gradient
  75092. * @param gradient defines the gradient to use (between 0 and 1)
  75093. * @param factor defines the limit velocity value to affect to the specified gradient
  75094. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75095. * @returns the current particle system
  75096. */
  75097. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75098. /**
  75099. * Remove a specific limit velocity gradient
  75100. * @param gradient defines the gradient to remove
  75101. * @returns the current particle system
  75102. */
  75103. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75104. /**
  75105. * Adds a new drag gradient
  75106. * @param gradient defines the gradient to use (between 0 and 1)
  75107. * @param factor defines the drag value to affect to the specified gradient
  75108. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75109. * @returns the current particle system
  75110. */
  75111. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75112. /**
  75113. * Remove a specific drag gradient
  75114. * @param gradient defines the gradient to remove
  75115. * @returns the current particle system
  75116. */
  75117. removeDragGradient(gradient: number): IParticleSystem;
  75118. /**
  75119. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75120. * @param gradient defines the gradient to use (between 0 and 1)
  75121. * @param factor defines the emit rate value to affect to the specified gradient
  75122. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75123. * @returns the current particle system
  75124. */
  75125. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75126. /**
  75127. * Remove a specific emit rate gradient
  75128. * @param gradient defines the gradient to remove
  75129. * @returns the current particle system
  75130. */
  75131. removeEmitRateGradient(gradient: number): IParticleSystem;
  75132. /**
  75133. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75134. * @param gradient defines the gradient to use (between 0 and 1)
  75135. * @param factor defines the start size value to affect to the specified gradient
  75136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75137. * @returns the current particle system
  75138. */
  75139. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75140. /**
  75141. * Remove a specific start size gradient
  75142. * @param gradient defines the gradient to remove
  75143. * @returns the current particle system
  75144. */
  75145. removeStartSizeGradient(gradient: number): IParticleSystem;
  75146. private _createRampGradientTexture;
  75147. /**
  75148. * Gets the current list of ramp gradients.
  75149. * You must use addRampGradient and removeRampGradient to udpate this list
  75150. * @returns the list of ramp gradients
  75151. */
  75152. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75153. /**
  75154. * Adds a new ramp gradient used to remap particle colors
  75155. * @param gradient defines the gradient to use (between 0 and 1)
  75156. * @param color defines the color to affect to the specified gradient
  75157. * @returns the current particle system
  75158. */
  75159. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  75160. /**
  75161. * Remove a specific ramp gradient
  75162. * @param gradient defines the gradient to remove
  75163. * @returns the current particle system
  75164. */
  75165. removeRampGradient(gradient: number): ParticleSystem;
  75166. /**
  75167. * Adds a new color gradient
  75168. * @param gradient defines the gradient to use (between 0 and 1)
  75169. * @param color1 defines the color to affect to the specified gradient
  75170. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75171. * @returns this particle system
  75172. */
  75173. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75174. /**
  75175. * Remove a specific color gradient
  75176. * @param gradient defines the gradient to remove
  75177. * @returns this particle system
  75178. */
  75179. removeColorGradient(gradient: number): IParticleSystem;
  75180. private _fetchR;
  75181. protected _reset(): void;
  75182. private _resetEffect;
  75183. private _createVertexBuffers;
  75184. private _createIndexBuffer;
  75185. /**
  75186. * Gets the maximum number of particles active at the same time.
  75187. * @returns The max number of active particles.
  75188. */
  75189. getCapacity(): number;
  75190. /**
  75191. * Gets whether there are still active particles in the system.
  75192. * @returns True if it is alive, otherwise false.
  75193. */
  75194. isAlive(): boolean;
  75195. /**
  75196. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75197. * @returns True if it has been started, otherwise false.
  75198. */
  75199. isStarted(): boolean;
  75200. private _prepareSubEmitterInternalArray;
  75201. /**
  75202. * Starts the particle system and begins to emit
  75203. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75204. */
  75205. start(delay?: number): void;
  75206. /**
  75207. * Stops the particle system.
  75208. * @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.
  75209. */
  75210. stop(stopSubEmitters?: boolean): void;
  75211. /**
  75212. * Remove all active particles
  75213. */
  75214. reset(): void;
  75215. /**
  75216. * @hidden (for internal use only)
  75217. */
  75218. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  75219. /**
  75220. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  75221. * Its lifetime will start back at 0.
  75222. */
  75223. recycleParticle: (particle: Particle) => void;
  75224. private _stopSubEmitters;
  75225. private _createParticle;
  75226. private _removeFromRoot;
  75227. private _emitFromParticle;
  75228. private _update;
  75229. /** @hidden */
  75230. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  75231. /** @hidden */
  75232. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  75233. /** @hidden */
  75234. private _getEffect;
  75235. /**
  75236. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75237. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  75238. */
  75239. animate(preWarmOnly?: boolean): void;
  75240. private _appendParticleVertices;
  75241. /**
  75242. * Rebuilds the particle system.
  75243. */
  75244. rebuild(): void;
  75245. /**
  75246. * Is this system ready to be used/rendered
  75247. * @return true if the system is ready
  75248. */
  75249. isReady(): boolean;
  75250. private _render;
  75251. /**
  75252. * Renders the particle system in its current state.
  75253. * @returns the current number of particles
  75254. */
  75255. render(): number;
  75256. /**
  75257. * Disposes the particle system and free the associated resources
  75258. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75259. */
  75260. dispose(disposeTexture?: boolean): void;
  75261. /**
  75262. * Clones the particle system.
  75263. * @param name The name of the cloned object
  75264. * @param newEmitter The new emitter to use
  75265. * @returns the cloned particle system
  75266. */
  75267. clone(name: string, newEmitter: any): ParticleSystem;
  75268. /**
  75269. * Serializes the particle system to a JSON object.
  75270. * @returns the JSON object
  75271. */
  75272. serialize(): any;
  75273. /** @hidden */
  75274. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  75275. /** @hidden */
  75276. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  75277. /**
  75278. * Parses a JSON object to create a particle system.
  75279. * @param parsedParticleSystem The JSON object to parse
  75280. * @param scene The scene to create the particle system in
  75281. * @param rootUrl The root url to use to load external dependencies like texture
  75282. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75283. * @returns the Parsed particle system
  75284. */
  75285. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  75286. }
  75287. }
  75288. declare module BABYLON {
  75289. /**
  75290. * A particle represents one of the element emitted by a particle system.
  75291. * This is mainly define by its coordinates, direction, velocity and age.
  75292. */
  75293. export class Particle {
  75294. /**
  75295. * The particle system the particle belongs to.
  75296. */
  75297. particleSystem: ParticleSystem;
  75298. private static _Count;
  75299. /**
  75300. * Unique ID of the particle
  75301. */
  75302. id: number;
  75303. /**
  75304. * The world position of the particle in the scene.
  75305. */
  75306. position: Vector3;
  75307. /**
  75308. * The world direction of the particle in the scene.
  75309. */
  75310. direction: Vector3;
  75311. /**
  75312. * The color of the particle.
  75313. */
  75314. color: Color4;
  75315. /**
  75316. * The color change of the particle per step.
  75317. */
  75318. colorStep: Color4;
  75319. /**
  75320. * Defines how long will the life of the particle be.
  75321. */
  75322. lifeTime: number;
  75323. /**
  75324. * The current age of the particle.
  75325. */
  75326. age: number;
  75327. /**
  75328. * The current size of the particle.
  75329. */
  75330. size: number;
  75331. /**
  75332. * The current scale of the particle.
  75333. */
  75334. scale: Vector2;
  75335. /**
  75336. * The current angle of the particle.
  75337. */
  75338. angle: number;
  75339. /**
  75340. * Defines how fast is the angle changing.
  75341. */
  75342. angularSpeed: number;
  75343. /**
  75344. * Defines the cell index used by the particle to be rendered from a sprite.
  75345. */
  75346. cellIndex: number;
  75347. /**
  75348. * The information required to support color remapping
  75349. */
  75350. remapData: Vector4;
  75351. /** @hidden */
  75352. _randomCellOffset?: number;
  75353. /** @hidden */
  75354. _initialDirection: Nullable<Vector3>;
  75355. /** @hidden */
  75356. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75357. /** @hidden */
  75358. _initialStartSpriteCellID: number;
  75359. /** @hidden */
  75360. _initialEndSpriteCellID: number;
  75361. /** @hidden */
  75362. _currentColorGradient: Nullable<ColorGradient>;
  75363. /** @hidden */
  75364. _currentColor1: Color4;
  75365. /** @hidden */
  75366. _currentColor2: Color4;
  75367. /** @hidden */
  75368. _currentSizeGradient: Nullable<FactorGradient>;
  75369. /** @hidden */
  75370. _currentSize1: number;
  75371. /** @hidden */
  75372. _currentSize2: number;
  75373. /** @hidden */
  75374. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75375. /** @hidden */
  75376. _currentAngularSpeed1: number;
  75377. /** @hidden */
  75378. _currentAngularSpeed2: number;
  75379. /** @hidden */
  75380. _currentVelocityGradient: Nullable<FactorGradient>;
  75381. /** @hidden */
  75382. _currentVelocity1: number;
  75383. /** @hidden */
  75384. _currentVelocity2: number;
  75385. /** @hidden */
  75386. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75387. /** @hidden */
  75388. _currentLimitVelocity1: number;
  75389. /** @hidden */
  75390. _currentLimitVelocity2: number;
  75391. /** @hidden */
  75392. _currentDragGradient: Nullable<FactorGradient>;
  75393. /** @hidden */
  75394. _currentDrag1: number;
  75395. /** @hidden */
  75396. _currentDrag2: number;
  75397. /** @hidden */
  75398. _randomNoiseCoordinates1: Vector3;
  75399. /** @hidden */
  75400. _randomNoiseCoordinates2: Vector3;
  75401. /**
  75402. * Creates a new instance Particle
  75403. * @param particleSystem the particle system the particle belongs to
  75404. */
  75405. constructor(
  75406. /**
  75407. * The particle system the particle belongs to.
  75408. */
  75409. particleSystem: ParticleSystem);
  75410. private updateCellInfoFromSystem;
  75411. /**
  75412. * Defines how the sprite cell index is updated for the particle
  75413. */
  75414. updateCellIndex(): void;
  75415. /** @hidden */
  75416. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75417. /** @hidden */
  75418. _inheritParticleInfoToSubEmitters(): void;
  75419. /** @hidden */
  75420. _reset(): void;
  75421. /**
  75422. * Copy the properties of particle to another one.
  75423. * @param other the particle to copy the information to.
  75424. */
  75425. copyTo(other: Particle): void;
  75426. }
  75427. }
  75428. declare module BABYLON {
  75429. /**
  75430. * Particle emitter represents a volume emitting particles.
  75431. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75432. */
  75433. export interface IParticleEmitterType {
  75434. /**
  75435. * Called by the particle System when the direction is computed for the created particle.
  75436. * @param worldMatrix is the world matrix of the particle system
  75437. * @param directionToUpdate is the direction vector to update with the result
  75438. * @param particle is the particle we are computed the direction for
  75439. */
  75440. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75441. /**
  75442. * Called by the particle System when the position is computed for the created particle.
  75443. * @param worldMatrix is the world matrix of the particle system
  75444. * @param positionToUpdate is the position vector to update with the result
  75445. * @param particle is the particle we are computed the position for
  75446. */
  75447. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75448. /**
  75449. * Clones the current emitter and returns a copy of it
  75450. * @returns the new emitter
  75451. */
  75452. clone(): IParticleEmitterType;
  75453. /**
  75454. * Called by the GPUParticleSystem to setup the update shader
  75455. * @param effect defines the update shader
  75456. */
  75457. applyToShader(effect: Effect): void;
  75458. /**
  75459. * Returns a string to use to update the GPU particles update shader
  75460. * @returns the effect defines string
  75461. */
  75462. getEffectDefines(): string;
  75463. /**
  75464. * Returns a string representing the class name
  75465. * @returns a string containing the class name
  75466. */
  75467. getClassName(): string;
  75468. /**
  75469. * Serializes the particle system to a JSON object.
  75470. * @returns the JSON object
  75471. */
  75472. serialize(): any;
  75473. /**
  75474. * Parse properties from a JSON object
  75475. * @param serializationObject defines the JSON object
  75476. */
  75477. parse(serializationObject: any): void;
  75478. }
  75479. }
  75480. declare module BABYLON {
  75481. /**
  75482. * Particle emitter emitting particles from the inside of a box.
  75483. * It emits the particles randomly between 2 given directions.
  75484. */
  75485. export class BoxParticleEmitter implements IParticleEmitterType {
  75486. /**
  75487. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75488. */
  75489. direction1: Vector3;
  75490. /**
  75491. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75492. */
  75493. direction2: Vector3;
  75494. /**
  75495. * 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.
  75496. */
  75497. minEmitBox: Vector3;
  75498. /**
  75499. * 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.
  75500. */
  75501. maxEmitBox: Vector3;
  75502. /**
  75503. * Creates a new instance BoxParticleEmitter
  75504. */
  75505. constructor();
  75506. /**
  75507. * Called by the particle System when the direction is computed for the created particle.
  75508. * @param worldMatrix is the world matrix of the particle system
  75509. * @param directionToUpdate is the direction vector to update with the result
  75510. * @param particle is the particle we are computed the direction for
  75511. */
  75512. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75513. /**
  75514. * Called by the particle System when the position is computed for the created particle.
  75515. * @param worldMatrix is the world matrix of the particle system
  75516. * @param positionToUpdate is the position vector to update with the result
  75517. * @param particle is the particle we are computed the position for
  75518. */
  75519. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75520. /**
  75521. * Clones the current emitter and returns a copy of it
  75522. * @returns the new emitter
  75523. */
  75524. clone(): BoxParticleEmitter;
  75525. /**
  75526. * Called by the GPUParticleSystem to setup the update shader
  75527. * @param effect defines the update shader
  75528. */
  75529. applyToShader(effect: Effect): void;
  75530. /**
  75531. * Returns a string to use to update the GPU particles update shader
  75532. * @returns a string containng the defines string
  75533. */
  75534. getEffectDefines(): string;
  75535. /**
  75536. * Returns the string "BoxParticleEmitter"
  75537. * @returns a string containing the class name
  75538. */
  75539. getClassName(): string;
  75540. /**
  75541. * Serializes the particle system to a JSON object.
  75542. * @returns the JSON object
  75543. */
  75544. serialize(): any;
  75545. /**
  75546. * Parse properties from a JSON object
  75547. * @param serializationObject defines the JSON object
  75548. */
  75549. parse(serializationObject: any): void;
  75550. }
  75551. }
  75552. declare module BABYLON {
  75553. /**
  75554. * Particle emitter emitting particles from the inside of a cone.
  75555. * It emits the particles alongside the cone volume from the base to the particle.
  75556. * The emission direction might be randomized.
  75557. */
  75558. export class ConeParticleEmitter implements IParticleEmitterType {
  75559. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75560. directionRandomizer: number;
  75561. private _radius;
  75562. private _angle;
  75563. private _height;
  75564. /**
  75565. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75566. */
  75567. radiusRange: number;
  75568. /**
  75569. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75570. */
  75571. heightRange: number;
  75572. /**
  75573. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75574. */
  75575. emitFromSpawnPointOnly: boolean;
  75576. /**
  75577. * Gets or sets the radius of the emission cone
  75578. */
  75579. radius: number;
  75580. /**
  75581. * Gets or sets the angle of the emission cone
  75582. */
  75583. angle: number;
  75584. private _buildHeight;
  75585. /**
  75586. * Creates a new instance ConeParticleEmitter
  75587. * @param radius the radius of the emission cone (1 by default)
  75588. * @param angle the cone base angle (PI by default)
  75589. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75590. */
  75591. constructor(radius?: number, angle?: number,
  75592. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75593. directionRandomizer?: number);
  75594. /**
  75595. * Called by the particle System when the direction is computed for the created particle.
  75596. * @param worldMatrix is the world matrix of the particle system
  75597. * @param directionToUpdate is the direction vector to update with the result
  75598. * @param particle is the particle we are computed the direction for
  75599. */
  75600. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75601. /**
  75602. * Called by the particle System when the position is computed for the created particle.
  75603. * @param worldMatrix is the world matrix of the particle system
  75604. * @param positionToUpdate is the position vector to update with the result
  75605. * @param particle is the particle we are computed the position for
  75606. */
  75607. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75608. /**
  75609. * Clones the current emitter and returns a copy of it
  75610. * @returns the new emitter
  75611. */
  75612. clone(): ConeParticleEmitter;
  75613. /**
  75614. * Called by the GPUParticleSystem to setup the update shader
  75615. * @param effect defines the update shader
  75616. */
  75617. applyToShader(effect: Effect): void;
  75618. /**
  75619. * Returns a string to use to update the GPU particles update shader
  75620. * @returns a string containng the defines string
  75621. */
  75622. getEffectDefines(): string;
  75623. /**
  75624. * Returns the string "ConeParticleEmitter"
  75625. * @returns a string containing the class name
  75626. */
  75627. getClassName(): string;
  75628. /**
  75629. * Serializes the particle system to a JSON object.
  75630. * @returns the JSON object
  75631. */
  75632. serialize(): any;
  75633. /**
  75634. * Parse properties from a JSON object
  75635. * @param serializationObject defines the JSON object
  75636. */
  75637. parse(serializationObject: any): void;
  75638. }
  75639. }
  75640. declare module BABYLON {
  75641. /**
  75642. * Particle emitter emitting particles from the inside of a cylinder.
  75643. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75644. */
  75645. export class CylinderParticleEmitter implements IParticleEmitterType {
  75646. /**
  75647. * The radius of the emission cylinder.
  75648. */
  75649. radius: number;
  75650. /**
  75651. * The height of the emission cylinder.
  75652. */
  75653. height: number;
  75654. /**
  75655. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75656. */
  75657. radiusRange: number;
  75658. /**
  75659. * How much to randomize the particle direction [0-1].
  75660. */
  75661. directionRandomizer: number;
  75662. /**
  75663. * Creates a new instance CylinderParticleEmitter
  75664. * @param radius the radius of the emission cylinder (1 by default)
  75665. * @param height the height of the emission cylinder (1 by default)
  75666. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75667. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75668. */
  75669. constructor(
  75670. /**
  75671. * The radius of the emission cylinder.
  75672. */
  75673. radius?: number,
  75674. /**
  75675. * The height of the emission cylinder.
  75676. */
  75677. height?: number,
  75678. /**
  75679. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75680. */
  75681. radiusRange?: number,
  75682. /**
  75683. * How much to randomize the particle direction [0-1].
  75684. */
  75685. directionRandomizer?: number);
  75686. /**
  75687. * Called by the particle System when the direction is computed for the created particle.
  75688. * @param worldMatrix is the world matrix of the particle system
  75689. * @param directionToUpdate is the direction vector to update with the result
  75690. * @param particle is the particle we are computed the direction for
  75691. */
  75692. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75693. /**
  75694. * Called by the particle System when the position is computed for the created particle.
  75695. * @param worldMatrix is the world matrix of the particle system
  75696. * @param positionToUpdate is the position vector to update with the result
  75697. * @param particle is the particle we are computed the position for
  75698. */
  75699. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75700. /**
  75701. * Clones the current emitter and returns a copy of it
  75702. * @returns the new emitter
  75703. */
  75704. clone(): CylinderParticleEmitter;
  75705. /**
  75706. * Called by the GPUParticleSystem to setup the update shader
  75707. * @param effect defines the update shader
  75708. */
  75709. applyToShader(effect: Effect): void;
  75710. /**
  75711. * Returns a string to use to update the GPU particles update shader
  75712. * @returns a string containng the defines string
  75713. */
  75714. getEffectDefines(): string;
  75715. /**
  75716. * Returns the string "CylinderParticleEmitter"
  75717. * @returns a string containing the class name
  75718. */
  75719. getClassName(): string;
  75720. /**
  75721. * Serializes the particle system to a JSON object.
  75722. * @returns the JSON object
  75723. */
  75724. serialize(): any;
  75725. /**
  75726. * Parse properties from a JSON object
  75727. * @param serializationObject defines the JSON object
  75728. */
  75729. parse(serializationObject: any): void;
  75730. }
  75731. /**
  75732. * Particle emitter emitting particles from the inside of a cylinder.
  75733. * It emits the particles randomly between two vectors.
  75734. */
  75735. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75736. /**
  75737. * The min limit of the emission direction.
  75738. */
  75739. direction1: Vector3;
  75740. /**
  75741. * The max limit of the emission direction.
  75742. */
  75743. direction2: Vector3;
  75744. /**
  75745. * Creates a new instance CylinderDirectedParticleEmitter
  75746. * @param radius the radius of the emission cylinder (1 by default)
  75747. * @param height the height of the emission cylinder (1 by default)
  75748. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75749. * @param direction1 the min limit of the emission direction (up vector by default)
  75750. * @param direction2 the max limit of the emission direction (up vector by default)
  75751. */
  75752. constructor(radius?: number, height?: number, radiusRange?: number,
  75753. /**
  75754. * The min limit of the emission direction.
  75755. */
  75756. direction1?: Vector3,
  75757. /**
  75758. * The max limit of the emission direction.
  75759. */
  75760. direction2?: Vector3);
  75761. /**
  75762. * Called by the particle System when the direction is computed for the created particle.
  75763. * @param worldMatrix is the world matrix of the particle system
  75764. * @param directionToUpdate is the direction vector to update with the result
  75765. * @param particle is the particle we are computed the direction for
  75766. */
  75767. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75768. /**
  75769. * Clones the current emitter and returns a copy of it
  75770. * @returns the new emitter
  75771. */
  75772. clone(): CylinderDirectedParticleEmitter;
  75773. /**
  75774. * Called by the GPUParticleSystem to setup the update shader
  75775. * @param effect defines the update shader
  75776. */
  75777. applyToShader(effect: Effect): void;
  75778. /**
  75779. * Returns a string to use to update the GPU particles update shader
  75780. * @returns a string containng the defines string
  75781. */
  75782. getEffectDefines(): string;
  75783. /**
  75784. * Returns the string "CylinderDirectedParticleEmitter"
  75785. * @returns a string containing the class name
  75786. */
  75787. getClassName(): string;
  75788. /**
  75789. * Serializes the particle system to a JSON object.
  75790. * @returns the JSON object
  75791. */
  75792. serialize(): any;
  75793. /**
  75794. * Parse properties from a JSON object
  75795. * @param serializationObject defines the JSON object
  75796. */
  75797. parse(serializationObject: any): void;
  75798. }
  75799. }
  75800. declare module BABYLON {
  75801. /**
  75802. * Particle emitter emitting particles from the inside of a hemisphere.
  75803. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75804. */
  75805. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75806. /**
  75807. * The radius of the emission hemisphere.
  75808. */
  75809. radius: number;
  75810. /**
  75811. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75812. */
  75813. radiusRange: number;
  75814. /**
  75815. * How much to randomize the particle direction [0-1].
  75816. */
  75817. directionRandomizer: number;
  75818. /**
  75819. * Creates a new instance HemisphericParticleEmitter
  75820. * @param radius the radius of the emission hemisphere (1 by default)
  75821. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75822. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75823. */
  75824. constructor(
  75825. /**
  75826. * The radius of the emission hemisphere.
  75827. */
  75828. radius?: number,
  75829. /**
  75830. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75831. */
  75832. radiusRange?: number,
  75833. /**
  75834. * How much to randomize the particle direction [0-1].
  75835. */
  75836. directionRandomizer?: number);
  75837. /**
  75838. * Called by the particle System when the direction is computed for the created particle.
  75839. * @param worldMatrix is the world matrix of the particle system
  75840. * @param directionToUpdate is the direction vector to update with the result
  75841. * @param particle is the particle we are computed the direction for
  75842. */
  75843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75844. /**
  75845. * Called by the particle System when the position is computed for the created particle.
  75846. * @param worldMatrix is the world matrix of the particle system
  75847. * @param positionToUpdate is the position vector to update with the result
  75848. * @param particle is the particle we are computed the position for
  75849. */
  75850. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75851. /**
  75852. * Clones the current emitter and returns a copy of it
  75853. * @returns the new emitter
  75854. */
  75855. clone(): HemisphericParticleEmitter;
  75856. /**
  75857. * Called by the GPUParticleSystem to setup the update shader
  75858. * @param effect defines the update shader
  75859. */
  75860. applyToShader(effect: Effect): void;
  75861. /**
  75862. * Returns a string to use to update the GPU particles update shader
  75863. * @returns a string containng the defines string
  75864. */
  75865. getEffectDefines(): string;
  75866. /**
  75867. * Returns the string "HemisphericParticleEmitter"
  75868. * @returns a string containing the class name
  75869. */
  75870. getClassName(): string;
  75871. /**
  75872. * Serializes the particle system to a JSON object.
  75873. * @returns the JSON object
  75874. */
  75875. serialize(): any;
  75876. /**
  75877. * Parse properties from a JSON object
  75878. * @param serializationObject defines the JSON object
  75879. */
  75880. parse(serializationObject: any): void;
  75881. }
  75882. }
  75883. declare module BABYLON {
  75884. /**
  75885. * Particle emitter emitting particles from a point.
  75886. * It emits the particles randomly between 2 given directions.
  75887. */
  75888. export class PointParticleEmitter implements IParticleEmitterType {
  75889. /**
  75890. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75891. */
  75892. direction1: Vector3;
  75893. /**
  75894. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75895. */
  75896. direction2: Vector3;
  75897. /**
  75898. * Creates a new instance PointParticleEmitter
  75899. */
  75900. constructor();
  75901. /**
  75902. * Called by the particle System when the direction is computed for the created particle.
  75903. * @param worldMatrix is the world matrix of the particle system
  75904. * @param directionToUpdate is the direction vector to update with the result
  75905. * @param particle is the particle we are computed the direction for
  75906. */
  75907. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75908. /**
  75909. * Called by the particle System when the position is computed for the created particle.
  75910. * @param worldMatrix is the world matrix of the particle system
  75911. * @param positionToUpdate is the position vector to update with the result
  75912. * @param particle is the particle we are computed the position for
  75913. */
  75914. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75915. /**
  75916. * Clones the current emitter and returns a copy of it
  75917. * @returns the new emitter
  75918. */
  75919. clone(): PointParticleEmitter;
  75920. /**
  75921. * Called by the GPUParticleSystem to setup the update shader
  75922. * @param effect defines the update shader
  75923. */
  75924. applyToShader(effect: Effect): void;
  75925. /**
  75926. * Returns a string to use to update the GPU particles update shader
  75927. * @returns a string containng the defines string
  75928. */
  75929. getEffectDefines(): string;
  75930. /**
  75931. * Returns the string "PointParticleEmitter"
  75932. * @returns a string containing the class name
  75933. */
  75934. getClassName(): string;
  75935. /**
  75936. * Serializes the particle system to a JSON object.
  75937. * @returns the JSON object
  75938. */
  75939. serialize(): any;
  75940. /**
  75941. * Parse properties from a JSON object
  75942. * @param serializationObject defines the JSON object
  75943. */
  75944. parse(serializationObject: any): void;
  75945. }
  75946. }
  75947. declare module BABYLON {
  75948. /**
  75949. * Particle emitter emitting particles from the inside of a sphere.
  75950. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75951. */
  75952. export class SphereParticleEmitter implements IParticleEmitterType {
  75953. /**
  75954. * The radius of the emission sphere.
  75955. */
  75956. radius: number;
  75957. /**
  75958. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75959. */
  75960. radiusRange: number;
  75961. /**
  75962. * How much to randomize the particle direction [0-1].
  75963. */
  75964. directionRandomizer: number;
  75965. /**
  75966. * Creates a new instance SphereParticleEmitter
  75967. * @param radius the radius of the emission sphere (1 by default)
  75968. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75969. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75970. */
  75971. constructor(
  75972. /**
  75973. * The radius of the emission sphere.
  75974. */
  75975. radius?: number,
  75976. /**
  75977. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75978. */
  75979. radiusRange?: number,
  75980. /**
  75981. * How much to randomize the particle direction [0-1].
  75982. */
  75983. directionRandomizer?: number);
  75984. /**
  75985. * Called by the particle System when the direction is computed for the created particle.
  75986. * @param worldMatrix is the world matrix of the particle system
  75987. * @param directionToUpdate is the direction vector to update with the result
  75988. * @param particle is the particle we are computed the direction for
  75989. */
  75990. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75991. /**
  75992. * Called by the particle System when the position is computed for the created particle.
  75993. * @param worldMatrix is the world matrix of the particle system
  75994. * @param positionToUpdate is the position vector to update with the result
  75995. * @param particle is the particle we are computed the position for
  75996. */
  75997. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75998. /**
  75999. * Clones the current emitter and returns a copy of it
  76000. * @returns the new emitter
  76001. */
  76002. clone(): SphereParticleEmitter;
  76003. /**
  76004. * Called by the GPUParticleSystem to setup the update shader
  76005. * @param effect defines the update shader
  76006. */
  76007. applyToShader(effect: Effect): void;
  76008. /**
  76009. * Returns a string to use to update the GPU particles update shader
  76010. * @returns a string containng the defines string
  76011. */
  76012. getEffectDefines(): string;
  76013. /**
  76014. * Returns the string "SphereParticleEmitter"
  76015. * @returns a string containing the class name
  76016. */
  76017. getClassName(): string;
  76018. /**
  76019. * Serializes the particle system to a JSON object.
  76020. * @returns the JSON object
  76021. */
  76022. serialize(): any;
  76023. /**
  76024. * Parse properties from a JSON object
  76025. * @param serializationObject defines the JSON object
  76026. */
  76027. parse(serializationObject: any): void;
  76028. }
  76029. /**
  76030. * Particle emitter emitting particles from the inside of a sphere.
  76031. * It emits the particles randomly between two vectors.
  76032. */
  76033. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  76034. /**
  76035. * The min limit of the emission direction.
  76036. */
  76037. direction1: Vector3;
  76038. /**
  76039. * The max limit of the emission direction.
  76040. */
  76041. direction2: Vector3;
  76042. /**
  76043. * Creates a new instance SphereDirectedParticleEmitter
  76044. * @param radius the radius of the emission sphere (1 by default)
  76045. * @param direction1 the min limit of the emission direction (up vector by default)
  76046. * @param direction2 the max limit of the emission direction (up vector by default)
  76047. */
  76048. constructor(radius?: number,
  76049. /**
  76050. * The min limit of the emission direction.
  76051. */
  76052. direction1?: Vector3,
  76053. /**
  76054. * The max limit of the emission direction.
  76055. */
  76056. direction2?: Vector3);
  76057. /**
  76058. * Called by the particle System when the direction is computed for the created particle.
  76059. * @param worldMatrix is the world matrix of the particle system
  76060. * @param directionToUpdate is the direction vector to update with the result
  76061. * @param particle is the particle we are computed the direction for
  76062. */
  76063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76064. /**
  76065. * Clones the current emitter and returns a copy of it
  76066. * @returns the new emitter
  76067. */
  76068. clone(): SphereDirectedParticleEmitter;
  76069. /**
  76070. * Called by the GPUParticleSystem to setup the update shader
  76071. * @param effect defines the update shader
  76072. */
  76073. applyToShader(effect: Effect): void;
  76074. /**
  76075. * Returns a string to use to update the GPU particles update shader
  76076. * @returns a string containng the defines string
  76077. */
  76078. getEffectDefines(): string;
  76079. /**
  76080. * Returns the string "SphereDirectedParticleEmitter"
  76081. * @returns a string containing the class name
  76082. */
  76083. getClassName(): string;
  76084. /**
  76085. * Serializes the particle system to a JSON object.
  76086. * @returns the JSON object
  76087. */
  76088. serialize(): any;
  76089. /**
  76090. * Parse properties from a JSON object
  76091. * @param serializationObject defines the JSON object
  76092. */
  76093. parse(serializationObject: any): void;
  76094. }
  76095. }
  76096. declare module BABYLON {
  76097. /**
  76098. * Interface representing a particle system in Babylon.js.
  76099. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  76100. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  76101. */
  76102. export interface IParticleSystem {
  76103. /**
  76104. * List of animations used by the particle system.
  76105. */
  76106. animations: Animation[];
  76107. /**
  76108. * The id of the Particle system.
  76109. */
  76110. id: string;
  76111. /**
  76112. * The name of the Particle system.
  76113. */
  76114. name: string;
  76115. /**
  76116. * The emitter represents the Mesh or position we are attaching the particle system to.
  76117. */
  76118. emitter: Nullable<AbstractMesh | Vector3>;
  76119. /**
  76120. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76121. */
  76122. isBillboardBased: boolean;
  76123. /**
  76124. * The rendering group used by the Particle system to chose when to render.
  76125. */
  76126. renderingGroupId: number;
  76127. /**
  76128. * The layer mask we are rendering the particles through.
  76129. */
  76130. layerMask: number;
  76131. /**
  76132. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76133. */
  76134. updateSpeed: number;
  76135. /**
  76136. * The amount of time the particle system is running (depends of the overall update speed).
  76137. */
  76138. targetStopDuration: number;
  76139. /**
  76140. * The texture used to render each particle. (this can be a spritesheet)
  76141. */
  76142. particleTexture: Nullable<Texture>;
  76143. /**
  76144. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  76145. */
  76146. blendMode: number;
  76147. /**
  76148. * Minimum life time of emitting particles.
  76149. */
  76150. minLifeTime: number;
  76151. /**
  76152. * Maximum life time of emitting particles.
  76153. */
  76154. maxLifeTime: number;
  76155. /**
  76156. * Minimum Size of emitting particles.
  76157. */
  76158. minSize: number;
  76159. /**
  76160. * Maximum Size of emitting particles.
  76161. */
  76162. maxSize: number;
  76163. /**
  76164. * Minimum scale of emitting particles on X axis.
  76165. */
  76166. minScaleX: number;
  76167. /**
  76168. * Maximum scale of emitting particles on X axis.
  76169. */
  76170. maxScaleX: number;
  76171. /**
  76172. * Minimum scale of emitting particles on Y axis.
  76173. */
  76174. minScaleY: number;
  76175. /**
  76176. * Maximum scale of emitting particles on Y axis.
  76177. */
  76178. maxScaleY: number;
  76179. /**
  76180. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76181. */
  76182. color1: Color4;
  76183. /**
  76184. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76185. */
  76186. color2: Color4;
  76187. /**
  76188. * Color the particle will have at the end of its lifetime.
  76189. */
  76190. colorDead: Color4;
  76191. /**
  76192. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  76193. */
  76194. emitRate: number;
  76195. /**
  76196. * You can use gravity if you want to give an orientation to your particles.
  76197. */
  76198. gravity: Vector3;
  76199. /**
  76200. * Minimum power of emitting particles.
  76201. */
  76202. minEmitPower: number;
  76203. /**
  76204. * Maximum power of emitting particles.
  76205. */
  76206. maxEmitPower: number;
  76207. /**
  76208. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76209. */
  76210. minAngularSpeed: number;
  76211. /**
  76212. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76213. */
  76214. maxAngularSpeed: number;
  76215. /**
  76216. * Gets or sets the minimal initial rotation in radians.
  76217. */
  76218. minInitialRotation: number;
  76219. /**
  76220. * Gets or sets the maximal initial rotation in radians.
  76221. */
  76222. maxInitialRotation: number;
  76223. /**
  76224. * The particle emitter type defines the emitter used by the particle system.
  76225. * It can be for example box, sphere, or cone...
  76226. */
  76227. particleEmitterType: Nullable<IParticleEmitterType>;
  76228. /**
  76229. * Defines the delay in milliseconds before starting the system (0 by default)
  76230. */
  76231. startDelay: number;
  76232. /**
  76233. * 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
  76234. */
  76235. preWarmCycles: number;
  76236. /**
  76237. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  76238. */
  76239. preWarmStepOffset: number;
  76240. /**
  76241. * 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)
  76242. */
  76243. spriteCellChangeSpeed: number;
  76244. /**
  76245. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76246. */
  76247. startSpriteCellID: number;
  76248. /**
  76249. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76250. */
  76251. endSpriteCellID: number;
  76252. /**
  76253. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76254. */
  76255. spriteCellWidth: number;
  76256. /**
  76257. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76258. */
  76259. spriteCellHeight: number;
  76260. /**
  76261. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76262. */
  76263. spriteRandomStartCell: boolean;
  76264. /**
  76265. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  76266. */
  76267. isAnimationSheetEnabled: boolean;
  76268. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76269. translationPivot: Vector2;
  76270. /**
  76271. * Gets or sets a texture used to add random noise to particle positions
  76272. */
  76273. noiseTexture: Nullable<BaseTexture>;
  76274. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76275. noiseStrength: Vector3;
  76276. /**
  76277. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76278. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76279. */
  76280. billboardMode: number;
  76281. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76282. limitVelocityDamping: number;
  76283. /**
  76284. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76285. */
  76286. beginAnimationOnStart: boolean;
  76287. /**
  76288. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76289. */
  76290. beginAnimationFrom: number;
  76291. /**
  76292. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76293. */
  76294. beginAnimationTo: number;
  76295. /**
  76296. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76297. */
  76298. beginAnimationLoop: boolean;
  76299. /**
  76300. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76301. */
  76302. disposeOnStop: boolean;
  76303. /**
  76304. * Gets the maximum number of particles active at the same time.
  76305. * @returns The max number of active particles.
  76306. */
  76307. getCapacity(): number;
  76308. /**
  76309. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76310. * @returns True if it has been started, otherwise false.
  76311. */
  76312. isStarted(): boolean;
  76313. /**
  76314. * Animates the particle system for this frame.
  76315. */
  76316. animate(): void;
  76317. /**
  76318. * Renders the particle system in its current state.
  76319. * @returns the current number of particles
  76320. */
  76321. render(): number;
  76322. /**
  76323. * Dispose the particle system and frees its associated resources.
  76324. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76325. */
  76326. dispose(disposeTexture?: boolean): void;
  76327. /**
  76328. * Clones the particle system.
  76329. * @param name The name of the cloned object
  76330. * @param newEmitter The new emitter to use
  76331. * @returns the cloned particle system
  76332. */
  76333. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76334. /**
  76335. * Serializes the particle system to a JSON object.
  76336. * @returns the JSON object
  76337. */
  76338. serialize(): any;
  76339. /**
  76340. * Rebuild the particle system
  76341. */
  76342. rebuild(): void;
  76343. /**
  76344. * Starts the particle system and begins to emit
  76345. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76346. */
  76347. start(delay?: number): void;
  76348. /**
  76349. * Stops the particle system.
  76350. */
  76351. stop(): void;
  76352. /**
  76353. * Remove all active particles
  76354. */
  76355. reset(): void;
  76356. /**
  76357. * Is this system ready to be used/rendered
  76358. * @return true if the system is ready
  76359. */
  76360. isReady(): boolean;
  76361. /**
  76362. * Adds a new color gradient
  76363. * @param gradient defines the gradient to use (between 0 and 1)
  76364. * @param color1 defines the color to affect to the specified gradient
  76365. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76366. * @returns the current particle system
  76367. */
  76368. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76369. /**
  76370. * Remove a specific color gradient
  76371. * @param gradient defines the gradient to remove
  76372. * @returns the current particle system
  76373. */
  76374. removeColorGradient(gradient: number): IParticleSystem;
  76375. /**
  76376. * Adds a new size gradient
  76377. * @param gradient defines the gradient to use (between 0 and 1)
  76378. * @param factor defines the size factor to affect to the specified gradient
  76379. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76380. * @returns the current particle system
  76381. */
  76382. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76383. /**
  76384. * Remove a specific size gradient
  76385. * @param gradient defines the gradient to remove
  76386. * @returns the current particle system
  76387. */
  76388. removeSizeGradient(gradient: number): IParticleSystem;
  76389. /**
  76390. * Gets the current list of color gradients.
  76391. * You must use addColorGradient and removeColorGradient to udpate this list
  76392. * @returns the list of color gradients
  76393. */
  76394. getColorGradients(): Nullable<Array<ColorGradient>>;
  76395. /**
  76396. * Gets the current list of size gradients.
  76397. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76398. * @returns the list of size gradients
  76399. */
  76400. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76401. /**
  76402. * Gets the current list of angular speed gradients.
  76403. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76404. * @returns the list of angular speed gradients
  76405. */
  76406. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76407. /**
  76408. * Adds a new angular speed gradient
  76409. * @param gradient defines the gradient to use (between 0 and 1)
  76410. * @param factor defines the angular speed to affect to the specified gradient
  76411. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76412. * @returns the current particle system
  76413. */
  76414. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76415. /**
  76416. * Remove a specific angular speed gradient
  76417. * @param gradient defines the gradient to remove
  76418. * @returns the current particle system
  76419. */
  76420. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76421. /**
  76422. * Gets the current list of velocity gradients.
  76423. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76424. * @returns the list of velocity gradients
  76425. */
  76426. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76427. /**
  76428. * Adds a new velocity gradient
  76429. * @param gradient defines the gradient to use (between 0 and 1)
  76430. * @param factor defines the velocity to affect to the specified gradient
  76431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76432. * @returns the current particle system
  76433. */
  76434. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76435. /**
  76436. * Remove a specific velocity gradient
  76437. * @param gradient defines the gradient to remove
  76438. * @returns the current particle system
  76439. */
  76440. removeVelocityGradient(gradient: number): IParticleSystem;
  76441. /**
  76442. * Gets the current list of limit velocity gradients.
  76443. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76444. * @returns the list of limit velocity gradients
  76445. */
  76446. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76447. /**
  76448. * Adds a new limit velocity gradient
  76449. * @param gradient defines the gradient to use (between 0 and 1)
  76450. * @param factor defines the limit velocity to affect to the specified gradient
  76451. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76452. * @returns the current particle system
  76453. */
  76454. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76455. /**
  76456. * Remove a specific limit velocity gradient
  76457. * @param gradient defines the gradient to remove
  76458. * @returns the current particle system
  76459. */
  76460. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76461. /**
  76462. * Adds a new drag gradient
  76463. * @param gradient defines the gradient to use (between 0 and 1)
  76464. * @param factor defines the drag to affect to the specified gradient
  76465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76466. * @returns the current particle system
  76467. */
  76468. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76469. /**
  76470. * Remove a specific drag gradient
  76471. * @param gradient defines the gradient to remove
  76472. * @returns the current particle system
  76473. */
  76474. removeDragGradient(gradient: number): IParticleSystem;
  76475. /**
  76476. * Gets the current list of drag gradients.
  76477. * You must use addDragGradient and removeDragGradient to udpate this list
  76478. * @returns the list of drag gradients
  76479. */
  76480. getDragGradients(): Nullable<Array<FactorGradient>>;
  76481. /**
  76482. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76483. * @param gradient defines the gradient to use (between 0 and 1)
  76484. * @param factor defines the emit rate to affect to the specified gradient
  76485. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76486. * @returns the current particle system
  76487. */
  76488. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76489. /**
  76490. * Remove a specific emit rate gradient
  76491. * @param gradient defines the gradient to remove
  76492. * @returns the current particle system
  76493. */
  76494. removeEmitRateGradient(gradient: number): IParticleSystem;
  76495. /**
  76496. * Gets the current list of emit rate gradients.
  76497. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76498. * @returns the list of emit rate gradients
  76499. */
  76500. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76501. /**
  76502. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76503. * @param gradient defines the gradient to use (between 0 and 1)
  76504. * @param factor defines the start size to affect to the specified gradient
  76505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76506. * @returns the current particle system
  76507. */
  76508. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76509. /**
  76510. * Remove a specific start size gradient
  76511. * @param gradient defines the gradient to remove
  76512. * @returns the current particle system
  76513. */
  76514. removeStartSizeGradient(gradient: number): IParticleSystem;
  76515. /**
  76516. * Gets the current list of start size gradients.
  76517. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76518. * @returns the list of start size gradients
  76519. */
  76520. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76521. /**
  76522. * Adds a new life time gradient
  76523. * @param gradient defines the gradient to use (between 0 and 1)
  76524. * @param factor defines the life time factor to affect to the specified gradient
  76525. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76526. * @returns the current particle system
  76527. */
  76528. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76529. /**
  76530. * Remove a specific life time gradient
  76531. * @param gradient defines the gradient to remove
  76532. * @returns the current particle system
  76533. */
  76534. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76535. /**
  76536. * Gets the current list of life time gradients.
  76537. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76538. * @returns the list of life time gradients
  76539. */
  76540. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76541. /**
  76542. * Gets the current list of color gradients.
  76543. * You must use addColorGradient and removeColorGradient to udpate this list
  76544. * @returns the list of color gradients
  76545. */
  76546. getColorGradients(): Nullable<Array<ColorGradient>>;
  76547. /**
  76548. * Adds a new ramp gradient used to remap particle colors
  76549. * @param gradient defines the gradient to use (between 0 and 1)
  76550. * @param color defines the color to affect to the specified gradient
  76551. * @returns the current particle system
  76552. */
  76553. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76554. /**
  76555. * Gets the current list of ramp gradients.
  76556. * You must use addRampGradient and removeRampGradient to udpate this list
  76557. * @returns the list of ramp gradients
  76558. */
  76559. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76560. /** Gets or sets a boolean indicating that ramp gradients must be used
  76561. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76562. */
  76563. useRampGradients: boolean;
  76564. /**
  76565. * Adds a new color remap gradient
  76566. * @param gradient defines the gradient to use (between 0 and 1)
  76567. * @param min defines the color remap minimal range
  76568. * @param max defines the color remap maximal range
  76569. * @returns the current particle system
  76570. */
  76571. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76572. /**
  76573. * Gets the current list of color remap gradients.
  76574. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76575. * @returns the list of color remap gradients
  76576. */
  76577. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76578. /**
  76579. * Adds a new alpha remap gradient
  76580. * @param gradient defines the gradient to use (between 0 and 1)
  76581. * @param min defines the alpha remap minimal range
  76582. * @param max defines the alpha remap maximal range
  76583. * @returns the current particle system
  76584. */
  76585. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76586. /**
  76587. * Gets the current list of alpha remap gradients.
  76588. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76589. * @returns the list of alpha remap gradients
  76590. */
  76591. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76592. /**
  76593. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76594. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76595. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76596. * @returns the emitter
  76597. */
  76598. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76599. /**
  76600. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76601. * @param radius The radius of the hemisphere to emit from
  76602. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76603. * @returns the emitter
  76604. */
  76605. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76606. /**
  76607. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76608. * @param radius The radius of the sphere to emit from
  76609. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76610. * @returns the emitter
  76611. */
  76612. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76613. /**
  76614. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76615. * @param radius The radius of the sphere to emit from
  76616. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76617. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76618. * @returns the emitter
  76619. */
  76620. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76621. /**
  76622. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76623. * @param radius The radius of the emission cylinder
  76624. * @param height The height of the emission cylinder
  76625. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76626. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76627. * @returns the emitter
  76628. */
  76629. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76630. /**
  76631. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76632. * @param radius The radius of the cylinder to emit from
  76633. * @param height The height of the emission cylinder
  76634. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76635. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76636. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76637. * @returns the emitter
  76638. */
  76639. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76640. /**
  76641. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76642. * @param radius The radius of the cone to emit from
  76643. * @param angle The base angle of the cone
  76644. * @returns the emitter
  76645. */
  76646. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76647. /**
  76648. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76651. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76652. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76653. * @returns the emitter
  76654. */
  76655. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76656. /**
  76657. * Get hosting scene
  76658. * @returns the scene
  76659. */
  76660. getScene(): Scene;
  76661. }
  76662. }
  76663. declare module BABYLON {
  76664. /**
  76665. * Creates an instance based on a source mesh.
  76666. */
  76667. export class InstancedMesh extends AbstractMesh {
  76668. private _sourceMesh;
  76669. private _currentLOD;
  76670. /** @hidden */
  76671. _indexInSourceMeshInstanceArray: number;
  76672. constructor(name: string, source: Mesh);
  76673. /**
  76674. * Returns the string "InstancedMesh".
  76675. */
  76676. getClassName(): string;
  76677. /** Gets the list of lights affecting that mesh */
  76678. readonly lightSources: Light[];
  76679. _resyncLightSources(): void;
  76680. _resyncLighSource(light: Light): void;
  76681. _removeLightSource(light: Light): void;
  76682. /**
  76683. * If the source mesh receives shadows
  76684. */
  76685. readonly receiveShadows: boolean;
  76686. /**
  76687. * The material of the source mesh
  76688. */
  76689. readonly material: Nullable<Material>;
  76690. /**
  76691. * Visibility of the source mesh
  76692. */
  76693. readonly visibility: number;
  76694. /**
  76695. * Skeleton of the source mesh
  76696. */
  76697. readonly skeleton: Nullable<Skeleton>;
  76698. /**
  76699. * Rendering ground id of the source mesh
  76700. */
  76701. renderingGroupId: number;
  76702. /**
  76703. * Returns the total number of vertices (integer).
  76704. */
  76705. getTotalVertices(): number;
  76706. /**
  76707. * Returns a positive integer : the total number of indices in this mesh geometry.
  76708. * @returns the numner of indices or zero if the mesh has no geometry.
  76709. */
  76710. getTotalIndices(): number;
  76711. /**
  76712. * The source mesh of the instance
  76713. */
  76714. readonly sourceMesh: Mesh;
  76715. /**
  76716. * Is this node ready to be used/rendered
  76717. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76718. * @return {boolean} is it ready
  76719. */
  76720. isReady(completeCheck?: boolean): boolean;
  76721. /**
  76722. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76723. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76724. * @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.
  76725. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76726. */
  76727. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76728. /**
  76729. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76730. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76731. * The `data` are either a numeric array either a Float32Array.
  76732. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76733. * 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).
  76734. * Note that a new underlying VertexBuffer object is created each call.
  76735. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76736. *
  76737. * Possible `kind` values :
  76738. * - VertexBuffer.PositionKind
  76739. * - VertexBuffer.UVKind
  76740. * - VertexBuffer.UV2Kind
  76741. * - VertexBuffer.UV3Kind
  76742. * - VertexBuffer.UV4Kind
  76743. * - VertexBuffer.UV5Kind
  76744. * - VertexBuffer.UV6Kind
  76745. * - VertexBuffer.ColorKind
  76746. * - VertexBuffer.MatricesIndicesKind
  76747. * - VertexBuffer.MatricesIndicesExtraKind
  76748. * - VertexBuffer.MatricesWeightsKind
  76749. * - VertexBuffer.MatricesWeightsExtraKind
  76750. *
  76751. * Returns the Mesh.
  76752. */
  76753. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76754. /**
  76755. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76756. * If the mesh has no geometry, it is simply returned as it is.
  76757. * The `data` are either a numeric array either a Float32Array.
  76758. * No new underlying VertexBuffer object is created.
  76759. * 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.
  76760. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76761. *
  76762. * Possible `kind` values :
  76763. * - VertexBuffer.PositionKind
  76764. * - VertexBuffer.UVKind
  76765. * - VertexBuffer.UV2Kind
  76766. * - VertexBuffer.UV3Kind
  76767. * - VertexBuffer.UV4Kind
  76768. * - VertexBuffer.UV5Kind
  76769. * - VertexBuffer.UV6Kind
  76770. * - VertexBuffer.ColorKind
  76771. * - VertexBuffer.MatricesIndicesKind
  76772. * - VertexBuffer.MatricesIndicesExtraKind
  76773. * - VertexBuffer.MatricesWeightsKind
  76774. * - VertexBuffer.MatricesWeightsExtraKind
  76775. *
  76776. * Returns the Mesh.
  76777. */
  76778. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76779. /**
  76780. * Sets the mesh indices.
  76781. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76782. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76783. * This method creates a new index buffer each call.
  76784. * Returns the Mesh.
  76785. */
  76786. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76787. /**
  76788. * Boolean : True if the mesh owns the requested kind of data.
  76789. */
  76790. isVerticesDataPresent(kind: string): boolean;
  76791. /**
  76792. * Returns an array of indices (IndicesArray).
  76793. */
  76794. getIndices(): Nullable<IndicesArray>;
  76795. readonly _positions: Nullable<Vector3[]>;
  76796. /**
  76797. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76798. * This means the mesh underlying bounding box and sphere are recomputed.
  76799. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76800. * @returns the current mesh
  76801. */
  76802. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76803. /** @hidden */
  76804. _preActivate(): InstancedMesh;
  76805. /** @hidden */
  76806. _activate(renderId: number): boolean;
  76807. /** @hidden */
  76808. _postActivate(): void;
  76809. getWorldMatrix(): Matrix;
  76810. readonly isAnInstance: boolean;
  76811. /**
  76812. * Returns the current associated LOD AbstractMesh.
  76813. */
  76814. getLOD(camera: Camera): AbstractMesh;
  76815. /** @hidden */
  76816. _syncSubMeshes(): InstancedMesh;
  76817. /** @hidden */
  76818. _generatePointsArray(): boolean;
  76819. /**
  76820. * Creates a new InstancedMesh from the current mesh.
  76821. * - name (string) : the cloned mesh name
  76822. * - newParent (optional Node) : the optional Node to parent the clone to.
  76823. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76824. *
  76825. * Returns the clone.
  76826. */
  76827. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76828. /**
  76829. * Disposes the InstancedMesh.
  76830. * Returns nothing.
  76831. */
  76832. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76833. }
  76834. }
  76835. declare module BABYLON {
  76836. /**
  76837. * Defines the options associated with the creation of a shader material.
  76838. */
  76839. export interface IShaderMaterialOptions {
  76840. /**
  76841. * Does the material work in alpha blend mode
  76842. */
  76843. needAlphaBlending: boolean;
  76844. /**
  76845. * Does the material work in alpha test mode
  76846. */
  76847. needAlphaTesting: boolean;
  76848. /**
  76849. * The list of attribute names used in the shader
  76850. */
  76851. attributes: string[];
  76852. /**
  76853. * The list of unifrom names used in the shader
  76854. */
  76855. uniforms: string[];
  76856. /**
  76857. * The list of UBO names used in the shader
  76858. */
  76859. uniformBuffers: string[];
  76860. /**
  76861. * The list of sampler names used in the shader
  76862. */
  76863. samplers: string[];
  76864. /**
  76865. * The list of defines used in the shader
  76866. */
  76867. defines: string[];
  76868. }
  76869. /**
  76870. * 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.
  76871. *
  76872. * This returned material effects how the mesh will look based on the code in the shaders.
  76873. *
  76874. * @see http://doc.babylonjs.com/how_to/shader_material
  76875. */
  76876. export class ShaderMaterial extends Material {
  76877. private _shaderPath;
  76878. private _options;
  76879. private _textures;
  76880. private _textureArrays;
  76881. private _floats;
  76882. private _ints;
  76883. private _floatsArrays;
  76884. private _colors3;
  76885. private _colors3Arrays;
  76886. private _colors4;
  76887. private _vectors2;
  76888. private _vectors3;
  76889. private _vectors4;
  76890. private _matrices;
  76891. private _matrices3x3;
  76892. private _matrices2x2;
  76893. private _vectors2Arrays;
  76894. private _vectors3Arrays;
  76895. private _cachedWorldViewMatrix;
  76896. private _renderId;
  76897. /**
  76898. * Instantiate a new shader material.
  76899. * 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.
  76900. * This returned material effects how the mesh will look based on the code in the shaders.
  76901. * @see http://doc.babylonjs.com/how_to/shader_material
  76902. * @param name Define the name of the material in the scene
  76903. * @param scene Define the scene the material belongs to
  76904. * @param shaderPath Defines the route to the shader code in one of three ways:
  76905. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76906. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76907. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76908. * @param options Define the options used to create the shader
  76909. */
  76910. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76911. /**
  76912. * Gets the options used to compile the shader.
  76913. * They can be modified to trigger a new compilation
  76914. */
  76915. readonly options: IShaderMaterialOptions;
  76916. /**
  76917. * Gets the current class name of the material e.g. "ShaderMaterial"
  76918. * Mainly use in serialization.
  76919. * @returns the class name
  76920. */
  76921. getClassName(): string;
  76922. /**
  76923. * Specifies if the material will require alpha blending
  76924. * @returns a boolean specifying if alpha blending is needed
  76925. */
  76926. needAlphaBlending(): boolean;
  76927. /**
  76928. * Specifies if this material should be rendered in alpha test mode
  76929. * @returns a boolean specifying if an alpha test is needed.
  76930. */
  76931. needAlphaTesting(): boolean;
  76932. private _checkUniform;
  76933. /**
  76934. * Set a texture in the shader.
  76935. * @param name Define the name of the uniform samplers as defined in the shader
  76936. * @param texture Define the texture to bind to this sampler
  76937. * @return the material itself allowing "fluent" like uniform updates
  76938. */
  76939. setTexture(name: string, texture: Texture): ShaderMaterial;
  76940. /**
  76941. * Set a texture array in the shader.
  76942. * @param name Define the name of the uniform sampler array as defined in the shader
  76943. * @param textures Define the list of textures to bind to this sampler
  76944. * @return the material itself allowing "fluent" like uniform updates
  76945. */
  76946. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76947. /**
  76948. * Set a float in the shader.
  76949. * @param name Define the name of the uniform as defined in the shader
  76950. * @param value Define the value to give to the uniform
  76951. * @return the material itself allowing "fluent" like uniform updates
  76952. */
  76953. setFloat(name: string, value: number): ShaderMaterial;
  76954. /**
  76955. * Set a int in the shader.
  76956. * @param name Define the name of the uniform as defined in the shader
  76957. * @param value Define the value to give to the uniform
  76958. * @return the material itself allowing "fluent" like uniform updates
  76959. */
  76960. setInt(name: string, value: number): ShaderMaterial;
  76961. /**
  76962. * Set an array of floats in the shader.
  76963. * @param name Define the name of the uniform as defined in the shader
  76964. * @param value Define the value to give to the uniform
  76965. * @return the material itself allowing "fluent" like uniform updates
  76966. */
  76967. setFloats(name: string, value: number[]): ShaderMaterial;
  76968. /**
  76969. * Set a vec3 in the shader from a Color3.
  76970. * @param name Define the name of the uniform as defined in the shader
  76971. * @param value Define the value to give to the uniform
  76972. * @return the material itself allowing "fluent" like uniform updates
  76973. */
  76974. setColor3(name: string, value: Color3): ShaderMaterial;
  76975. /**
  76976. * Set a vec3 array in the shader from a Color3 array.
  76977. * @param name Define the name of the uniform as defined in the shader
  76978. * @param value Define the value to give to the uniform
  76979. * @return the material itself allowing "fluent" like uniform updates
  76980. */
  76981. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76982. /**
  76983. * Set a vec4 in the shader from a Color4.
  76984. * @param name Define the name of the uniform as defined in the shader
  76985. * @param value Define the value to give to the uniform
  76986. * @return the material itself allowing "fluent" like uniform updates
  76987. */
  76988. setColor4(name: string, value: Color4): ShaderMaterial;
  76989. /**
  76990. * Set a vec2 in the shader from a Vector2.
  76991. * @param name Define the name of the uniform as defined in the shader
  76992. * @param value Define the value to give to the uniform
  76993. * @return the material itself allowing "fluent" like uniform updates
  76994. */
  76995. setVector2(name: string, value: Vector2): ShaderMaterial;
  76996. /**
  76997. * Set a vec3 in the shader from a Vector3.
  76998. * @param name Define the name of the uniform as defined in the shader
  76999. * @param value Define the value to give to the uniform
  77000. * @return the material itself allowing "fluent" like uniform updates
  77001. */
  77002. setVector3(name: string, value: Vector3): ShaderMaterial;
  77003. /**
  77004. * Set a vec4 in the shader from a Vector4.
  77005. * @param name Define the name of the uniform as defined in the shader
  77006. * @param value Define the value to give to the uniform
  77007. * @return the material itself allowing "fluent" like uniform updates
  77008. */
  77009. setVector4(name: string, value: Vector4): ShaderMaterial;
  77010. /**
  77011. * Set a mat4 in the shader from a Matrix.
  77012. * @param name Define the name of the uniform as defined in the shader
  77013. * @param value Define the value to give to the uniform
  77014. * @return the material itself allowing "fluent" like uniform updates
  77015. */
  77016. setMatrix(name: string, value: Matrix): ShaderMaterial;
  77017. /**
  77018. * Set a mat3 in the shader from a Float32Array.
  77019. * @param name Define the name of the uniform as defined in the shader
  77020. * @param value Define the value to give to the uniform
  77021. * @return the material itself allowing "fluent" like uniform updates
  77022. */
  77023. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  77024. /**
  77025. * Set a mat2 in the shader from a Float32Array.
  77026. * @param name Define the name of the uniform as defined in the shader
  77027. * @param value Define the value to give to the uniform
  77028. * @return the material itself allowing "fluent" like uniform updates
  77029. */
  77030. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  77031. /**
  77032. * Set a vec2 array in the shader from a number array.
  77033. * @param name Define the name of the uniform as defined in the shader
  77034. * @param value Define the value to give to the uniform
  77035. * @return the material itself allowing "fluent" like uniform updates
  77036. */
  77037. setArray2(name: string, value: number[]): ShaderMaterial;
  77038. /**
  77039. * Set a vec3 array in the shader from a number array.
  77040. * @param name Define the name of the uniform as defined in the shader
  77041. * @param value Define the value to give to the uniform
  77042. * @return the material itself allowing "fluent" like uniform updates
  77043. */
  77044. setArray3(name: string, value: number[]): ShaderMaterial;
  77045. private _checkCache;
  77046. /**
  77047. * Specifies that the submesh is ready to be used
  77048. * @param mesh defines the mesh to check
  77049. * @param subMesh defines which submesh to check
  77050. * @param useInstances specifies that instances should be used
  77051. * @returns a boolean indicating that the submesh is ready or not
  77052. */
  77053. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77054. /**
  77055. * Checks if the material is ready to render the requested mesh
  77056. * @param mesh Define the mesh to render
  77057. * @param useInstances Define whether or not the material is used with instances
  77058. * @returns true if ready, otherwise false
  77059. */
  77060. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77061. /**
  77062. * Binds the world matrix to the material
  77063. * @param world defines the world transformation matrix
  77064. */
  77065. bindOnlyWorldMatrix(world: Matrix): void;
  77066. /**
  77067. * Binds the material to the mesh
  77068. * @param world defines the world transformation matrix
  77069. * @param mesh defines the mesh to bind the material to
  77070. */
  77071. bind(world: Matrix, mesh?: Mesh): void;
  77072. /**
  77073. * Gets the active textures from the material
  77074. * @returns an array of textures
  77075. */
  77076. getActiveTextures(): BaseTexture[];
  77077. /**
  77078. * Specifies if the material uses a texture
  77079. * @param texture defines the texture to check against the material
  77080. * @returns a boolean specifying if the material uses the texture
  77081. */
  77082. hasTexture(texture: BaseTexture): boolean;
  77083. /**
  77084. * Makes a duplicate of the material, and gives it a new name
  77085. * @param name defines the new name for the duplicated material
  77086. * @returns the cloned material
  77087. */
  77088. clone(name: string): ShaderMaterial;
  77089. /**
  77090. * Disposes the material
  77091. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77092. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77093. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77094. */
  77095. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77096. /**
  77097. * Serializes this material in a JSON representation
  77098. * @returns the serialized material object
  77099. */
  77100. serialize(): any;
  77101. /**
  77102. * Creates a shader material from parsed shader material data
  77103. * @param source defines the JSON represnetation of the material
  77104. * @param scene defines the hosting scene
  77105. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77106. * @returns a new material
  77107. */
  77108. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  77109. }
  77110. }
  77111. declare module BABYLON {
  77112. /** @hidden */
  77113. export var colorPixelShader: {
  77114. name: string;
  77115. shader: string;
  77116. };
  77117. }
  77118. declare module BABYLON {
  77119. /** @hidden */
  77120. export var colorVertexShader: {
  77121. name: string;
  77122. shader: string;
  77123. };
  77124. }
  77125. declare module BABYLON {
  77126. /**
  77127. * Line mesh
  77128. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  77129. */
  77130. export class LinesMesh extends Mesh {
  77131. /**
  77132. * If vertex color should be applied to the mesh
  77133. */
  77134. useVertexColor?: boolean | undefined;
  77135. /**
  77136. * If vertex alpha should be applied to the mesh
  77137. */
  77138. useVertexAlpha?: boolean | undefined;
  77139. /**
  77140. * Color of the line (Default: White)
  77141. */
  77142. color: Color3;
  77143. /**
  77144. * Alpha of the line (Default: 1)
  77145. */
  77146. alpha: number;
  77147. /**
  77148. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77149. * This margin is expressed in world space coordinates, so its value may vary.
  77150. * Default value is 0.1
  77151. */
  77152. intersectionThreshold: number;
  77153. private _colorShader;
  77154. /**
  77155. * Creates a new LinesMesh
  77156. * @param name defines the name
  77157. * @param scene defines the hosting scene
  77158. * @param parent defines the parent mesh if any
  77159. * @param source defines the optional source LinesMesh used to clone data from
  77160. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77161. * When false, achieved by calling a clone(), also passing False.
  77162. * This will make creation of children, recursive.
  77163. * @param useVertexColor defines if this LinesMesh supports vertex color
  77164. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  77165. */
  77166. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  77167. /**
  77168. * If vertex color should be applied to the mesh
  77169. */
  77170. useVertexColor?: boolean | undefined,
  77171. /**
  77172. * If vertex alpha should be applied to the mesh
  77173. */
  77174. useVertexAlpha?: boolean | undefined);
  77175. private _addClipPlaneDefine;
  77176. private _removeClipPlaneDefine;
  77177. isReady(): boolean;
  77178. /**
  77179. * Returns the string "LineMesh"
  77180. */
  77181. getClassName(): string;
  77182. /**
  77183. * @hidden
  77184. */
  77185. /**
  77186. * @hidden
  77187. */
  77188. material: Material;
  77189. /**
  77190. * @hidden
  77191. */
  77192. readonly checkCollisions: boolean;
  77193. /** @hidden */
  77194. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  77195. /** @hidden */
  77196. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  77197. /**
  77198. * Disposes of the line mesh
  77199. * @param doNotRecurse If children should be disposed
  77200. */
  77201. dispose(doNotRecurse?: boolean): void;
  77202. /**
  77203. * Returns a new LineMesh object cloned from the current one.
  77204. */
  77205. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  77206. /**
  77207. * Creates a new InstancedLinesMesh object from the mesh model.
  77208. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77209. * @param name defines the name of the new instance
  77210. * @returns a new InstancedLinesMesh
  77211. */
  77212. createInstance(name: string): InstancedLinesMesh;
  77213. }
  77214. /**
  77215. * Creates an instance based on a source LinesMesh
  77216. */
  77217. export class InstancedLinesMesh extends InstancedMesh {
  77218. /**
  77219. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77220. * This margin is expressed in world space coordinates, so its value may vary.
  77221. * Initilized with the intersectionThreshold value of the source LinesMesh
  77222. */
  77223. intersectionThreshold: number;
  77224. constructor(name: string, source: LinesMesh);
  77225. /**
  77226. * Returns the string "InstancedLinesMesh".
  77227. */
  77228. getClassName(): string;
  77229. }
  77230. }
  77231. declare module BABYLON {
  77232. /** @hidden */
  77233. export var linePixelShader: {
  77234. name: string;
  77235. shader: string;
  77236. };
  77237. }
  77238. declare module BABYLON {
  77239. /** @hidden */
  77240. export var lineVertexShader: {
  77241. name: string;
  77242. shader: string;
  77243. };
  77244. }
  77245. declare module BABYLON {
  77246. interface AbstractMesh {
  77247. /**
  77248. * Disables the mesh edge rendering mode
  77249. * @returns the currentAbstractMesh
  77250. */
  77251. disableEdgesRendering(): AbstractMesh;
  77252. /**
  77253. * Enables the edge rendering mode on the mesh.
  77254. * This mode makes the mesh edges visible
  77255. * @param epsilon defines the maximal distance between two angles to detect a face
  77256. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77257. * @returns the currentAbstractMesh
  77258. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77259. */
  77260. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77261. /**
  77262. * Gets the edgesRenderer associated with the mesh
  77263. */
  77264. edgesRenderer: Nullable<EdgesRenderer>;
  77265. }
  77266. interface LinesMesh {
  77267. /**
  77268. * Enables the edge rendering mode on the mesh.
  77269. * This mode makes the mesh edges visible
  77270. * @param epsilon defines the maximal distance between two angles to detect a face
  77271. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77272. * @returns the currentAbstractMesh
  77273. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77274. */
  77275. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77276. }
  77277. interface InstancedLinesMesh {
  77278. /**
  77279. * Enables the edge rendering mode on the mesh.
  77280. * This mode makes the mesh edges visible
  77281. * @param epsilon defines the maximal distance between two angles to detect a face
  77282. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77283. * @returns the current InstancedLinesMesh
  77284. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77285. */
  77286. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  77287. }
  77288. /**
  77289. * Defines the minimum contract an Edges renderer should follow.
  77290. */
  77291. export interface IEdgesRenderer extends IDisposable {
  77292. /**
  77293. * Gets or sets a boolean indicating if the edgesRenderer is active
  77294. */
  77295. isEnabled: boolean;
  77296. /**
  77297. * Renders the edges of the attached mesh,
  77298. */
  77299. render(): void;
  77300. /**
  77301. * Checks wether or not the edges renderer is ready to render.
  77302. * @return true if ready, otherwise false.
  77303. */
  77304. isReady(): boolean;
  77305. }
  77306. /**
  77307. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  77308. */
  77309. export class EdgesRenderer implements IEdgesRenderer {
  77310. /**
  77311. * Define the size of the edges with an orthographic camera
  77312. */
  77313. edgesWidthScalerForOrthographic: number;
  77314. /**
  77315. * Define the size of the edges with a perspective camera
  77316. */
  77317. edgesWidthScalerForPerspective: number;
  77318. protected _source: AbstractMesh;
  77319. protected _linesPositions: number[];
  77320. protected _linesNormals: number[];
  77321. protected _linesIndices: number[];
  77322. protected _epsilon: number;
  77323. protected _indicesCount: number;
  77324. protected _lineShader: ShaderMaterial;
  77325. protected _ib: DataBuffer;
  77326. protected _buffers: {
  77327. [key: string]: Nullable<VertexBuffer>;
  77328. };
  77329. protected _checkVerticesInsteadOfIndices: boolean;
  77330. private _meshRebuildObserver;
  77331. private _meshDisposeObserver;
  77332. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77333. isEnabled: boolean;
  77334. /**
  77335. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77336. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77337. * @param source Mesh used to create edges
  77338. * @param epsilon sum of angles in adjacency to check for edge
  77339. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77340. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77341. */
  77342. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77343. protected _prepareRessources(): void;
  77344. /** @hidden */
  77345. _rebuild(): void;
  77346. /**
  77347. * Releases the required resources for the edges renderer
  77348. */
  77349. dispose(): void;
  77350. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77351. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77352. /**
  77353. * Checks if the pair of p0 and p1 is en edge
  77354. * @param faceIndex
  77355. * @param edge
  77356. * @param faceNormals
  77357. * @param p0
  77358. * @param p1
  77359. * @private
  77360. */
  77361. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77362. /**
  77363. * push line into the position, normal and index buffer
  77364. * @protected
  77365. */
  77366. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77367. /**
  77368. * Generates lines edges from adjacencjes
  77369. * @private
  77370. */
  77371. _generateEdgesLines(): void;
  77372. /**
  77373. * Checks wether or not the edges renderer is ready to render.
  77374. * @return true if ready, otherwise false.
  77375. */
  77376. isReady(): boolean;
  77377. /**
  77378. * Renders the edges of the attached mesh,
  77379. */
  77380. render(): void;
  77381. }
  77382. /**
  77383. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77384. */
  77385. export class LineEdgesRenderer extends EdgesRenderer {
  77386. /**
  77387. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77388. * @param source LineMesh used to generate edges
  77389. * @param epsilon not important (specified angle for edge detection)
  77390. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77391. */
  77392. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77393. /**
  77394. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77395. */
  77396. _generateEdgesLines(): void;
  77397. }
  77398. }
  77399. declare module BABYLON {
  77400. /**
  77401. * This represents the object necessary to create a rendering group.
  77402. * This is exclusively used and created by the rendering manager.
  77403. * To modify the behavior, you use the available helpers in your scene or meshes.
  77404. * @hidden
  77405. */
  77406. export class RenderingGroup {
  77407. index: number;
  77408. private _scene;
  77409. private _opaqueSubMeshes;
  77410. private _transparentSubMeshes;
  77411. private _alphaTestSubMeshes;
  77412. private _depthOnlySubMeshes;
  77413. private _particleSystems;
  77414. private _spriteManagers;
  77415. private _opaqueSortCompareFn;
  77416. private _alphaTestSortCompareFn;
  77417. private _transparentSortCompareFn;
  77418. private _renderOpaque;
  77419. private _renderAlphaTest;
  77420. private _renderTransparent;
  77421. /** @hidden */
  77422. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77423. onBeforeTransparentRendering: () => void;
  77424. /**
  77425. * Set the opaque sort comparison function.
  77426. * If null the sub meshes will be render in the order they were created
  77427. */
  77428. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77429. /**
  77430. * Set the alpha test sort comparison function.
  77431. * If null the sub meshes will be render in the order they were created
  77432. */
  77433. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77434. /**
  77435. * Set the transparent sort comparison function.
  77436. * If null the sub meshes will be render in the order they were created
  77437. */
  77438. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77439. /**
  77440. * Creates a new rendering group.
  77441. * @param index The rendering group index
  77442. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77443. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77444. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77445. */
  77446. 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>);
  77447. /**
  77448. * Render all the sub meshes contained in the group.
  77449. * @param customRenderFunction Used to override the default render behaviour of the group.
  77450. * @returns true if rendered some submeshes.
  77451. */
  77452. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77453. /**
  77454. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77455. * @param subMeshes The submeshes to render
  77456. */
  77457. private renderOpaqueSorted;
  77458. /**
  77459. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77460. * @param subMeshes The submeshes to render
  77461. */
  77462. private renderAlphaTestSorted;
  77463. /**
  77464. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77465. * @param subMeshes The submeshes to render
  77466. */
  77467. private renderTransparentSorted;
  77468. /**
  77469. * Renders the submeshes in a specified order.
  77470. * @param subMeshes The submeshes to sort before render
  77471. * @param sortCompareFn The comparison function use to sort
  77472. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77473. * @param transparent Specifies to activate blending if true
  77474. */
  77475. private static renderSorted;
  77476. /**
  77477. * Renders the submeshes in the order they were dispatched (no sort applied).
  77478. * @param subMeshes The submeshes to render
  77479. */
  77480. private static renderUnsorted;
  77481. /**
  77482. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77483. * are rendered back to front if in the same alpha index.
  77484. *
  77485. * @param a The first submesh
  77486. * @param b The second submesh
  77487. * @returns The result of the comparison
  77488. */
  77489. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77490. /**
  77491. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77492. * are rendered back to front.
  77493. *
  77494. * @param a The first submesh
  77495. * @param b The second submesh
  77496. * @returns The result of the comparison
  77497. */
  77498. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77499. /**
  77500. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77501. * are rendered front to back (prevent overdraw).
  77502. *
  77503. * @param a The first submesh
  77504. * @param b The second submesh
  77505. * @returns The result of the comparison
  77506. */
  77507. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77508. /**
  77509. * Resets the different lists of submeshes to prepare a new frame.
  77510. */
  77511. prepare(): void;
  77512. dispose(): void;
  77513. /**
  77514. * Inserts the submesh in its correct queue depending on its material.
  77515. * @param subMesh The submesh to dispatch
  77516. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77517. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77518. */
  77519. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77520. dispatchSprites(spriteManager: ISpriteManager): void;
  77521. dispatchParticles(particleSystem: IParticleSystem): void;
  77522. private _renderParticles;
  77523. private _renderSprites;
  77524. }
  77525. }
  77526. declare module BABYLON {
  77527. /**
  77528. * Interface describing the different options available in the rendering manager
  77529. * regarding Auto Clear between groups.
  77530. */
  77531. export interface IRenderingManagerAutoClearSetup {
  77532. /**
  77533. * Defines whether or not autoclear is enable.
  77534. */
  77535. autoClear: boolean;
  77536. /**
  77537. * Defines whether or not to autoclear the depth buffer.
  77538. */
  77539. depth: boolean;
  77540. /**
  77541. * Defines whether or not to autoclear the stencil buffer.
  77542. */
  77543. stencil: boolean;
  77544. }
  77545. /**
  77546. * This class is used by the onRenderingGroupObservable
  77547. */
  77548. export class RenderingGroupInfo {
  77549. /**
  77550. * The Scene that being rendered
  77551. */
  77552. scene: Scene;
  77553. /**
  77554. * The camera currently used for the rendering pass
  77555. */
  77556. camera: Nullable<Camera>;
  77557. /**
  77558. * The ID of the renderingGroup being processed
  77559. */
  77560. renderingGroupId: number;
  77561. }
  77562. /**
  77563. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77564. * It is enable to manage the different groups as well as the different necessary sort functions.
  77565. * This should not be used directly aside of the few static configurations
  77566. */
  77567. export class RenderingManager {
  77568. /**
  77569. * The max id used for rendering groups (not included)
  77570. */
  77571. static MAX_RENDERINGGROUPS: number;
  77572. /**
  77573. * The min id used for rendering groups (included)
  77574. */
  77575. static MIN_RENDERINGGROUPS: number;
  77576. /**
  77577. * Used to globally prevent autoclearing scenes.
  77578. */
  77579. static AUTOCLEAR: boolean;
  77580. /**
  77581. * @hidden
  77582. */
  77583. _useSceneAutoClearSetup: boolean;
  77584. private _scene;
  77585. private _renderingGroups;
  77586. private _depthStencilBufferAlreadyCleaned;
  77587. private _autoClearDepthStencil;
  77588. private _customOpaqueSortCompareFn;
  77589. private _customAlphaTestSortCompareFn;
  77590. private _customTransparentSortCompareFn;
  77591. private _renderingGroupInfo;
  77592. /**
  77593. * Instantiates a new rendering group for a particular scene
  77594. * @param scene Defines the scene the groups belongs to
  77595. */
  77596. constructor(scene: Scene);
  77597. private _clearDepthStencilBuffer;
  77598. /**
  77599. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77600. * @hidden
  77601. */
  77602. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77603. /**
  77604. * Resets the different information of the group to prepare a new frame
  77605. * @hidden
  77606. */
  77607. reset(): void;
  77608. /**
  77609. * Dispose and release the group and its associated resources.
  77610. * @hidden
  77611. */
  77612. dispose(): void;
  77613. /**
  77614. * Clear the info related to rendering groups preventing retention points during dispose.
  77615. */
  77616. freeRenderingGroups(): void;
  77617. private _prepareRenderingGroup;
  77618. /**
  77619. * Add a sprite manager to the rendering manager in order to render it this frame.
  77620. * @param spriteManager Define the sprite manager to render
  77621. */
  77622. dispatchSprites(spriteManager: ISpriteManager): void;
  77623. /**
  77624. * Add a particle system to the rendering manager in order to render it this frame.
  77625. * @param particleSystem Define the particle system to render
  77626. */
  77627. dispatchParticles(particleSystem: IParticleSystem): void;
  77628. /**
  77629. * Add a submesh to the manager in order to render it this frame
  77630. * @param subMesh The submesh to dispatch
  77631. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77632. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77633. */
  77634. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77635. /**
  77636. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77637. * This allowed control for front to back rendering or reversly depending of the special needs.
  77638. *
  77639. * @param renderingGroupId The rendering group id corresponding to its index
  77640. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77641. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77642. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77643. */
  77644. 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;
  77645. /**
  77646. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77647. *
  77648. * @param renderingGroupId The rendering group id corresponding to its index
  77649. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77650. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77651. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77652. */
  77653. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77654. /**
  77655. * Gets the current auto clear configuration for one rendering group of the rendering
  77656. * manager.
  77657. * @param index the rendering group index to get the information for
  77658. * @returns The auto clear setup for the requested rendering group
  77659. */
  77660. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77661. }
  77662. }
  77663. declare module BABYLON {
  77664. /**
  77665. * This Helps creating a texture that will be created from a camera in your scene.
  77666. * It is basically a dynamic texture that could be used to create special effects for instance.
  77667. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77668. */
  77669. export class RenderTargetTexture extends Texture {
  77670. isCube: boolean;
  77671. /**
  77672. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77673. */
  77674. static readonly REFRESHRATE_RENDER_ONCE: number;
  77675. /**
  77676. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77677. */
  77678. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77679. /**
  77680. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77681. * the central point of your effect and can save a lot of performances.
  77682. */
  77683. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77684. /**
  77685. * Use this predicate to dynamically define the list of mesh you want to render.
  77686. * If set, the renderList property will be overwritten.
  77687. */
  77688. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77689. private _renderList;
  77690. /**
  77691. * Use this list to define the list of mesh you want to render.
  77692. */
  77693. renderList: Nullable<Array<AbstractMesh>>;
  77694. private _hookArray;
  77695. /**
  77696. * Define if particles should be rendered in your texture.
  77697. */
  77698. renderParticles: boolean;
  77699. /**
  77700. * Define if sprites should be rendered in your texture.
  77701. */
  77702. renderSprites: boolean;
  77703. /**
  77704. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77705. */
  77706. coordinatesMode: number;
  77707. /**
  77708. * Define the camera used to render the texture.
  77709. */
  77710. activeCamera: Nullable<Camera>;
  77711. /**
  77712. * Override the render function of the texture with your own one.
  77713. */
  77714. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77715. /**
  77716. * Define if camera post processes should be use while rendering the texture.
  77717. */
  77718. useCameraPostProcesses: boolean;
  77719. /**
  77720. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77721. */
  77722. ignoreCameraViewport: boolean;
  77723. private _postProcessManager;
  77724. private _postProcesses;
  77725. private _resizeObserver;
  77726. /**
  77727. * An event triggered when the texture is unbind.
  77728. */
  77729. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77730. /**
  77731. * An event triggered when the texture is unbind.
  77732. */
  77733. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77734. private _onAfterUnbindObserver;
  77735. /**
  77736. * Set a after unbind callback in the texture.
  77737. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77738. */
  77739. onAfterUnbind: () => void;
  77740. /**
  77741. * An event triggered before rendering the texture
  77742. */
  77743. onBeforeRenderObservable: Observable<number>;
  77744. private _onBeforeRenderObserver;
  77745. /**
  77746. * Set a before render callback in the texture.
  77747. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77748. */
  77749. onBeforeRender: (faceIndex: number) => void;
  77750. /**
  77751. * An event triggered after rendering the texture
  77752. */
  77753. onAfterRenderObservable: Observable<number>;
  77754. private _onAfterRenderObserver;
  77755. /**
  77756. * Set a after render callback in the texture.
  77757. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77758. */
  77759. onAfterRender: (faceIndex: number) => void;
  77760. /**
  77761. * An event triggered after the texture clear
  77762. */
  77763. onClearObservable: Observable<Engine>;
  77764. private _onClearObserver;
  77765. /**
  77766. * Set a clear callback in the texture.
  77767. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77768. */
  77769. onClear: (Engine: Engine) => void;
  77770. /**
  77771. * Define the clear color of the Render Target if it should be different from the scene.
  77772. */
  77773. clearColor: Color4;
  77774. protected _size: number | {
  77775. width: number;
  77776. height: number;
  77777. };
  77778. protected _initialSizeParameter: number | {
  77779. width: number;
  77780. height: number;
  77781. } | {
  77782. ratio: number;
  77783. };
  77784. protected _sizeRatio: Nullable<number>;
  77785. /** @hidden */
  77786. _generateMipMaps: boolean;
  77787. protected _renderingManager: RenderingManager;
  77788. /** @hidden */
  77789. _waitingRenderList: string[];
  77790. protected _doNotChangeAspectRatio: boolean;
  77791. protected _currentRefreshId: number;
  77792. protected _refreshRate: number;
  77793. protected _textureMatrix: Matrix;
  77794. protected _samples: number;
  77795. protected _renderTargetOptions: RenderTargetCreationOptions;
  77796. /**
  77797. * Gets render target creation options that were used.
  77798. */
  77799. readonly renderTargetOptions: RenderTargetCreationOptions;
  77800. protected _engine: Engine;
  77801. protected _onRatioRescale(): void;
  77802. /**
  77803. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77804. * It must define where the camera used to render the texture is set
  77805. */
  77806. boundingBoxPosition: Vector3;
  77807. private _boundingBoxSize;
  77808. /**
  77809. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77810. * When defined, the cubemap will switch to local mode
  77811. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77812. * @example https://www.babylonjs-playground.com/#RNASML
  77813. */
  77814. boundingBoxSize: Vector3;
  77815. /**
  77816. * In case the RTT has been created with a depth texture, get the associated
  77817. * depth texture.
  77818. * Otherwise, return null.
  77819. */
  77820. depthStencilTexture: Nullable<InternalTexture>;
  77821. /**
  77822. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77823. * or used a shadow, depth texture...
  77824. * @param name The friendly name of the texture
  77825. * @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)
  77826. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77827. * @param generateMipMaps True if mip maps need to be generated after render.
  77828. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77829. * @param type The type of the buffer in the RTT (int, half float, float...)
  77830. * @param isCube True if a cube texture needs to be created
  77831. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77832. * @param generateDepthBuffer True to generate a depth buffer
  77833. * @param generateStencilBuffer True to generate a stencil buffer
  77834. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77835. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77836. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77837. */
  77838. constructor(name: string, size: number | {
  77839. width: number;
  77840. height: number;
  77841. } | {
  77842. ratio: number;
  77843. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77844. /**
  77845. * Creates a depth stencil texture.
  77846. * This is only available in WebGL 2 or with the depth texture extension available.
  77847. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77848. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77849. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77850. */
  77851. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77852. private _processSizeParameter;
  77853. /**
  77854. * Define the number of samples to use in case of MSAA.
  77855. * It defaults to one meaning no MSAA has been enabled.
  77856. */
  77857. samples: number;
  77858. /**
  77859. * Resets the refresh counter of the texture and start bak from scratch.
  77860. * Could be useful to regenerate the texture if it is setup to render only once.
  77861. */
  77862. resetRefreshCounter(): void;
  77863. /**
  77864. * Define the refresh rate of the texture or the rendering frequency.
  77865. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77866. */
  77867. refreshRate: number;
  77868. /**
  77869. * Adds a post process to the render target rendering passes.
  77870. * @param postProcess define the post process to add
  77871. */
  77872. addPostProcess(postProcess: PostProcess): void;
  77873. /**
  77874. * Clear all the post processes attached to the render target
  77875. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77876. */
  77877. clearPostProcesses(dispose?: boolean): void;
  77878. /**
  77879. * Remove one of the post process from the list of attached post processes to the texture
  77880. * @param postProcess define the post process to remove from the list
  77881. */
  77882. removePostProcess(postProcess: PostProcess): void;
  77883. /** @hidden */
  77884. _shouldRender(): boolean;
  77885. /**
  77886. * Gets the actual render size of the texture.
  77887. * @returns the width of the render size
  77888. */
  77889. getRenderSize(): number;
  77890. /**
  77891. * Gets the actual render width of the texture.
  77892. * @returns the width of the render size
  77893. */
  77894. getRenderWidth(): number;
  77895. /**
  77896. * Gets the actual render height of the texture.
  77897. * @returns the height of the render size
  77898. */
  77899. getRenderHeight(): number;
  77900. /**
  77901. * Get if the texture can be rescaled or not.
  77902. */
  77903. readonly canRescale: boolean;
  77904. /**
  77905. * Resize the texture using a ratio.
  77906. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77907. */
  77908. scale(ratio: number): void;
  77909. /**
  77910. * Get the texture reflection matrix used to rotate/transform the reflection.
  77911. * @returns the reflection matrix
  77912. */
  77913. getReflectionTextureMatrix(): Matrix;
  77914. /**
  77915. * Resize the texture to a new desired size.
  77916. * Be carrefull as it will recreate all the data in the new texture.
  77917. * @param size Define the new size. It can be:
  77918. * - a number for squared texture,
  77919. * - an object containing { width: number, height: number }
  77920. * - or an object containing a ratio { ratio: number }
  77921. */
  77922. resize(size: number | {
  77923. width: number;
  77924. height: number;
  77925. } | {
  77926. ratio: number;
  77927. }): void;
  77928. /**
  77929. * Renders all the objects from the render list into the texture.
  77930. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77931. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77932. */
  77933. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77934. private _bestReflectionRenderTargetDimension;
  77935. /**
  77936. * @hidden
  77937. * @param faceIndex face index to bind to if this is a cubetexture
  77938. */
  77939. _bindFrameBuffer(faceIndex?: number): void;
  77940. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77941. private renderToTarget;
  77942. /**
  77943. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77944. * This allowed control for front to back rendering or reversly depending of the special needs.
  77945. *
  77946. * @param renderingGroupId The rendering group id corresponding to its index
  77947. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77948. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77949. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77950. */
  77951. 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;
  77952. /**
  77953. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77954. *
  77955. * @param renderingGroupId The rendering group id corresponding to its index
  77956. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77957. */
  77958. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77959. /**
  77960. * Clones the texture.
  77961. * @returns the cloned texture
  77962. */
  77963. clone(): RenderTargetTexture;
  77964. /**
  77965. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77966. * @returns The JSON representation of the texture
  77967. */
  77968. serialize(): any;
  77969. /**
  77970. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77971. */
  77972. disposeFramebufferObjects(): void;
  77973. /**
  77974. * Dispose the texture and release its associated resources.
  77975. */
  77976. dispose(): void;
  77977. /** @hidden */
  77978. _rebuild(): void;
  77979. /**
  77980. * Clear the info related to rendering groups preventing retention point in material dispose.
  77981. */
  77982. freeRenderingGroups(): void;
  77983. /**
  77984. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77985. * @returns the view count
  77986. */
  77987. getViewCount(): number;
  77988. }
  77989. }
  77990. declare module BABYLON {
  77991. /**
  77992. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77993. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77994. * You can then easily use it as a reflectionTexture on a flat surface.
  77995. * In case the surface is not a plane, please consider relying on reflection probes.
  77996. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77997. */
  77998. export class MirrorTexture extends RenderTargetTexture {
  77999. private scene;
  78000. /**
  78001. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  78002. * 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.
  78003. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78004. */
  78005. mirrorPlane: Plane;
  78006. /**
  78007. * Define the blur ratio used to blur the reflection if needed.
  78008. */
  78009. blurRatio: number;
  78010. /**
  78011. * Define the adaptive blur kernel used to blur the reflection if needed.
  78012. * This will autocompute the closest best match for the `blurKernel`
  78013. */
  78014. adaptiveBlurKernel: number;
  78015. /**
  78016. * Define the blur kernel used to blur the reflection if needed.
  78017. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78018. */
  78019. blurKernel: number;
  78020. /**
  78021. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  78022. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78023. */
  78024. blurKernelX: number;
  78025. /**
  78026. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  78027. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78028. */
  78029. blurKernelY: number;
  78030. private _autoComputeBlurKernel;
  78031. protected _onRatioRescale(): void;
  78032. private _updateGammaSpace;
  78033. private _imageProcessingConfigChangeObserver;
  78034. private _transformMatrix;
  78035. private _mirrorMatrix;
  78036. private _savedViewMatrix;
  78037. private _blurX;
  78038. private _blurY;
  78039. private _adaptiveBlurKernel;
  78040. private _blurKernelX;
  78041. private _blurKernelY;
  78042. private _blurRatio;
  78043. /**
  78044. * Instantiates a Mirror Texture.
  78045. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78046. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78047. * You can then easily use it as a reflectionTexture on a flat surface.
  78048. * In case the surface is not a plane, please consider relying on reflection probes.
  78049. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78050. * @param name
  78051. * @param size
  78052. * @param scene
  78053. * @param generateMipMaps
  78054. * @param type
  78055. * @param samplingMode
  78056. * @param generateDepthBuffer
  78057. */
  78058. constructor(name: string, size: number | {
  78059. width: number;
  78060. height: number;
  78061. } | {
  78062. ratio: number;
  78063. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  78064. private _preparePostProcesses;
  78065. /**
  78066. * Clone the mirror texture.
  78067. * @returns the cloned texture
  78068. */
  78069. clone(): MirrorTexture;
  78070. /**
  78071. * Serialize the texture to a JSON representation you could use in Parse later on
  78072. * @returns the serialized JSON representation
  78073. */
  78074. serialize(): any;
  78075. /**
  78076. * Dispose the texture and release its associated resources.
  78077. */
  78078. dispose(): void;
  78079. }
  78080. }
  78081. declare module BABYLON {
  78082. /**
  78083. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78084. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78085. */
  78086. export class Texture extends BaseTexture {
  78087. /** @hidden */
  78088. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78089. /** @hidden */
  78090. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78091. /** @hidden */
  78092. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78093. /** nearest is mag = nearest and min = nearest and mip = linear */
  78094. static readonly NEAREST_SAMPLINGMODE: number;
  78095. /** nearest is mag = nearest and min = nearest and mip = linear */
  78096. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78097. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78098. static readonly BILINEAR_SAMPLINGMODE: number;
  78099. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78100. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78101. /** Trilinear is mag = linear and min = linear and mip = linear */
  78102. static readonly TRILINEAR_SAMPLINGMODE: number;
  78103. /** Trilinear is mag = linear and min = linear and mip = linear */
  78104. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78105. /** mag = nearest and min = nearest and mip = nearest */
  78106. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78107. /** mag = nearest and min = linear and mip = nearest */
  78108. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78109. /** mag = nearest and min = linear and mip = linear */
  78110. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78111. /** mag = nearest and min = linear and mip = none */
  78112. static readonly NEAREST_LINEAR: number;
  78113. /** mag = nearest and min = nearest and mip = none */
  78114. static readonly NEAREST_NEAREST: number;
  78115. /** mag = linear and min = nearest and mip = nearest */
  78116. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78117. /** mag = linear and min = nearest and mip = linear */
  78118. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78119. /** mag = linear and min = linear and mip = none */
  78120. static readonly LINEAR_LINEAR: number;
  78121. /** mag = linear and min = nearest and mip = none */
  78122. static readonly LINEAR_NEAREST: number;
  78123. /** Explicit coordinates mode */
  78124. static readonly EXPLICIT_MODE: number;
  78125. /** Spherical coordinates mode */
  78126. static readonly SPHERICAL_MODE: number;
  78127. /** Planar coordinates mode */
  78128. static readonly PLANAR_MODE: number;
  78129. /** Cubic coordinates mode */
  78130. static readonly CUBIC_MODE: number;
  78131. /** Projection coordinates mode */
  78132. static readonly PROJECTION_MODE: number;
  78133. /** Inverse Cubic coordinates mode */
  78134. static readonly SKYBOX_MODE: number;
  78135. /** Inverse Cubic coordinates mode */
  78136. static readonly INVCUBIC_MODE: number;
  78137. /** Equirectangular coordinates mode */
  78138. static readonly EQUIRECTANGULAR_MODE: number;
  78139. /** Equirectangular Fixed coordinates mode */
  78140. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78141. /** Equirectangular Fixed Mirrored coordinates mode */
  78142. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78143. /** Texture is not repeating outside of 0..1 UVs */
  78144. static readonly CLAMP_ADDRESSMODE: number;
  78145. /** Texture is repeating outside of 0..1 UVs */
  78146. static readonly WRAP_ADDRESSMODE: number;
  78147. /** Texture is repeating and mirrored */
  78148. static readonly MIRROR_ADDRESSMODE: number;
  78149. /**
  78150. * 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
  78151. */
  78152. static UseSerializedUrlIfAny: boolean;
  78153. /**
  78154. * Define the url of the texture.
  78155. */
  78156. url: Nullable<string>;
  78157. /**
  78158. * Define an offset on the texture to offset the u coordinates of the UVs
  78159. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78160. */
  78161. uOffset: number;
  78162. /**
  78163. * Define an offset on the texture to offset the v coordinates of the UVs
  78164. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78165. */
  78166. vOffset: number;
  78167. /**
  78168. * Define an offset on the texture to scale the u coordinates of the UVs
  78169. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78170. */
  78171. uScale: number;
  78172. /**
  78173. * Define an offset on the texture to scale the v coordinates of the UVs
  78174. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78175. */
  78176. vScale: number;
  78177. /**
  78178. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78179. * @see http://doc.babylonjs.com/how_to/more_materials
  78180. */
  78181. uAng: number;
  78182. /**
  78183. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78184. * @see http://doc.babylonjs.com/how_to/more_materials
  78185. */
  78186. vAng: number;
  78187. /**
  78188. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78189. * @see http://doc.babylonjs.com/how_to/more_materials
  78190. */
  78191. wAng: number;
  78192. /**
  78193. * Defines the center of rotation (U)
  78194. */
  78195. uRotationCenter: number;
  78196. /**
  78197. * Defines the center of rotation (V)
  78198. */
  78199. vRotationCenter: number;
  78200. /**
  78201. * Defines the center of rotation (W)
  78202. */
  78203. wRotationCenter: number;
  78204. /**
  78205. * Are mip maps generated for this texture or not.
  78206. */
  78207. readonly noMipmap: boolean;
  78208. /**
  78209. * List of inspectable custom properties (used by the Inspector)
  78210. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78211. */
  78212. inspectableCustomProperties: Nullable<IInspectable[]>;
  78213. private _noMipmap;
  78214. /** @hidden */
  78215. _invertY: boolean;
  78216. private _rowGenerationMatrix;
  78217. private _cachedTextureMatrix;
  78218. private _projectionModeMatrix;
  78219. private _t0;
  78220. private _t1;
  78221. private _t2;
  78222. private _cachedUOffset;
  78223. private _cachedVOffset;
  78224. private _cachedUScale;
  78225. private _cachedVScale;
  78226. private _cachedUAng;
  78227. private _cachedVAng;
  78228. private _cachedWAng;
  78229. private _cachedProjectionMatrixId;
  78230. private _cachedCoordinatesMode;
  78231. /** @hidden */
  78232. protected _initialSamplingMode: number;
  78233. /** @hidden */
  78234. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78235. private _deleteBuffer;
  78236. protected _format: Nullable<number>;
  78237. private _delayedOnLoad;
  78238. private _delayedOnError;
  78239. /**
  78240. * Observable triggered once the texture has been loaded.
  78241. */
  78242. onLoadObservable: Observable<Texture>;
  78243. protected _isBlocking: boolean;
  78244. /**
  78245. * Is the texture preventing material to render while loading.
  78246. * If false, a default texture will be used instead of the loading one during the preparation step.
  78247. */
  78248. isBlocking: boolean;
  78249. /**
  78250. * Get the current sampling mode associated with the texture.
  78251. */
  78252. readonly samplingMode: number;
  78253. /**
  78254. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78255. */
  78256. readonly invertY: boolean;
  78257. /**
  78258. * Instantiates a new texture.
  78259. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78260. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78261. * @param url define the url of the picture to load as a texture
  78262. * @param scene define the scene the texture will belong to
  78263. * @param noMipmap define if the texture will require mip maps or not
  78264. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78265. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78266. * @param onLoad define a callback triggered when the texture has been loaded
  78267. * @param onError define a callback triggered when an error occurred during the loading session
  78268. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78269. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78270. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78271. */
  78272. 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);
  78273. /**
  78274. * Update the url (and optional buffer) of this texture if url was null during construction.
  78275. * @param url the url of the texture
  78276. * @param buffer the buffer of the texture (defaults to null)
  78277. * @param onLoad callback called when the texture is loaded (defaults to null)
  78278. */
  78279. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78280. /**
  78281. * Finish the loading sequence of a texture flagged as delayed load.
  78282. * @hidden
  78283. */
  78284. delayLoad(): void;
  78285. private _prepareRowForTextureGeneration;
  78286. /**
  78287. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78288. * @returns the transform matrix of the texture.
  78289. */
  78290. getTextureMatrix(): Matrix;
  78291. /**
  78292. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78293. * @returns The reflection texture transform
  78294. */
  78295. getReflectionTextureMatrix(): Matrix;
  78296. /**
  78297. * Clones the texture.
  78298. * @returns the cloned texture
  78299. */
  78300. clone(): Texture;
  78301. /**
  78302. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78303. * @returns The JSON representation of the texture
  78304. */
  78305. serialize(): any;
  78306. /**
  78307. * Get the current class name of the texture useful for serialization or dynamic coding.
  78308. * @returns "Texture"
  78309. */
  78310. getClassName(): string;
  78311. /**
  78312. * Dispose the texture and release its associated resources.
  78313. */
  78314. dispose(): void;
  78315. /**
  78316. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78317. * @param parsedTexture Define the JSON representation of the texture
  78318. * @param scene Define the scene the parsed texture should be instantiated in
  78319. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78320. * @returns The parsed texture if successful
  78321. */
  78322. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78323. /**
  78324. * Creates a texture from its base 64 representation.
  78325. * @param data Define the base64 payload without the data: prefix
  78326. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78327. * @param scene Define the scene the texture should belong to
  78328. * @param noMipmap Forces the texture to not create mip map information if true
  78329. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78330. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78331. * @param onLoad define a callback triggered when the texture has been loaded
  78332. * @param onError define a callback triggered when an error occurred during the loading session
  78333. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78334. * @returns the created texture
  78335. */
  78336. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78337. /**
  78338. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78339. * @param data Define the base64 payload without the data: prefix
  78340. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78341. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78342. * @param scene Define the scene the texture should belong to
  78343. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78344. * @param noMipmap Forces the texture to not create mip map information if true
  78345. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78346. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78347. * @param onLoad define a callback triggered when the texture has been loaded
  78348. * @param onError define a callback triggered when an error occurred during the loading session
  78349. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78350. * @returns the created texture
  78351. */
  78352. 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;
  78353. }
  78354. }
  78355. declare module BABYLON {
  78356. interface Engine {
  78357. /**
  78358. * Creates a raw texture
  78359. * @param data defines the data to store in the texture
  78360. * @param width defines the width of the texture
  78361. * @param height defines the height of the texture
  78362. * @param format defines the format of the data
  78363. * @param generateMipMaps defines if the engine should generate the mip levels
  78364. * @param invertY defines if data must be stored with Y axis inverted
  78365. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78366. * @param compression defines the compression used (null by default)
  78367. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78368. * @returns the raw texture inside an InternalTexture
  78369. */
  78370. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78371. /**
  78372. * Update a raw texture
  78373. * @param texture defines the texture to update
  78374. * @param data defines the data to store in the texture
  78375. * @param format defines the format of the data
  78376. * @param invertY defines if data must be stored with Y axis inverted
  78377. */
  78378. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78379. /**
  78380. * Update a raw texture
  78381. * @param texture defines the texture to update
  78382. * @param data defines the data to store in the texture
  78383. * @param format defines the format of the data
  78384. * @param invertY defines if data must be stored with Y axis inverted
  78385. * @param compression defines the compression used (null by default)
  78386. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78387. */
  78388. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78389. /**
  78390. * Creates a new raw cube texture
  78391. * @param data defines the array of data to use to create each face
  78392. * @param size defines the size of the textures
  78393. * @param format defines the format of the data
  78394. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78395. * @param generateMipMaps defines if the engine should generate the mip levels
  78396. * @param invertY defines if data must be stored with Y axis inverted
  78397. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78398. * @param compression defines the compression used (null by default)
  78399. * @returns the cube texture as an InternalTexture
  78400. */
  78401. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78402. /**
  78403. * Update a raw cube texture
  78404. * @param texture defines the texture to udpdate
  78405. * @param data defines the data to store
  78406. * @param format defines the data format
  78407. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78408. * @param invertY defines if data must be stored with Y axis inverted
  78409. */
  78410. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78411. /**
  78412. * Update a raw cube texture
  78413. * @param texture defines the texture to udpdate
  78414. * @param data defines the data to store
  78415. * @param format defines the data format
  78416. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78417. * @param invertY defines if data must be stored with Y axis inverted
  78418. * @param compression defines the compression used (null by default)
  78419. */
  78420. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78421. /**
  78422. * Update a raw cube texture
  78423. * @param texture defines the texture to udpdate
  78424. * @param data defines the data to store
  78425. * @param format defines the data format
  78426. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78427. * @param invertY defines if data must be stored with Y axis inverted
  78428. * @param compression defines the compression used (null by default)
  78429. * @param level defines which level of the texture to update
  78430. */
  78431. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78432. /**
  78433. * Creates a new raw cube texture from a specified url
  78434. * @param url defines the url where the data is located
  78435. * @param scene defines the current scene
  78436. * @param size defines the size of the textures
  78437. * @param format defines the format of the data
  78438. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78439. * @param noMipmap defines if the engine should avoid generating the mip levels
  78440. * @param callback defines a callback used to extract texture data from loaded data
  78441. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78442. * @param onLoad defines a callback called when texture is loaded
  78443. * @param onError defines a callback called if there is an error
  78444. * @returns the cube texture as an InternalTexture
  78445. */
  78446. 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;
  78447. /**
  78448. * Creates a new raw cube texture from a specified url
  78449. * @param url defines the url where the data is located
  78450. * @param scene defines the current scene
  78451. * @param size defines the size of the textures
  78452. * @param format defines the format of the data
  78453. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78454. * @param noMipmap defines if the engine should avoid generating the mip levels
  78455. * @param callback defines a callback used to extract texture data from loaded data
  78456. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78457. * @param onLoad defines a callback called when texture is loaded
  78458. * @param onError defines a callback called if there is an error
  78459. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78460. * @param invertY defines if data must be stored with Y axis inverted
  78461. * @returns the cube texture as an InternalTexture
  78462. */
  78463. 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;
  78464. /**
  78465. * Creates a new raw 3D texture
  78466. * @param data defines the data used to create the texture
  78467. * @param width defines the width of the texture
  78468. * @param height defines the height of the texture
  78469. * @param depth defines the depth of the texture
  78470. * @param format defines the format of the texture
  78471. * @param generateMipMaps defines if the engine must generate mip levels
  78472. * @param invertY defines if data must be stored with Y axis inverted
  78473. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78474. * @param compression defines the compressed used (can be null)
  78475. * @param textureType defines the compressed used (can be null)
  78476. * @returns a new raw 3D texture (stored in an InternalTexture)
  78477. */
  78478. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78479. /**
  78480. * Update a raw 3D texture
  78481. * @param texture defines the texture to update
  78482. * @param data defines the data to store
  78483. * @param format defines the data format
  78484. * @param invertY defines if data must be stored with Y axis inverted
  78485. */
  78486. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78487. /**
  78488. * Update a raw 3D texture
  78489. * @param texture defines the texture to update
  78490. * @param data defines the data to store
  78491. * @param format defines the data format
  78492. * @param invertY defines if data must be stored with Y axis inverted
  78493. * @param compression defines the used compression (can be null)
  78494. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78495. */
  78496. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78497. }
  78498. }
  78499. declare module BABYLON {
  78500. /**
  78501. * Raw texture can help creating a texture directly from an array of data.
  78502. * This can be super useful if you either get the data from an uncompressed source or
  78503. * if you wish to create your texture pixel by pixel.
  78504. */
  78505. export class RawTexture extends Texture {
  78506. /**
  78507. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78508. */
  78509. format: number;
  78510. private _engine;
  78511. /**
  78512. * Instantiates a new RawTexture.
  78513. * Raw texture can help creating a texture directly from an array of data.
  78514. * This can be super useful if you either get the data from an uncompressed source or
  78515. * if you wish to create your texture pixel by pixel.
  78516. * @param data define the array of data to use to create the texture
  78517. * @param width define the width of the texture
  78518. * @param height define the height of the texture
  78519. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78520. * @param scene define the scene the texture belongs to
  78521. * @param generateMipMaps define whether mip maps should be generated or not
  78522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78524. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78525. */
  78526. constructor(data: ArrayBufferView, width: number, height: number,
  78527. /**
  78528. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78529. */
  78530. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78531. /**
  78532. * Updates the texture underlying data.
  78533. * @param data Define the new data of the texture
  78534. */
  78535. update(data: ArrayBufferView): void;
  78536. /**
  78537. * Creates a luminance texture from some data.
  78538. * @param data Define the texture data
  78539. * @param width Define the width of the texture
  78540. * @param height Define the height of the texture
  78541. * @param scene Define the scene the texture belongs to
  78542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78545. * @returns the luminance texture
  78546. */
  78547. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78548. /**
  78549. * Creates a luminance alpha texture from some data.
  78550. * @param data Define the texture data
  78551. * @param width Define the width of the texture
  78552. * @param height Define the height of the texture
  78553. * @param scene Define the scene the texture belongs to
  78554. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78555. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78556. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78557. * @returns the luminance alpha texture
  78558. */
  78559. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78560. /**
  78561. * Creates an alpha texture from some data.
  78562. * @param data Define the texture data
  78563. * @param width Define the width of the texture
  78564. * @param height Define the height of the texture
  78565. * @param scene Define the scene the texture belongs to
  78566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78569. * @returns the alpha texture
  78570. */
  78571. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78572. /**
  78573. * Creates a RGB 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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78582. * @returns the RGB alpha texture
  78583. */
  78584. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78585. /**
  78586. * Creates a RGBA texture from some data.
  78587. * @param data Define the texture data
  78588. * @param width Define the width of the texture
  78589. * @param height Define the height of the texture
  78590. * @param scene Define the scene the texture belongs to
  78591. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78592. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78593. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78594. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78595. * @returns the RGBA texture
  78596. */
  78597. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78598. /**
  78599. * Creates a R texture from some data.
  78600. * @param data Define the texture data
  78601. * @param width Define the width of the texture
  78602. * @param height Define the height of the texture
  78603. * @param scene Define the scene the texture belongs to
  78604. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78605. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78606. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78607. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78608. * @returns the R texture
  78609. */
  78610. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78611. }
  78612. }
  78613. declare module BABYLON {
  78614. /**
  78615. * Defines a runtime animation
  78616. */
  78617. export class RuntimeAnimation {
  78618. private _events;
  78619. /**
  78620. * The current frame of the runtime animation
  78621. */
  78622. private _currentFrame;
  78623. /**
  78624. * The animation used by the runtime animation
  78625. */
  78626. private _animation;
  78627. /**
  78628. * The target of the runtime animation
  78629. */
  78630. private _target;
  78631. /**
  78632. * The initiating animatable
  78633. */
  78634. private _host;
  78635. /**
  78636. * The original value of the runtime animation
  78637. */
  78638. private _originalValue;
  78639. /**
  78640. * The original blend value of the runtime animation
  78641. */
  78642. private _originalBlendValue;
  78643. /**
  78644. * The offsets cache of the runtime animation
  78645. */
  78646. private _offsetsCache;
  78647. /**
  78648. * The high limits cache of the runtime animation
  78649. */
  78650. private _highLimitsCache;
  78651. /**
  78652. * Specifies if the runtime animation has been stopped
  78653. */
  78654. private _stopped;
  78655. /**
  78656. * The blending factor of the runtime animation
  78657. */
  78658. private _blendingFactor;
  78659. /**
  78660. * The BabylonJS scene
  78661. */
  78662. private _scene;
  78663. /**
  78664. * The current value of the runtime animation
  78665. */
  78666. private _currentValue;
  78667. /** @hidden */
  78668. _animationState: _IAnimationState;
  78669. /**
  78670. * The active target of the runtime animation
  78671. */
  78672. private _activeTargets;
  78673. private _currentActiveTarget;
  78674. private _directTarget;
  78675. /**
  78676. * The target path of the runtime animation
  78677. */
  78678. private _targetPath;
  78679. /**
  78680. * The weight of the runtime animation
  78681. */
  78682. private _weight;
  78683. /**
  78684. * The ratio offset of the runtime animation
  78685. */
  78686. private _ratioOffset;
  78687. /**
  78688. * The previous delay of the runtime animation
  78689. */
  78690. private _previousDelay;
  78691. /**
  78692. * The previous ratio of the runtime animation
  78693. */
  78694. private _previousRatio;
  78695. private _enableBlending;
  78696. private _keys;
  78697. private _minFrame;
  78698. private _maxFrame;
  78699. private _minValue;
  78700. private _maxValue;
  78701. private _targetIsArray;
  78702. /**
  78703. * Gets the current frame of the runtime animation
  78704. */
  78705. readonly currentFrame: number;
  78706. /**
  78707. * Gets the weight of the runtime animation
  78708. */
  78709. readonly weight: number;
  78710. /**
  78711. * Gets the current value of the runtime animation
  78712. */
  78713. readonly currentValue: any;
  78714. /**
  78715. * Gets the target path of the runtime animation
  78716. */
  78717. readonly targetPath: string;
  78718. /**
  78719. * Gets the actual target of the runtime animation
  78720. */
  78721. readonly target: any;
  78722. /** @hidden */
  78723. _onLoop: () => void;
  78724. /**
  78725. * Create a new RuntimeAnimation object
  78726. * @param target defines the target of the animation
  78727. * @param animation defines the source animation object
  78728. * @param scene defines the hosting scene
  78729. * @param host defines the initiating Animatable
  78730. */
  78731. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78732. private _preparePath;
  78733. /**
  78734. * Gets the animation from the runtime animation
  78735. */
  78736. readonly animation: Animation;
  78737. /**
  78738. * Resets the runtime animation to the beginning
  78739. * @param restoreOriginal defines whether to restore the target property to the original value
  78740. */
  78741. reset(restoreOriginal?: boolean): void;
  78742. /**
  78743. * Specifies if the runtime animation is stopped
  78744. * @returns Boolean specifying if the runtime animation is stopped
  78745. */
  78746. isStopped(): boolean;
  78747. /**
  78748. * Disposes of the runtime animation
  78749. */
  78750. dispose(): void;
  78751. /**
  78752. * Apply the interpolated value to the target
  78753. * @param currentValue defines the value computed by the animation
  78754. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78755. */
  78756. setValue(currentValue: any, weight: number): void;
  78757. private _getOriginalValues;
  78758. private _setValue;
  78759. /**
  78760. * Gets the loop pmode of the runtime animation
  78761. * @returns Loop Mode
  78762. */
  78763. private _getCorrectLoopMode;
  78764. /**
  78765. * Move the current animation to a given frame
  78766. * @param frame defines the frame to move to
  78767. */
  78768. goToFrame(frame: number): void;
  78769. /**
  78770. * @hidden Internal use only
  78771. */
  78772. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78773. /**
  78774. * Execute the current animation
  78775. * @param delay defines the delay to add to the current frame
  78776. * @param from defines the lower bound of the animation range
  78777. * @param to defines the upper bound of the animation range
  78778. * @param loop defines if the current animation must loop
  78779. * @param speedRatio defines the current speed ratio
  78780. * @param weight defines the weight of the animation (default is -1 so no weight)
  78781. * @param onLoop optional callback called when animation loops
  78782. * @returns a boolean indicating if the animation is running
  78783. */
  78784. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78785. }
  78786. }
  78787. declare module BABYLON {
  78788. /**
  78789. * Class used to store an actual running animation
  78790. */
  78791. export class Animatable {
  78792. /** defines the target object */
  78793. target: any;
  78794. /** defines the starting frame number (default is 0) */
  78795. fromFrame: number;
  78796. /** defines the ending frame number (default is 100) */
  78797. toFrame: number;
  78798. /** defines if the animation must loop (default is false) */
  78799. loopAnimation: boolean;
  78800. /** defines a callback to call when animation ends if it is not looping */
  78801. onAnimationEnd?: (() => void) | null | undefined;
  78802. /** defines a callback to call when animation loops */
  78803. onAnimationLoop?: (() => void) | null | undefined;
  78804. private _localDelayOffset;
  78805. private _pausedDelay;
  78806. private _runtimeAnimations;
  78807. private _paused;
  78808. private _scene;
  78809. private _speedRatio;
  78810. private _weight;
  78811. private _syncRoot;
  78812. /**
  78813. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78814. * This will only apply for non looping animation (default is true)
  78815. */
  78816. disposeOnEnd: boolean;
  78817. /**
  78818. * Gets a boolean indicating if the animation has started
  78819. */
  78820. animationStarted: boolean;
  78821. /**
  78822. * Observer raised when the animation ends
  78823. */
  78824. onAnimationEndObservable: Observable<Animatable>;
  78825. /**
  78826. * Observer raised when the animation loops
  78827. */
  78828. onAnimationLoopObservable: Observable<Animatable>;
  78829. /**
  78830. * Gets the root Animatable used to synchronize and normalize animations
  78831. */
  78832. readonly syncRoot: Nullable<Animatable>;
  78833. /**
  78834. * Gets the current frame of the first RuntimeAnimation
  78835. * Used to synchronize Animatables
  78836. */
  78837. readonly masterFrame: number;
  78838. /**
  78839. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78840. */
  78841. weight: number;
  78842. /**
  78843. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78844. */
  78845. speedRatio: number;
  78846. /**
  78847. * Creates a new Animatable
  78848. * @param scene defines the hosting scene
  78849. * @param target defines the target object
  78850. * @param fromFrame defines the starting frame number (default is 0)
  78851. * @param toFrame defines the ending frame number (default is 100)
  78852. * @param loopAnimation defines if the animation must loop (default is false)
  78853. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78854. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78855. * @param animations defines a group of animation to add to the new Animatable
  78856. * @param onAnimationLoop defines a callback to call when animation loops
  78857. */
  78858. constructor(scene: Scene,
  78859. /** defines the target object */
  78860. target: any,
  78861. /** defines the starting frame number (default is 0) */
  78862. fromFrame?: number,
  78863. /** defines the ending frame number (default is 100) */
  78864. toFrame?: number,
  78865. /** defines if the animation must loop (default is false) */
  78866. loopAnimation?: boolean, speedRatio?: number,
  78867. /** defines a callback to call when animation ends if it is not looping */
  78868. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78869. /** defines a callback to call when animation loops */
  78870. onAnimationLoop?: (() => void) | null | undefined);
  78871. /**
  78872. * Synchronize and normalize current Animatable with a source Animatable
  78873. * This is useful when using animation weights and when animations are not of the same length
  78874. * @param root defines the root Animatable to synchronize with
  78875. * @returns the current Animatable
  78876. */
  78877. syncWith(root: Animatable): Animatable;
  78878. /**
  78879. * Gets the list of runtime animations
  78880. * @returns an array of RuntimeAnimation
  78881. */
  78882. getAnimations(): RuntimeAnimation[];
  78883. /**
  78884. * Adds more animations to the current animatable
  78885. * @param target defines the target of the animations
  78886. * @param animations defines the new animations to add
  78887. */
  78888. appendAnimations(target: any, animations: Animation[]): void;
  78889. /**
  78890. * Gets the source animation for a specific property
  78891. * @param property defines the propertyu to look for
  78892. * @returns null or the source animation for the given property
  78893. */
  78894. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78895. /**
  78896. * Gets the runtime animation for a specific property
  78897. * @param property defines the propertyu to look for
  78898. * @returns null or the runtime animation for the given property
  78899. */
  78900. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78901. /**
  78902. * Resets the animatable to its original state
  78903. */
  78904. reset(): void;
  78905. /**
  78906. * Allows the animatable to blend with current running animations
  78907. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78908. * @param blendingSpeed defines the blending speed to use
  78909. */
  78910. enableBlending(blendingSpeed: number): void;
  78911. /**
  78912. * Disable animation blending
  78913. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78914. */
  78915. disableBlending(): void;
  78916. /**
  78917. * Jump directly to a given frame
  78918. * @param frame defines the frame to jump to
  78919. */
  78920. goToFrame(frame: number): void;
  78921. /**
  78922. * Pause the animation
  78923. */
  78924. pause(): void;
  78925. /**
  78926. * Restart the animation
  78927. */
  78928. restart(): void;
  78929. private _raiseOnAnimationEnd;
  78930. /**
  78931. * Stop and delete the current animation
  78932. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78933. * @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)
  78934. */
  78935. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78936. /**
  78937. * Wait asynchronously for the animation to end
  78938. * @returns a promise which will be fullfilled when the animation ends
  78939. */
  78940. waitAsync(): Promise<Animatable>;
  78941. /** @hidden */
  78942. _animate(delay: number): boolean;
  78943. }
  78944. interface Scene {
  78945. /** @hidden */
  78946. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78947. /** @hidden */
  78948. _processLateAnimationBindingsForMatrices(holder: {
  78949. totalWeight: number;
  78950. animations: RuntimeAnimation[];
  78951. originalValue: Matrix;
  78952. }): any;
  78953. /** @hidden */
  78954. _processLateAnimationBindingsForQuaternions(holder: {
  78955. totalWeight: number;
  78956. animations: RuntimeAnimation[];
  78957. originalValue: Quaternion;
  78958. }, refQuaternion: Quaternion): Quaternion;
  78959. /** @hidden */
  78960. _processLateAnimationBindings(): void;
  78961. /**
  78962. * Will start the animation sequence of a given target
  78963. * @param target defines the target
  78964. * @param from defines from which frame should animation start
  78965. * @param to defines until which frame should animation run.
  78966. * @param weight defines the weight to apply to the animation (1.0 by default)
  78967. * @param loop defines if the animation loops
  78968. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78969. * @param onAnimationEnd defines the function to be executed when the animation ends
  78970. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78971. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78972. * @param onAnimationLoop defines the callback to call when an animation loops
  78973. * @returns the animatable object created for this animation
  78974. */
  78975. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78976. /**
  78977. * Will start the animation sequence of a given target
  78978. * @param target defines the target
  78979. * @param from defines from which frame should animation start
  78980. * @param to defines until which frame should animation run.
  78981. * @param loop defines if the animation loops
  78982. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78983. * @param onAnimationEnd defines the function to be executed when the animation ends
  78984. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78985. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78986. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78987. * @param onAnimationLoop defines the callback to call when an animation loops
  78988. * @returns the animatable object created for this animation
  78989. */
  78990. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78991. /**
  78992. * Will start the animation sequence of a given target and its hierarchy
  78993. * @param target defines the target
  78994. * @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.
  78995. * @param from defines from which frame should animation start
  78996. * @param to defines until which frame should animation run.
  78997. * @param loop defines if the animation loops
  78998. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78999. * @param onAnimationEnd defines the function to be executed when the animation ends
  79000. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79001. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79002. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79003. * @param onAnimationLoop defines the callback to call when an animation loops
  79004. * @returns the list of created animatables
  79005. */
  79006. 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[];
  79007. /**
  79008. * Begin a new animation on a given node
  79009. * @param target defines the target where the animation will take place
  79010. * @param animations defines the list of animations to start
  79011. * @param from defines the initial value
  79012. * @param to defines the final value
  79013. * @param loop defines if you want animation to loop (off by default)
  79014. * @param speedRatio defines the speed ratio to apply to all animations
  79015. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79016. * @param onAnimationLoop defines the callback to call when an animation loops
  79017. * @returns the list of created animatables
  79018. */
  79019. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79020. /**
  79021. * Begin a new animation on a given node and its hierarchy
  79022. * @param target defines the root node where the animation will take place
  79023. * @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.
  79024. * @param animations defines the list of animations to start
  79025. * @param from defines the initial value
  79026. * @param to defines the final value
  79027. * @param loop defines if you want animation to loop (off by default)
  79028. * @param speedRatio defines the speed ratio to apply to all animations
  79029. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79030. * @param onAnimationLoop defines the callback to call when an animation loops
  79031. * @returns the list of animatables created for all nodes
  79032. */
  79033. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79034. /**
  79035. * Gets the animatable associated with a specific target
  79036. * @param target defines the target of the animatable
  79037. * @returns the required animatable if found
  79038. */
  79039. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79040. /**
  79041. * Gets all animatables associated with a given target
  79042. * @param target defines the target to look animatables for
  79043. * @returns an array of Animatables
  79044. */
  79045. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79046. /**
  79047. * Stops and removes all animations that have been applied to the scene
  79048. */
  79049. stopAllAnimations(): void;
  79050. }
  79051. interface Bone {
  79052. /**
  79053. * Copy an animation range from another bone
  79054. * @param source defines the source bone
  79055. * @param rangeName defines the range name to copy
  79056. * @param frameOffset defines the frame offset
  79057. * @param rescaleAsRequired defines if rescaling must be applied if required
  79058. * @param skelDimensionsRatio defines the scaling ratio
  79059. * @returns true if operation was successful
  79060. */
  79061. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79062. }
  79063. }
  79064. declare module BABYLON {
  79065. /**
  79066. * Class used to handle skinning animations
  79067. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79068. */
  79069. export class Skeleton implements IAnimatable {
  79070. /** defines the skeleton name */
  79071. name: string;
  79072. /** defines the skeleton Id */
  79073. id: string;
  79074. /**
  79075. * Defines the list of child bones
  79076. */
  79077. bones: Bone[];
  79078. /**
  79079. * Defines an estimate of the dimension of the skeleton at rest
  79080. */
  79081. dimensionsAtRest: Vector3;
  79082. /**
  79083. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79084. */
  79085. needInitialSkinMatrix: boolean;
  79086. /**
  79087. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79088. */
  79089. overrideMesh: Nullable<AbstractMesh>;
  79090. /**
  79091. * Gets the list of animations attached to this skeleton
  79092. */
  79093. animations: Array<Animation>;
  79094. private _scene;
  79095. private _isDirty;
  79096. private _transformMatrices;
  79097. private _transformMatrixTexture;
  79098. private _meshesWithPoseMatrix;
  79099. private _animatables;
  79100. private _identity;
  79101. private _synchronizedWithMesh;
  79102. private _ranges;
  79103. private _lastAbsoluteTransformsUpdateId;
  79104. private _canUseTextureForBones;
  79105. private _uniqueId;
  79106. /** @hidden */
  79107. _numBonesWithLinkedTransformNode: number;
  79108. /**
  79109. * Specifies if the skeleton should be serialized
  79110. */
  79111. doNotSerialize: boolean;
  79112. private _useTextureToStoreBoneMatrices;
  79113. /**
  79114. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79115. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79116. */
  79117. useTextureToStoreBoneMatrices: boolean;
  79118. private _animationPropertiesOverride;
  79119. /**
  79120. * Gets or sets the animation properties override
  79121. */
  79122. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79123. /**
  79124. * List of inspectable custom properties (used by the Inspector)
  79125. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79126. */
  79127. inspectableCustomProperties: IInspectable[];
  79128. /**
  79129. * An observable triggered before computing the skeleton's matrices
  79130. */
  79131. onBeforeComputeObservable: Observable<Skeleton>;
  79132. /**
  79133. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79134. */
  79135. readonly isUsingTextureForMatrices: boolean;
  79136. /**
  79137. * Gets the unique ID of this skeleton
  79138. */
  79139. readonly uniqueId: number;
  79140. /**
  79141. * Creates a new skeleton
  79142. * @param name defines the skeleton name
  79143. * @param id defines the skeleton Id
  79144. * @param scene defines the hosting scene
  79145. */
  79146. constructor(
  79147. /** defines the skeleton name */
  79148. name: string,
  79149. /** defines the skeleton Id */
  79150. id: string, scene: Scene);
  79151. /**
  79152. * Gets the current object class name.
  79153. * @return the class name
  79154. */
  79155. getClassName(): string;
  79156. /**
  79157. * Returns an array containing the root bones
  79158. * @returns an array containing the root bones
  79159. */
  79160. getChildren(): Array<Bone>;
  79161. /**
  79162. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79163. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79164. * @returns a Float32Array containing matrices data
  79165. */
  79166. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79167. /**
  79168. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79169. * @returns a raw texture containing the data
  79170. */
  79171. getTransformMatrixTexture(): Nullable<RawTexture>;
  79172. /**
  79173. * Gets the current hosting scene
  79174. * @returns a scene object
  79175. */
  79176. getScene(): Scene;
  79177. /**
  79178. * Gets a string representing the current skeleton data
  79179. * @param fullDetails defines a boolean indicating if we want a verbose version
  79180. * @returns a string representing the current skeleton data
  79181. */
  79182. toString(fullDetails?: boolean): string;
  79183. /**
  79184. * Get bone's index searching by name
  79185. * @param name defines bone's name to search for
  79186. * @return the indice of the bone. Returns -1 if not found
  79187. */
  79188. getBoneIndexByName(name: string): number;
  79189. /**
  79190. * Creater a new animation range
  79191. * @param name defines the name of the range
  79192. * @param from defines the start key
  79193. * @param to defines the end key
  79194. */
  79195. createAnimationRange(name: string, from: number, to: number): void;
  79196. /**
  79197. * Delete a specific animation range
  79198. * @param name defines the name of the range
  79199. * @param deleteFrames defines if frames must be removed as well
  79200. */
  79201. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79202. /**
  79203. * Gets a specific animation range
  79204. * @param name defines the name of the range to look for
  79205. * @returns the requested animation range or null if not found
  79206. */
  79207. getAnimationRange(name: string): Nullable<AnimationRange>;
  79208. /**
  79209. * Gets the list of all animation ranges defined on this skeleton
  79210. * @returns an array
  79211. */
  79212. getAnimationRanges(): Nullable<AnimationRange>[];
  79213. /**
  79214. * Copy animation range from a source skeleton.
  79215. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79216. * @param source defines the source skeleton
  79217. * @param name defines the name of the range to copy
  79218. * @param rescaleAsRequired defines if rescaling must be applied if required
  79219. * @returns true if operation was successful
  79220. */
  79221. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79222. /**
  79223. * Forces the skeleton to go to rest pose
  79224. */
  79225. returnToRest(): void;
  79226. private _getHighestAnimationFrame;
  79227. /**
  79228. * Begin a specific animation range
  79229. * @param name defines the name of the range to start
  79230. * @param loop defines if looping must be turned on (false by default)
  79231. * @param speedRatio defines the speed ratio to apply (1 by default)
  79232. * @param onAnimationEnd defines a callback which will be called when animation will end
  79233. * @returns a new animatable
  79234. */
  79235. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79236. /** @hidden */
  79237. _markAsDirty(): void;
  79238. /** @hidden */
  79239. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79240. /** @hidden */
  79241. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79242. private _computeTransformMatrices;
  79243. /**
  79244. * Build all resources required to render a skeleton
  79245. */
  79246. prepare(): void;
  79247. /**
  79248. * Gets the list of animatables currently running for this skeleton
  79249. * @returns an array of animatables
  79250. */
  79251. getAnimatables(): IAnimatable[];
  79252. /**
  79253. * Clone the current skeleton
  79254. * @param name defines the name of the new skeleton
  79255. * @param id defines the id of the new skeleton
  79256. * @returns the new skeleton
  79257. */
  79258. clone(name: string, id: string): Skeleton;
  79259. /**
  79260. * Enable animation blending for this skeleton
  79261. * @param blendingSpeed defines the blending speed to apply
  79262. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79263. */
  79264. enableBlending(blendingSpeed?: number): void;
  79265. /**
  79266. * Releases all resources associated with the current skeleton
  79267. */
  79268. dispose(): void;
  79269. /**
  79270. * Serialize the skeleton in a JSON object
  79271. * @returns a JSON object
  79272. */
  79273. serialize(): any;
  79274. /**
  79275. * Creates a new skeleton from serialized data
  79276. * @param parsedSkeleton defines the serialized data
  79277. * @param scene defines the hosting scene
  79278. * @returns a new skeleton
  79279. */
  79280. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79281. /**
  79282. * Compute all node absolute transforms
  79283. * @param forceUpdate defines if computation must be done even if cache is up to date
  79284. */
  79285. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79286. /**
  79287. * Gets the root pose matrix
  79288. * @returns a matrix
  79289. */
  79290. getPoseMatrix(): Nullable<Matrix>;
  79291. /**
  79292. * Sorts bones per internal index
  79293. */
  79294. sortBones(): void;
  79295. private _sortBones;
  79296. }
  79297. }
  79298. declare module BABYLON {
  79299. /**
  79300. * Defines a target to use with MorphTargetManager
  79301. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79302. */
  79303. export class MorphTarget implements IAnimatable {
  79304. /** defines the name of the target */
  79305. name: string;
  79306. /**
  79307. * Gets or sets the list of animations
  79308. */
  79309. animations: Animation[];
  79310. private _scene;
  79311. private _positions;
  79312. private _normals;
  79313. private _tangents;
  79314. private _influence;
  79315. /**
  79316. * Observable raised when the influence changes
  79317. */
  79318. onInfluenceChanged: Observable<boolean>;
  79319. /** @hidden */
  79320. _onDataLayoutChanged: Observable<void>;
  79321. /**
  79322. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79323. */
  79324. influence: number;
  79325. /**
  79326. * Gets or sets the id of the morph Target
  79327. */
  79328. id: string;
  79329. private _animationPropertiesOverride;
  79330. /**
  79331. * Gets or sets the animation properties override
  79332. */
  79333. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79334. /**
  79335. * Creates a new MorphTarget
  79336. * @param name defines the name of the target
  79337. * @param influence defines the influence to use
  79338. * @param scene defines the scene the morphtarget belongs to
  79339. */
  79340. constructor(
  79341. /** defines the name of the target */
  79342. name: string, influence?: number, scene?: Nullable<Scene>);
  79343. /**
  79344. * Gets a boolean defining if the target contains position data
  79345. */
  79346. readonly hasPositions: boolean;
  79347. /**
  79348. * Gets a boolean defining if the target contains normal data
  79349. */
  79350. readonly hasNormals: boolean;
  79351. /**
  79352. * Gets a boolean defining if the target contains tangent data
  79353. */
  79354. readonly hasTangents: boolean;
  79355. /**
  79356. * Affects position data to this target
  79357. * @param data defines the position data to use
  79358. */
  79359. setPositions(data: Nullable<FloatArray>): void;
  79360. /**
  79361. * Gets the position data stored in this target
  79362. * @returns a FloatArray containing the position data (or null if not present)
  79363. */
  79364. getPositions(): Nullable<FloatArray>;
  79365. /**
  79366. * Affects normal data to this target
  79367. * @param data defines the normal data to use
  79368. */
  79369. setNormals(data: Nullable<FloatArray>): void;
  79370. /**
  79371. * Gets the normal data stored in this target
  79372. * @returns a FloatArray containing the normal data (or null if not present)
  79373. */
  79374. getNormals(): Nullable<FloatArray>;
  79375. /**
  79376. * Affects tangent data to this target
  79377. * @param data defines the tangent data to use
  79378. */
  79379. setTangents(data: Nullable<FloatArray>): void;
  79380. /**
  79381. * Gets the tangent data stored in this target
  79382. * @returns a FloatArray containing the tangent data (or null if not present)
  79383. */
  79384. getTangents(): Nullable<FloatArray>;
  79385. /**
  79386. * Serializes the current target into a Serialization object
  79387. * @returns the serialized object
  79388. */
  79389. serialize(): any;
  79390. /**
  79391. * Returns the string "MorphTarget"
  79392. * @returns "MorphTarget"
  79393. */
  79394. getClassName(): string;
  79395. /**
  79396. * Creates a new target from serialized data
  79397. * @param serializationObject defines the serialized data to use
  79398. * @returns a new MorphTarget
  79399. */
  79400. static Parse(serializationObject: any): MorphTarget;
  79401. /**
  79402. * Creates a MorphTarget from mesh data
  79403. * @param mesh defines the source mesh
  79404. * @param name defines the name to use for the new target
  79405. * @param influence defines the influence to attach to the target
  79406. * @returns a new MorphTarget
  79407. */
  79408. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79409. }
  79410. }
  79411. declare module BABYLON {
  79412. /**
  79413. * This class is used to deform meshes using morphing between different targets
  79414. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79415. */
  79416. export class MorphTargetManager {
  79417. private _targets;
  79418. private _targetInfluenceChangedObservers;
  79419. private _targetDataLayoutChangedObservers;
  79420. private _activeTargets;
  79421. private _scene;
  79422. private _influences;
  79423. private _supportsNormals;
  79424. private _supportsTangents;
  79425. private _vertexCount;
  79426. private _uniqueId;
  79427. private _tempInfluences;
  79428. /**
  79429. * Creates a new MorphTargetManager
  79430. * @param scene defines the current scene
  79431. */
  79432. constructor(scene?: Nullable<Scene>);
  79433. /**
  79434. * Gets the unique ID of this manager
  79435. */
  79436. readonly uniqueId: number;
  79437. /**
  79438. * Gets the number of vertices handled by this manager
  79439. */
  79440. readonly vertexCount: number;
  79441. /**
  79442. * Gets a boolean indicating if this manager supports morphing of normals
  79443. */
  79444. readonly supportsNormals: boolean;
  79445. /**
  79446. * Gets a boolean indicating if this manager supports morphing of tangents
  79447. */
  79448. readonly supportsTangents: boolean;
  79449. /**
  79450. * Gets the number of targets stored in this manager
  79451. */
  79452. readonly numTargets: number;
  79453. /**
  79454. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79455. */
  79456. readonly numInfluencers: number;
  79457. /**
  79458. * Gets the list of influences (one per target)
  79459. */
  79460. readonly influences: Float32Array;
  79461. /**
  79462. * Gets the active target at specified index. An active target is a target with an influence > 0
  79463. * @param index defines the index to check
  79464. * @returns the requested target
  79465. */
  79466. getActiveTarget(index: number): MorphTarget;
  79467. /**
  79468. * Gets the target at specified index
  79469. * @param index defines the index to check
  79470. * @returns the requested target
  79471. */
  79472. getTarget(index: number): MorphTarget;
  79473. /**
  79474. * Add a new target to this manager
  79475. * @param target defines the target to add
  79476. */
  79477. addTarget(target: MorphTarget): void;
  79478. /**
  79479. * Removes a target from the manager
  79480. * @param target defines the target to remove
  79481. */
  79482. removeTarget(target: MorphTarget): void;
  79483. /**
  79484. * Serializes the current manager into a Serialization object
  79485. * @returns the serialized object
  79486. */
  79487. serialize(): any;
  79488. private _syncActiveTargets;
  79489. /**
  79490. * Syncrhonize the targets with all the meshes using this morph target manager
  79491. */
  79492. synchronize(): void;
  79493. /**
  79494. * Creates a new MorphTargetManager from serialized data
  79495. * @param serializationObject defines the serialized data
  79496. * @param scene defines the hosting scene
  79497. * @returns the new MorphTargetManager
  79498. */
  79499. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79500. }
  79501. }
  79502. declare module BABYLON {
  79503. /**
  79504. * Class used to represent a specific level of detail of a mesh
  79505. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79506. */
  79507. export class MeshLODLevel {
  79508. /** Defines the distance where this level should star being displayed */
  79509. distance: number;
  79510. /** Defines the mesh to use to render this level */
  79511. mesh: Nullable<Mesh>;
  79512. /**
  79513. * Creates a new LOD level
  79514. * @param distance defines the distance where this level should star being displayed
  79515. * @param mesh defines the mesh to use to render this level
  79516. */
  79517. constructor(
  79518. /** Defines the distance where this level should star being displayed */
  79519. distance: number,
  79520. /** Defines the mesh to use to render this level */
  79521. mesh: Nullable<Mesh>);
  79522. }
  79523. }
  79524. declare module BABYLON {
  79525. /**
  79526. * Mesh representing the gorund
  79527. */
  79528. export class GroundMesh extends Mesh {
  79529. /** If octree should be generated */
  79530. generateOctree: boolean;
  79531. private _heightQuads;
  79532. /** @hidden */
  79533. _subdivisionsX: number;
  79534. /** @hidden */
  79535. _subdivisionsY: number;
  79536. /** @hidden */
  79537. _width: number;
  79538. /** @hidden */
  79539. _height: number;
  79540. /** @hidden */
  79541. _minX: number;
  79542. /** @hidden */
  79543. _maxX: number;
  79544. /** @hidden */
  79545. _minZ: number;
  79546. /** @hidden */
  79547. _maxZ: number;
  79548. constructor(name: string, scene: Scene);
  79549. /**
  79550. * "GroundMesh"
  79551. * @returns "GroundMesh"
  79552. */
  79553. getClassName(): string;
  79554. /**
  79555. * The minimum of x and y subdivisions
  79556. */
  79557. readonly subdivisions: number;
  79558. /**
  79559. * X subdivisions
  79560. */
  79561. readonly subdivisionsX: number;
  79562. /**
  79563. * Y subdivisions
  79564. */
  79565. readonly subdivisionsY: number;
  79566. /**
  79567. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79568. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79569. * @param chunksCount the number of subdivisions for x and y
  79570. * @param octreeBlocksSize (Default: 32)
  79571. */
  79572. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79573. /**
  79574. * Returns a height (y) value in the Worl system :
  79575. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79576. * @param x x coordinate
  79577. * @param z z coordinate
  79578. * @returns the ground y position if (x, z) are outside the ground surface.
  79579. */
  79580. getHeightAtCoordinates(x: number, z: number): number;
  79581. /**
  79582. * Returns a normalized vector (Vector3) orthogonal to the ground
  79583. * at the ground coordinates (x, z) expressed in the World system.
  79584. * @param x x coordinate
  79585. * @param z z coordinate
  79586. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79587. */
  79588. getNormalAtCoordinates(x: number, z: number): Vector3;
  79589. /**
  79590. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79591. * at the ground coordinates (x, z) expressed in the World system.
  79592. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79593. * @param x x coordinate
  79594. * @param z z coordinate
  79595. * @param ref vector to store the result
  79596. * @returns the GroundMesh.
  79597. */
  79598. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79599. /**
  79600. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79601. * if the ground has been updated.
  79602. * This can be used in the render loop.
  79603. * @returns the GroundMesh.
  79604. */
  79605. updateCoordinateHeights(): GroundMesh;
  79606. private _getFacetAt;
  79607. private _initHeightQuads;
  79608. private _computeHeightQuads;
  79609. /**
  79610. * Serializes this ground mesh
  79611. * @param serializationObject object to write serialization to
  79612. */
  79613. serialize(serializationObject: any): void;
  79614. /**
  79615. * Parses a serialized ground mesh
  79616. * @param parsedMesh the serialized mesh
  79617. * @param scene the scene to create the ground mesh in
  79618. * @returns the created ground mesh
  79619. */
  79620. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79621. }
  79622. }
  79623. declare module BABYLON {
  79624. /**
  79625. * Interface for Physics-Joint data
  79626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79627. */
  79628. export interface PhysicsJointData {
  79629. /**
  79630. * The main pivot of the joint
  79631. */
  79632. mainPivot?: Vector3;
  79633. /**
  79634. * The connected pivot of the joint
  79635. */
  79636. connectedPivot?: Vector3;
  79637. /**
  79638. * The main axis of the joint
  79639. */
  79640. mainAxis?: Vector3;
  79641. /**
  79642. * The connected axis of the joint
  79643. */
  79644. connectedAxis?: Vector3;
  79645. /**
  79646. * The collision of the joint
  79647. */
  79648. collision?: boolean;
  79649. /**
  79650. * Native Oimo/Cannon/Energy data
  79651. */
  79652. nativeParams?: any;
  79653. }
  79654. /**
  79655. * This is a holder class for the physics joint created by the physics plugin
  79656. * It holds a set of functions to control the underlying joint
  79657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79658. */
  79659. export class PhysicsJoint {
  79660. /**
  79661. * The type of the physics joint
  79662. */
  79663. type: number;
  79664. /**
  79665. * The data for the physics joint
  79666. */
  79667. jointData: PhysicsJointData;
  79668. private _physicsJoint;
  79669. protected _physicsPlugin: IPhysicsEnginePlugin;
  79670. /**
  79671. * Initializes the physics joint
  79672. * @param type The type of the physics joint
  79673. * @param jointData The data for the physics joint
  79674. */
  79675. constructor(
  79676. /**
  79677. * The type of the physics joint
  79678. */
  79679. type: number,
  79680. /**
  79681. * The data for the physics joint
  79682. */
  79683. jointData: PhysicsJointData);
  79684. /**
  79685. * Gets the physics joint
  79686. */
  79687. /**
  79688. * Sets the physics joint
  79689. */
  79690. physicsJoint: any;
  79691. /**
  79692. * Sets the physics plugin
  79693. */
  79694. physicsPlugin: IPhysicsEnginePlugin;
  79695. /**
  79696. * Execute a function that is physics-plugin specific.
  79697. * @param {Function} func the function that will be executed.
  79698. * It accepts two parameters: the physics world and the physics joint
  79699. */
  79700. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79701. /**
  79702. * Distance-Joint type
  79703. */
  79704. static DistanceJoint: number;
  79705. /**
  79706. * Hinge-Joint type
  79707. */
  79708. static HingeJoint: number;
  79709. /**
  79710. * Ball-and-Socket joint type
  79711. */
  79712. static BallAndSocketJoint: number;
  79713. /**
  79714. * Wheel-Joint type
  79715. */
  79716. static WheelJoint: number;
  79717. /**
  79718. * Slider-Joint type
  79719. */
  79720. static SliderJoint: number;
  79721. /**
  79722. * Prismatic-Joint type
  79723. */
  79724. static PrismaticJoint: number;
  79725. /**
  79726. * Universal-Joint type
  79727. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79728. */
  79729. static UniversalJoint: number;
  79730. /**
  79731. * Hinge-Joint 2 type
  79732. */
  79733. static Hinge2Joint: number;
  79734. /**
  79735. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79736. */
  79737. static PointToPointJoint: number;
  79738. /**
  79739. * Spring-Joint type
  79740. */
  79741. static SpringJoint: number;
  79742. /**
  79743. * Lock-Joint type
  79744. */
  79745. static LockJoint: number;
  79746. }
  79747. /**
  79748. * A class representing a physics distance joint
  79749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79750. */
  79751. export class DistanceJoint extends PhysicsJoint {
  79752. /**
  79753. *
  79754. * @param jointData The data for the Distance-Joint
  79755. */
  79756. constructor(jointData: DistanceJointData);
  79757. /**
  79758. * Update the predefined distance.
  79759. * @param maxDistance The maximum preferred distance
  79760. * @param minDistance The minimum preferred distance
  79761. */
  79762. updateDistance(maxDistance: number, minDistance?: number): void;
  79763. }
  79764. /**
  79765. * Represents a Motor-Enabled Joint
  79766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79767. */
  79768. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79769. /**
  79770. * Initializes the Motor-Enabled Joint
  79771. * @param type The type of the joint
  79772. * @param jointData The physica joint data for the joint
  79773. */
  79774. constructor(type: number, jointData: PhysicsJointData);
  79775. /**
  79776. * Set the motor values.
  79777. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79778. * @param force the force to apply
  79779. * @param maxForce max force for this motor.
  79780. */
  79781. setMotor(force?: number, maxForce?: number): void;
  79782. /**
  79783. * Set the motor's limits.
  79784. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79785. * @param upperLimit The upper limit of the motor
  79786. * @param lowerLimit The lower limit of the motor
  79787. */
  79788. setLimit(upperLimit: number, lowerLimit?: number): void;
  79789. }
  79790. /**
  79791. * This class represents a single physics Hinge-Joint
  79792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79793. */
  79794. export class HingeJoint extends MotorEnabledJoint {
  79795. /**
  79796. * Initializes the Hinge-Joint
  79797. * @param jointData The joint data for the Hinge-Joint
  79798. */
  79799. constructor(jointData: PhysicsJointData);
  79800. /**
  79801. * Set the motor values.
  79802. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79803. * @param {number} force the force to apply
  79804. * @param {number} maxForce max force for this motor.
  79805. */
  79806. setMotor(force?: number, maxForce?: number): void;
  79807. /**
  79808. * Set the motor's limits.
  79809. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79810. * @param upperLimit The upper limit of the motor
  79811. * @param lowerLimit The lower limit of the motor
  79812. */
  79813. setLimit(upperLimit: number, lowerLimit?: number): void;
  79814. }
  79815. /**
  79816. * This class represents a dual hinge physics joint (same as wheel joint)
  79817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79818. */
  79819. export class Hinge2Joint extends MotorEnabledJoint {
  79820. /**
  79821. * Initializes the Hinge2-Joint
  79822. * @param jointData The joint data for the Hinge2-Joint
  79823. */
  79824. constructor(jointData: PhysicsJointData);
  79825. /**
  79826. * Set the motor values.
  79827. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79828. * @param {number} targetSpeed the speed the motor is to reach
  79829. * @param {number} maxForce max force for this motor.
  79830. * @param {motorIndex} the motor's index, 0 or 1.
  79831. */
  79832. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79833. /**
  79834. * Set the motor limits.
  79835. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79836. * @param {number} upperLimit the upper limit
  79837. * @param {number} lowerLimit lower limit
  79838. * @param {motorIndex} the motor's index, 0 or 1.
  79839. */
  79840. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79841. }
  79842. /**
  79843. * Interface for a motor enabled joint
  79844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79845. */
  79846. export interface IMotorEnabledJoint {
  79847. /**
  79848. * Physics joint
  79849. */
  79850. physicsJoint: any;
  79851. /**
  79852. * Sets the motor of the motor-enabled joint
  79853. * @param force The force of the motor
  79854. * @param maxForce The maximum force of the motor
  79855. * @param motorIndex The index of the motor
  79856. */
  79857. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79858. /**
  79859. * Sets the limit of the motor
  79860. * @param upperLimit The upper limit of the motor
  79861. * @param lowerLimit The lower limit of the motor
  79862. * @param motorIndex The index of the motor
  79863. */
  79864. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79865. }
  79866. /**
  79867. * Joint data for a Distance-Joint
  79868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79869. */
  79870. export interface DistanceJointData extends PhysicsJointData {
  79871. /**
  79872. * Max distance the 2 joint objects can be apart
  79873. */
  79874. maxDistance: number;
  79875. }
  79876. /**
  79877. * Joint data from a spring joint
  79878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79879. */
  79880. export interface SpringJointData extends PhysicsJointData {
  79881. /**
  79882. * Length of the spring
  79883. */
  79884. length: number;
  79885. /**
  79886. * Stiffness of the spring
  79887. */
  79888. stiffness: number;
  79889. /**
  79890. * Damping of the spring
  79891. */
  79892. damping: number;
  79893. /** this callback will be called when applying the force to the impostors. */
  79894. forceApplicationCallback: () => void;
  79895. }
  79896. }
  79897. declare module BABYLON {
  79898. /**
  79899. * Holds the data for the raycast result
  79900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79901. */
  79902. export class PhysicsRaycastResult {
  79903. private _hasHit;
  79904. private _hitDistance;
  79905. private _hitNormalWorld;
  79906. private _hitPointWorld;
  79907. private _rayFromWorld;
  79908. private _rayToWorld;
  79909. /**
  79910. * Gets if there was a hit
  79911. */
  79912. readonly hasHit: boolean;
  79913. /**
  79914. * Gets the distance from the hit
  79915. */
  79916. readonly hitDistance: number;
  79917. /**
  79918. * Gets the hit normal/direction in the world
  79919. */
  79920. readonly hitNormalWorld: Vector3;
  79921. /**
  79922. * Gets the hit point in the world
  79923. */
  79924. readonly hitPointWorld: Vector3;
  79925. /**
  79926. * Gets the ray "start point" of the ray in the world
  79927. */
  79928. readonly rayFromWorld: Vector3;
  79929. /**
  79930. * Gets the ray "end point" of the ray in the world
  79931. */
  79932. readonly rayToWorld: Vector3;
  79933. /**
  79934. * Sets the hit data (normal & point in world space)
  79935. * @param hitNormalWorld defines the normal in world space
  79936. * @param hitPointWorld defines the point in world space
  79937. */
  79938. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79939. /**
  79940. * Sets the distance from the start point to the hit point
  79941. * @param distance
  79942. */
  79943. setHitDistance(distance: number): void;
  79944. /**
  79945. * Calculates the distance manually
  79946. */
  79947. calculateHitDistance(): void;
  79948. /**
  79949. * Resets all the values to default
  79950. * @param from The from point on world space
  79951. * @param to The to point on world space
  79952. */
  79953. reset(from?: Vector3, to?: Vector3): void;
  79954. }
  79955. /**
  79956. * Interface for the size containing width and height
  79957. */
  79958. interface IXYZ {
  79959. /**
  79960. * X
  79961. */
  79962. x: number;
  79963. /**
  79964. * Y
  79965. */
  79966. y: number;
  79967. /**
  79968. * Z
  79969. */
  79970. z: number;
  79971. }
  79972. }
  79973. declare module BABYLON {
  79974. /**
  79975. * Interface used to describe a physics joint
  79976. */
  79977. export interface PhysicsImpostorJoint {
  79978. /** Defines the main impostor to which the joint is linked */
  79979. mainImpostor: PhysicsImpostor;
  79980. /** Defines the impostor that is connected to the main impostor using this joint */
  79981. connectedImpostor: PhysicsImpostor;
  79982. /** Defines the joint itself */
  79983. joint: PhysicsJoint;
  79984. }
  79985. /** @hidden */
  79986. export interface IPhysicsEnginePlugin {
  79987. world: any;
  79988. name: string;
  79989. setGravity(gravity: Vector3): void;
  79990. setTimeStep(timeStep: number): void;
  79991. getTimeStep(): number;
  79992. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79993. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79994. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79995. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79996. removePhysicsBody(impostor: PhysicsImpostor): void;
  79997. generateJoint(joint: PhysicsImpostorJoint): void;
  79998. removeJoint(joint: PhysicsImpostorJoint): void;
  79999. isSupported(): boolean;
  80000. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  80001. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  80002. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80003. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80004. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80005. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80006. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  80007. getBodyMass(impostor: PhysicsImpostor): number;
  80008. getBodyFriction(impostor: PhysicsImpostor): number;
  80009. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  80010. getBodyRestitution(impostor: PhysicsImpostor): number;
  80011. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  80012. getBodyPressure?(impostor: PhysicsImpostor): number;
  80013. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  80014. getBodyStiffness?(impostor: PhysicsImpostor): number;
  80015. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  80016. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  80017. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  80018. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  80019. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  80020. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80021. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80022. sleepBody(impostor: PhysicsImpostor): void;
  80023. wakeUpBody(impostor: PhysicsImpostor): void;
  80024. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80025. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  80026. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  80027. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  80028. getRadius(impostor: PhysicsImpostor): number;
  80029. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  80030. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  80031. dispose(): void;
  80032. }
  80033. /**
  80034. * Interface used to define a physics engine
  80035. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  80036. */
  80037. export interface IPhysicsEngine {
  80038. /**
  80039. * Gets the gravity vector used by the simulation
  80040. */
  80041. gravity: Vector3;
  80042. /**
  80043. * Sets the gravity vector used by the simulation
  80044. * @param gravity defines the gravity vector to use
  80045. */
  80046. setGravity(gravity: Vector3): void;
  80047. /**
  80048. * Set the time step of the physics engine.
  80049. * Default is 1/60.
  80050. * To slow it down, enter 1/600 for example.
  80051. * To speed it up, 1/30
  80052. * @param newTimeStep the new timestep to apply to this world.
  80053. */
  80054. setTimeStep(newTimeStep: number): void;
  80055. /**
  80056. * Get the time step of the physics engine.
  80057. * @returns the current time step
  80058. */
  80059. getTimeStep(): number;
  80060. /**
  80061. * Release all resources
  80062. */
  80063. dispose(): void;
  80064. /**
  80065. * Gets the name of the current physics plugin
  80066. * @returns the name of the plugin
  80067. */
  80068. getPhysicsPluginName(): string;
  80069. /**
  80070. * Adding a new impostor for the impostor tracking.
  80071. * This will be done by the impostor itself.
  80072. * @param impostor the impostor to add
  80073. */
  80074. addImpostor(impostor: PhysicsImpostor): void;
  80075. /**
  80076. * Remove an impostor from the engine.
  80077. * This impostor and its mesh will not longer be updated by the physics engine.
  80078. * @param impostor the impostor to remove
  80079. */
  80080. removeImpostor(impostor: PhysicsImpostor): void;
  80081. /**
  80082. * Add a joint to the physics engine
  80083. * @param mainImpostor defines the main impostor to which the joint is added.
  80084. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  80085. * @param joint defines the joint that will connect both impostors.
  80086. */
  80087. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80088. /**
  80089. * Removes a joint from the simulation
  80090. * @param mainImpostor defines the impostor used with the joint
  80091. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  80092. * @param joint defines the joint to remove
  80093. */
  80094. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80095. /**
  80096. * Gets the current plugin used to run the simulation
  80097. * @returns current plugin
  80098. */
  80099. getPhysicsPlugin(): IPhysicsEnginePlugin;
  80100. /**
  80101. * Gets the list of physic impostors
  80102. * @returns an array of PhysicsImpostor
  80103. */
  80104. getImpostors(): Array<PhysicsImpostor>;
  80105. /**
  80106. * Gets the impostor for a physics enabled object
  80107. * @param object defines the object impersonated by the impostor
  80108. * @returns the PhysicsImpostor or null if not found
  80109. */
  80110. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80111. /**
  80112. * Gets the impostor for a physics body object
  80113. * @param body defines physics body used by the impostor
  80114. * @returns the PhysicsImpostor or null if not found
  80115. */
  80116. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  80117. /**
  80118. * Does a raycast in the physics world
  80119. * @param from when should the ray start?
  80120. * @param to when should the ray end?
  80121. * @returns PhysicsRaycastResult
  80122. */
  80123. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80124. /**
  80125. * Called by the scene. No need to call it.
  80126. * @param delta defines the timespam between frames
  80127. */
  80128. _step(delta: number): void;
  80129. }
  80130. }
  80131. declare module BABYLON {
  80132. /**
  80133. * The interface for the physics imposter parameters
  80134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80135. */
  80136. export interface PhysicsImpostorParameters {
  80137. /**
  80138. * The mass of the physics imposter
  80139. */
  80140. mass: number;
  80141. /**
  80142. * The friction of the physics imposter
  80143. */
  80144. friction?: number;
  80145. /**
  80146. * The coefficient of restitution of the physics imposter
  80147. */
  80148. restitution?: number;
  80149. /**
  80150. * The native options of the physics imposter
  80151. */
  80152. nativeOptions?: any;
  80153. /**
  80154. * Specifies if the parent should be ignored
  80155. */
  80156. ignoreParent?: boolean;
  80157. /**
  80158. * Specifies if bi-directional transformations should be disabled
  80159. */
  80160. disableBidirectionalTransformation?: boolean;
  80161. /**
  80162. * The pressure inside the physics imposter, soft object only
  80163. */
  80164. pressure?: number;
  80165. /**
  80166. * The stiffness the physics imposter, soft object only
  80167. */
  80168. stiffness?: number;
  80169. /**
  80170. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  80171. */
  80172. velocityIterations?: number;
  80173. /**
  80174. * The number of iterations used in maintaining consistent vertex positions, soft object only
  80175. */
  80176. positionIterations?: number;
  80177. /**
  80178. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  80179. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  80180. * Add to fix multiple points
  80181. */
  80182. fixedPoints?: number;
  80183. /**
  80184. * The collision margin around a soft object
  80185. */
  80186. margin?: number;
  80187. /**
  80188. * The collision margin around a soft object
  80189. */
  80190. damping?: number;
  80191. /**
  80192. * The path for a rope based on an extrusion
  80193. */
  80194. path?: any;
  80195. /**
  80196. * The shape of an extrusion used for a rope based on an extrusion
  80197. */
  80198. shape?: any;
  80199. }
  80200. /**
  80201. * Interface for a physics-enabled object
  80202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80203. */
  80204. export interface IPhysicsEnabledObject {
  80205. /**
  80206. * The position of the physics-enabled object
  80207. */
  80208. position: Vector3;
  80209. /**
  80210. * The rotation of the physics-enabled object
  80211. */
  80212. rotationQuaternion: Nullable<Quaternion>;
  80213. /**
  80214. * The scale of the physics-enabled object
  80215. */
  80216. scaling: Vector3;
  80217. /**
  80218. * The rotation of the physics-enabled object
  80219. */
  80220. rotation?: Vector3;
  80221. /**
  80222. * The parent of the physics-enabled object
  80223. */
  80224. parent?: any;
  80225. /**
  80226. * The bounding info of the physics-enabled object
  80227. * @returns The bounding info of the physics-enabled object
  80228. */
  80229. getBoundingInfo(): BoundingInfo;
  80230. /**
  80231. * Computes the world matrix
  80232. * @param force Specifies if the world matrix should be computed by force
  80233. * @returns A world matrix
  80234. */
  80235. computeWorldMatrix(force: boolean): Matrix;
  80236. /**
  80237. * Gets the world matrix
  80238. * @returns A world matrix
  80239. */
  80240. getWorldMatrix?(): Matrix;
  80241. /**
  80242. * Gets the child meshes
  80243. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  80244. * @returns An array of abstract meshes
  80245. */
  80246. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  80247. /**
  80248. * Gets the vertex data
  80249. * @param kind The type of vertex data
  80250. * @returns A nullable array of numbers, or a float32 array
  80251. */
  80252. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  80253. /**
  80254. * Gets the indices from the mesh
  80255. * @returns A nullable array of index arrays
  80256. */
  80257. getIndices?(): Nullable<IndicesArray>;
  80258. /**
  80259. * Gets the scene from the mesh
  80260. * @returns the indices array or null
  80261. */
  80262. getScene?(): Scene;
  80263. /**
  80264. * Gets the absolute position from the mesh
  80265. * @returns the absolute position
  80266. */
  80267. getAbsolutePosition(): Vector3;
  80268. /**
  80269. * Gets the absolute pivot point from the mesh
  80270. * @returns the absolute pivot point
  80271. */
  80272. getAbsolutePivotPoint(): Vector3;
  80273. /**
  80274. * Rotates the mesh
  80275. * @param axis The axis of rotation
  80276. * @param amount The amount of rotation
  80277. * @param space The space of the rotation
  80278. * @returns The rotation transform node
  80279. */
  80280. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80281. /**
  80282. * Translates the mesh
  80283. * @param axis The axis of translation
  80284. * @param distance The distance of translation
  80285. * @param space The space of the translation
  80286. * @returns The transform node
  80287. */
  80288. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80289. /**
  80290. * Sets the absolute position of the mesh
  80291. * @param absolutePosition The absolute position of the mesh
  80292. * @returns The transform node
  80293. */
  80294. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80295. /**
  80296. * Gets the class name of the mesh
  80297. * @returns The class name
  80298. */
  80299. getClassName(): string;
  80300. }
  80301. /**
  80302. * Represents a physics imposter
  80303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80304. */
  80305. export class PhysicsImpostor {
  80306. /**
  80307. * The physics-enabled object used as the physics imposter
  80308. */
  80309. object: IPhysicsEnabledObject;
  80310. /**
  80311. * The type of the physics imposter
  80312. */
  80313. type: number;
  80314. private _options;
  80315. private _scene?;
  80316. /**
  80317. * The default object size of the imposter
  80318. */
  80319. static DEFAULT_OBJECT_SIZE: Vector3;
  80320. /**
  80321. * The identity quaternion of the imposter
  80322. */
  80323. static IDENTITY_QUATERNION: Quaternion;
  80324. /** @hidden */
  80325. _pluginData: any;
  80326. private _physicsEngine;
  80327. private _physicsBody;
  80328. private _bodyUpdateRequired;
  80329. private _onBeforePhysicsStepCallbacks;
  80330. private _onAfterPhysicsStepCallbacks;
  80331. /** @hidden */
  80332. _onPhysicsCollideCallbacks: Array<{
  80333. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80334. otherImpostors: Array<PhysicsImpostor>;
  80335. }>;
  80336. private _deltaPosition;
  80337. private _deltaRotation;
  80338. private _deltaRotationConjugated;
  80339. /** hidden */
  80340. _isFromLine: boolean;
  80341. private _parent;
  80342. private _isDisposed;
  80343. private static _tmpVecs;
  80344. private static _tmpQuat;
  80345. /**
  80346. * Specifies if the physics imposter is disposed
  80347. */
  80348. readonly isDisposed: boolean;
  80349. /**
  80350. * Gets the mass of the physics imposter
  80351. */
  80352. mass: number;
  80353. /**
  80354. * Gets the coefficient of friction
  80355. */
  80356. /**
  80357. * Sets the coefficient of friction
  80358. */
  80359. friction: number;
  80360. /**
  80361. * Gets the coefficient of restitution
  80362. */
  80363. /**
  80364. * Sets the coefficient of restitution
  80365. */
  80366. restitution: number;
  80367. /**
  80368. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80369. */
  80370. /**
  80371. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80372. */
  80373. pressure: number;
  80374. /**
  80375. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80376. */
  80377. /**
  80378. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80379. */
  80380. stiffness: number;
  80381. /**
  80382. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80383. */
  80384. /**
  80385. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80386. */
  80387. velocityIterations: number;
  80388. /**
  80389. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80390. */
  80391. /**
  80392. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80393. */
  80394. positionIterations: number;
  80395. /**
  80396. * The unique id of the physics imposter
  80397. * set by the physics engine when adding this impostor to the array
  80398. */
  80399. uniqueId: number;
  80400. /**
  80401. * @hidden
  80402. */
  80403. soft: boolean;
  80404. /**
  80405. * @hidden
  80406. */
  80407. segments: number;
  80408. private _joints;
  80409. /**
  80410. * Initializes the physics imposter
  80411. * @param object The physics-enabled object used as the physics imposter
  80412. * @param type The type of the physics imposter
  80413. * @param _options The options for the physics imposter
  80414. * @param _scene The Babylon scene
  80415. */
  80416. constructor(
  80417. /**
  80418. * The physics-enabled object used as the physics imposter
  80419. */
  80420. object: IPhysicsEnabledObject,
  80421. /**
  80422. * The type of the physics imposter
  80423. */
  80424. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80425. /**
  80426. * This function will completly initialize this impostor.
  80427. * It will create a new body - but only if this mesh has no parent.
  80428. * If it has, this impostor will not be used other than to define the impostor
  80429. * of the child mesh.
  80430. * @hidden
  80431. */
  80432. _init(): void;
  80433. private _getPhysicsParent;
  80434. /**
  80435. * Should a new body be generated.
  80436. * @returns boolean specifying if body initialization is required
  80437. */
  80438. isBodyInitRequired(): boolean;
  80439. /**
  80440. * Sets the updated scaling
  80441. * @param updated Specifies if the scaling is updated
  80442. */
  80443. setScalingUpdated(): void;
  80444. /**
  80445. * Force a regeneration of this or the parent's impostor's body.
  80446. * Use under cautious - This will remove all joints already implemented.
  80447. */
  80448. forceUpdate(): void;
  80449. /**
  80450. * Gets the body that holds this impostor. Either its own, or its parent.
  80451. */
  80452. /**
  80453. * Set the physics body. Used mainly by the physics engine/plugin
  80454. */
  80455. physicsBody: any;
  80456. /**
  80457. * Get the parent of the physics imposter
  80458. * @returns Physics imposter or null
  80459. */
  80460. /**
  80461. * Sets the parent of the physics imposter
  80462. */
  80463. parent: Nullable<PhysicsImpostor>;
  80464. /**
  80465. * Resets the update flags
  80466. */
  80467. resetUpdateFlags(): void;
  80468. /**
  80469. * Gets the object extend size
  80470. * @returns the object extend size
  80471. */
  80472. getObjectExtendSize(): Vector3;
  80473. /**
  80474. * Gets the object center
  80475. * @returns The object center
  80476. */
  80477. getObjectCenter(): Vector3;
  80478. /**
  80479. * Get a specific parametes from the options parameter
  80480. * @param paramName The object parameter name
  80481. * @returns The object parameter
  80482. */
  80483. getParam(paramName: string): any;
  80484. /**
  80485. * Sets a specific parameter in the options given to the physics plugin
  80486. * @param paramName The parameter name
  80487. * @param value The value of the parameter
  80488. */
  80489. setParam(paramName: string, value: number): void;
  80490. /**
  80491. * Specifically change the body's mass option. Won't recreate the physics body object
  80492. * @param mass The mass of the physics imposter
  80493. */
  80494. setMass(mass: number): void;
  80495. /**
  80496. * Gets the linear velocity
  80497. * @returns linear velocity or null
  80498. */
  80499. getLinearVelocity(): Nullable<Vector3>;
  80500. /**
  80501. * Sets the linear velocity
  80502. * @param velocity linear velocity or null
  80503. */
  80504. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80505. /**
  80506. * Gets the angular velocity
  80507. * @returns angular velocity or null
  80508. */
  80509. getAngularVelocity(): Nullable<Vector3>;
  80510. /**
  80511. * Sets the angular velocity
  80512. * @param velocity The velocity or null
  80513. */
  80514. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80515. /**
  80516. * Execute a function with the physics plugin native code
  80517. * Provide a function the will have two variables - the world object and the physics body object
  80518. * @param func The function to execute with the physics plugin native code
  80519. */
  80520. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80521. /**
  80522. * Register a function that will be executed before the physics world is stepping forward
  80523. * @param func The function to execute before the physics world is stepped forward
  80524. */
  80525. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80526. /**
  80527. * Unregister a function that will be executed before the physics world is stepping forward
  80528. * @param func The function to execute before the physics world is stepped forward
  80529. */
  80530. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80531. /**
  80532. * Register a function that will be executed after the physics step
  80533. * @param func The function to execute after physics step
  80534. */
  80535. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80536. /**
  80537. * Unregisters a function that will be executed after the physics step
  80538. * @param func The function to execute after physics step
  80539. */
  80540. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80541. /**
  80542. * register a function that will be executed when this impostor collides against a different body
  80543. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80544. * @param func Callback that is executed on collision
  80545. */
  80546. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80547. /**
  80548. * Unregisters the physics imposter on contact
  80549. * @param collideAgainst The physics object to collide against
  80550. * @param func Callback to execute on collision
  80551. */
  80552. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80553. private _tmpQuat;
  80554. private _tmpQuat2;
  80555. /**
  80556. * Get the parent rotation
  80557. * @returns The parent rotation
  80558. */
  80559. getParentsRotation(): Quaternion;
  80560. /**
  80561. * this function is executed by the physics engine.
  80562. */
  80563. beforeStep: () => void;
  80564. /**
  80565. * this function is executed by the physics engine
  80566. */
  80567. afterStep: () => void;
  80568. /**
  80569. * Legacy collision detection event support
  80570. */
  80571. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80572. /**
  80573. * event and body object due to cannon's event-based architecture.
  80574. */
  80575. onCollide: (e: {
  80576. body: any;
  80577. }) => void;
  80578. /**
  80579. * Apply a force
  80580. * @param force The force to apply
  80581. * @param contactPoint The contact point for the force
  80582. * @returns The physics imposter
  80583. */
  80584. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80585. /**
  80586. * Apply an impulse
  80587. * @param force The impulse force
  80588. * @param contactPoint The contact point for the impulse force
  80589. * @returns The physics imposter
  80590. */
  80591. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80592. /**
  80593. * A help function to create a joint
  80594. * @param otherImpostor A physics imposter used to create a joint
  80595. * @param jointType The type of joint
  80596. * @param jointData The data for the joint
  80597. * @returns The physics imposter
  80598. */
  80599. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80600. /**
  80601. * Add a joint to this impostor with a different impostor
  80602. * @param otherImpostor A physics imposter used to add a joint
  80603. * @param joint The joint to add
  80604. * @returns The physics imposter
  80605. */
  80606. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80607. /**
  80608. * Add an anchor to a cloth impostor
  80609. * @param otherImpostor rigid impostor to anchor to
  80610. * @param width ratio across width from 0 to 1
  80611. * @param height ratio up height from 0 to 1
  80612. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80613. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80614. * @returns impostor the soft imposter
  80615. */
  80616. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80617. /**
  80618. * Add a hook to a rope impostor
  80619. * @param otherImpostor rigid impostor to anchor to
  80620. * @param length ratio across rope from 0 to 1
  80621. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80622. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80623. * @returns impostor the rope imposter
  80624. */
  80625. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80626. /**
  80627. * Will keep this body still, in a sleep mode.
  80628. * @returns the physics imposter
  80629. */
  80630. sleep(): PhysicsImpostor;
  80631. /**
  80632. * Wake the body up.
  80633. * @returns The physics imposter
  80634. */
  80635. wakeUp(): PhysicsImpostor;
  80636. /**
  80637. * Clones the physics imposter
  80638. * @param newObject The physics imposter clones to this physics-enabled object
  80639. * @returns A nullable physics imposter
  80640. */
  80641. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80642. /**
  80643. * Disposes the physics imposter
  80644. */
  80645. dispose(): void;
  80646. /**
  80647. * Sets the delta position
  80648. * @param position The delta position amount
  80649. */
  80650. setDeltaPosition(position: Vector3): void;
  80651. /**
  80652. * Sets the delta rotation
  80653. * @param rotation The delta rotation amount
  80654. */
  80655. setDeltaRotation(rotation: Quaternion): void;
  80656. /**
  80657. * Gets the box size of the physics imposter and stores the result in the input parameter
  80658. * @param result Stores the box size
  80659. * @returns The physics imposter
  80660. */
  80661. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80662. /**
  80663. * Gets the radius of the physics imposter
  80664. * @returns Radius of the physics imposter
  80665. */
  80666. getRadius(): number;
  80667. /**
  80668. * Sync a bone with this impostor
  80669. * @param bone The bone to sync to the impostor.
  80670. * @param boneMesh The mesh that the bone is influencing.
  80671. * @param jointPivot The pivot of the joint / bone in local space.
  80672. * @param distToJoint Optional distance from the impostor to the joint.
  80673. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80674. */
  80675. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80676. /**
  80677. * Sync impostor to a bone
  80678. * @param bone The bone that the impostor will be synced to.
  80679. * @param boneMesh The mesh that the bone is influencing.
  80680. * @param jointPivot The pivot of the joint / bone in local space.
  80681. * @param distToJoint Optional distance from the impostor to the joint.
  80682. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80683. * @param boneAxis Optional vector3 axis the bone is aligned with
  80684. */
  80685. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80686. /**
  80687. * No-Imposter type
  80688. */
  80689. static NoImpostor: number;
  80690. /**
  80691. * Sphere-Imposter type
  80692. */
  80693. static SphereImpostor: number;
  80694. /**
  80695. * Box-Imposter type
  80696. */
  80697. static BoxImpostor: number;
  80698. /**
  80699. * Plane-Imposter type
  80700. */
  80701. static PlaneImpostor: number;
  80702. /**
  80703. * Mesh-imposter type
  80704. */
  80705. static MeshImpostor: number;
  80706. /**
  80707. * Cylinder-Imposter type
  80708. */
  80709. static CylinderImpostor: number;
  80710. /**
  80711. * Particle-Imposter type
  80712. */
  80713. static ParticleImpostor: number;
  80714. /**
  80715. * Heightmap-Imposter type
  80716. */
  80717. static HeightmapImpostor: number;
  80718. /**
  80719. * ConvexHull-Impostor type (Ammo.js plugin only)
  80720. */
  80721. static ConvexHullImpostor: number;
  80722. /**
  80723. * Rope-Imposter type
  80724. */
  80725. static RopeImpostor: number;
  80726. /**
  80727. * Cloth-Imposter type
  80728. */
  80729. static ClothImpostor: number;
  80730. /**
  80731. * Softbody-Imposter type
  80732. */
  80733. static SoftbodyImpostor: number;
  80734. }
  80735. }
  80736. declare module BABYLON {
  80737. /**
  80738. * @hidden
  80739. **/
  80740. export class _CreationDataStorage {
  80741. closePath?: boolean;
  80742. closeArray?: boolean;
  80743. idx: number[];
  80744. dashSize: number;
  80745. gapSize: number;
  80746. path3D: Path3D;
  80747. pathArray: Vector3[][];
  80748. arc: number;
  80749. radius: number;
  80750. cap: number;
  80751. tessellation: number;
  80752. }
  80753. /**
  80754. * @hidden
  80755. **/
  80756. class _InstanceDataStorage {
  80757. visibleInstances: any;
  80758. batchCache: _InstancesBatch;
  80759. instancesBufferSize: number;
  80760. instancesBuffer: Nullable<Buffer>;
  80761. instancesData: Float32Array;
  80762. overridenInstanceCount: number;
  80763. isFrozen: boolean;
  80764. previousBatch: _InstancesBatch;
  80765. hardwareInstancedRendering: boolean;
  80766. sideOrientation: number;
  80767. }
  80768. /**
  80769. * @hidden
  80770. **/
  80771. export class _InstancesBatch {
  80772. mustReturn: boolean;
  80773. visibleInstances: Nullable<InstancedMesh[]>[];
  80774. renderSelf: boolean[];
  80775. hardwareInstancedRendering: boolean[];
  80776. }
  80777. /**
  80778. * Class used to represent renderable models
  80779. */
  80780. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80781. /**
  80782. * Mesh side orientation : usually the external or front surface
  80783. */
  80784. static readonly FRONTSIDE: number;
  80785. /**
  80786. * Mesh side orientation : usually the internal or back surface
  80787. */
  80788. static readonly BACKSIDE: number;
  80789. /**
  80790. * Mesh side orientation : both internal and external or front and back surfaces
  80791. */
  80792. static readonly DOUBLESIDE: number;
  80793. /**
  80794. * Mesh side orientation : by default, `FRONTSIDE`
  80795. */
  80796. static readonly DEFAULTSIDE: number;
  80797. /**
  80798. * Mesh cap setting : no cap
  80799. */
  80800. static readonly NO_CAP: number;
  80801. /**
  80802. * Mesh cap setting : one cap at the beginning of the mesh
  80803. */
  80804. static readonly CAP_START: number;
  80805. /**
  80806. * Mesh cap setting : one cap at the end of the mesh
  80807. */
  80808. static readonly CAP_END: number;
  80809. /**
  80810. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80811. */
  80812. static readonly CAP_ALL: number;
  80813. /**
  80814. * Gets the default side orientation.
  80815. * @param orientation the orientation to value to attempt to get
  80816. * @returns the default orientation
  80817. * @hidden
  80818. */
  80819. static _GetDefaultSideOrientation(orientation?: number): number;
  80820. private _onBeforeRenderObservable;
  80821. private _onBeforeBindObservable;
  80822. private _onAfterRenderObservable;
  80823. private _onBeforeDrawObservable;
  80824. /**
  80825. * An event triggered before rendering the mesh
  80826. */
  80827. readonly onBeforeRenderObservable: Observable<Mesh>;
  80828. /**
  80829. * An event triggered before binding the mesh
  80830. */
  80831. readonly onBeforeBindObservable: Observable<Mesh>;
  80832. /**
  80833. * An event triggered after rendering the mesh
  80834. */
  80835. readonly onAfterRenderObservable: Observable<Mesh>;
  80836. /**
  80837. * An event triggered before drawing the mesh
  80838. */
  80839. readonly onBeforeDrawObservable: Observable<Mesh>;
  80840. private _onBeforeDrawObserver;
  80841. /**
  80842. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80843. */
  80844. onBeforeDraw: () => void;
  80845. /**
  80846. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80847. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80848. */
  80849. delayLoadState: number;
  80850. /**
  80851. * Gets the list of instances created from this mesh
  80852. * it is not supposed to be modified manually.
  80853. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80854. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80855. */
  80856. instances: InstancedMesh[];
  80857. /**
  80858. * Gets the file containing delay loading data for this mesh
  80859. */
  80860. delayLoadingFile: string;
  80861. /** @hidden */
  80862. _binaryInfo: any;
  80863. private _LODLevels;
  80864. /**
  80865. * User defined function used to change how LOD level selection is done
  80866. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80867. */
  80868. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80869. private _morphTargetManager;
  80870. /**
  80871. * Gets or sets the morph target manager
  80872. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80873. */
  80874. morphTargetManager: Nullable<MorphTargetManager>;
  80875. /** @hidden */
  80876. _creationDataStorage: Nullable<_CreationDataStorage>;
  80877. /** @hidden */
  80878. _geometry: Nullable<Geometry>;
  80879. /** @hidden */
  80880. _delayInfo: Array<string>;
  80881. /** @hidden */
  80882. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80883. /** @hidden */
  80884. _instanceDataStorage: _InstanceDataStorage;
  80885. private _effectiveMaterial;
  80886. /** @hidden */
  80887. _shouldGenerateFlatShading: boolean;
  80888. private _preActivateId;
  80889. /** @hidden */
  80890. _originalBuilderSideOrientation: number;
  80891. /**
  80892. * Use this property to change the original side orientation defined at construction time
  80893. */
  80894. overrideMaterialSideOrientation: Nullable<number>;
  80895. private _areNormalsFrozen;
  80896. private _sourcePositions;
  80897. private _sourceNormals;
  80898. private _source;
  80899. private meshMap;
  80900. /**
  80901. * Gets the source mesh (the one used to clone this one from)
  80902. */
  80903. readonly source: Nullable<Mesh>;
  80904. /**
  80905. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80906. */
  80907. isUnIndexed: boolean;
  80908. /**
  80909. * @constructor
  80910. * @param name The value used by scene.getMeshByName() to do a lookup.
  80911. * @param scene The scene to add this mesh to.
  80912. * @param parent The parent of this mesh, if it has one
  80913. * @param source An optional Mesh from which geometry is shared, cloned.
  80914. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80915. * When false, achieved by calling a clone(), also passing False.
  80916. * This will make creation of children, recursive.
  80917. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80918. */
  80919. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80920. /**
  80921. * Gets the class name
  80922. * @returns the string "Mesh".
  80923. */
  80924. getClassName(): string;
  80925. /** @hidden */
  80926. readonly _isMesh: boolean;
  80927. /**
  80928. * Returns a description of this mesh
  80929. * @param fullDetails define if full details about this mesh must be used
  80930. * @returns a descriptive string representing this mesh
  80931. */
  80932. toString(fullDetails?: boolean): string;
  80933. /** @hidden */
  80934. _unBindEffect(): void;
  80935. /**
  80936. * Gets a boolean indicating if this mesh has LOD
  80937. */
  80938. readonly hasLODLevels: boolean;
  80939. /**
  80940. * Gets the list of MeshLODLevel associated with the current mesh
  80941. * @returns an array of MeshLODLevel
  80942. */
  80943. getLODLevels(): MeshLODLevel[];
  80944. private _sortLODLevels;
  80945. /**
  80946. * Add a mesh as LOD level triggered at the given distance.
  80947. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80948. * @param distance The distance from the center of the object to show this level
  80949. * @param mesh The mesh to be added as LOD level (can be null)
  80950. * @return This mesh (for chaining)
  80951. */
  80952. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80953. /**
  80954. * Returns the LOD level mesh at the passed distance or null if not found.
  80955. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80956. * @param distance The distance from the center of the object to show this level
  80957. * @returns a Mesh or `null`
  80958. */
  80959. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80960. /**
  80961. * Remove a mesh from the LOD array
  80962. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80963. * @param mesh defines the mesh to be removed
  80964. * @return This mesh (for chaining)
  80965. */
  80966. removeLODLevel(mesh: Mesh): Mesh;
  80967. /**
  80968. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80969. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80970. * @param camera defines the camera to use to compute distance
  80971. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80972. * @return This mesh (for chaining)
  80973. */
  80974. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80975. /**
  80976. * Gets the mesh internal Geometry object
  80977. */
  80978. readonly geometry: Nullable<Geometry>;
  80979. /**
  80980. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80981. * @returns the total number of vertices
  80982. */
  80983. getTotalVertices(): number;
  80984. /**
  80985. * Returns the content of an associated vertex buffer
  80986. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80987. * - VertexBuffer.PositionKind
  80988. * - VertexBuffer.UVKind
  80989. * - VertexBuffer.UV2Kind
  80990. * - VertexBuffer.UV3Kind
  80991. * - VertexBuffer.UV4Kind
  80992. * - VertexBuffer.UV5Kind
  80993. * - VertexBuffer.UV6Kind
  80994. * - VertexBuffer.ColorKind
  80995. * - VertexBuffer.MatricesIndicesKind
  80996. * - VertexBuffer.MatricesIndicesExtraKind
  80997. * - VertexBuffer.MatricesWeightsKind
  80998. * - VertexBuffer.MatricesWeightsExtraKind
  80999. * @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
  81000. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  81001. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  81002. */
  81003. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81004. /**
  81005. * Returns the mesh VertexBuffer object from the requested `kind`
  81006. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81007. * - VertexBuffer.PositionKind
  81008. * - VertexBuffer.UVKind
  81009. * - VertexBuffer.UV2Kind
  81010. * - VertexBuffer.UV3Kind
  81011. * - VertexBuffer.UV4Kind
  81012. * - VertexBuffer.UV5Kind
  81013. * - VertexBuffer.UV6Kind
  81014. * - VertexBuffer.ColorKind
  81015. * - VertexBuffer.MatricesIndicesKind
  81016. * - VertexBuffer.MatricesIndicesExtraKind
  81017. * - VertexBuffer.MatricesWeightsKind
  81018. * - VertexBuffer.MatricesWeightsExtraKind
  81019. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  81020. */
  81021. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81022. /**
  81023. * Tests if a specific vertex buffer is associated with this mesh
  81024. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81025. * - VertexBuffer.PositionKind
  81026. * - VertexBuffer.UVKind
  81027. * - VertexBuffer.UV2Kind
  81028. * - VertexBuffer.UV3Kind
  81029. * - VertexBuffer.UV4Kind
  81030. * - VertexBuffer.UV5Kind
  81031. * - VertexBuffer.UV6Kind
  81032. * - VertexBuffer.ColorKind
  81033. * - VertexBuffer.MatricesIndicesKind
  81034. * - VertexBuffer.MatricesIndicesExtraKind
  81035. * - VertexBuffer.MatricesWeightsKind
  81036. * - VertexBuffer.MatricesWeightsExtraKind
  81037. * @returns a boolean
  81038. */
  81039. isVerticesDataPresent(kind: string): boolean;
  81040. /**
  81041. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  81042. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81043. * - VertexBuffer.PositionKind
  81044. * - VertexBuffer.UVKind
  81045. * - VertexBuffer.UV2Kind
  81046. * - VertexBuffer.UV3Kind
  81047. * - VertexBuffer.UV4Kind
  81048. * - VertexBuffer.UV5Kind
  81049. * - VertexBuffer.UV6Kind
  81050. * - VertexBuffer.ColorKind
  81051. * - VertexBuffer.MatricesIndicesKind
  81052. * - VertexBuffer.MatricesIndicesExtraKind
  81053. * - VertexBuffer.MatricesWeightsKind
  81054. * - VertexBuffer.MatricesWeightsExtraKind
  81055. * @returns a boolean
  81056. */
  81057. isVertexBufferUpdatable(kind: string): boolean;
  81058. /**
  81059. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  81060. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81061. * - VertexBuffer.PositionKind
  81062. * - VertexBuffer.UVKind
  81063. * - VertexBuffer.UV2Kind
  81064. * - VertexBuffer.UV3Kind
  81065. * - VertexBuffer.UV4Kind
  81066. * - VertexBuffer.UV5Kind
  81067. * - VertexBuffer.UV6Kind
  81068. * - VertexBuffer.ColorKind
  81069. * - VertexBuffer.MatricesIndicesKind
  81070. * - VertexBuffer.MatricesIndicesExtraKind
  81071. * - VertexBuffer.MatricesWeightsKind
  81072. * - VertexBuffer.MatricesWeightsExtraKind
  81073. * @returns an array of strings
  81074. */
  81075. getVerticesDataKinds(): string[];
  81076. /**
  81077. * Returns a positive integer : the total number of indices in this mesh geometry.
  81078. * @returns the numner of indices or zero if the mesh has no geometry.
  81079. */
  81080. getTotalIndices(): number;
  81081. /**
  81082. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81083. * @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.
  81084. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81085. * @returns the indices array or an empty array if the mesh has no geometry
  81086. */
  81087. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81088. readonly isBlocked: boolean;
  81089. /**
  81090. * Determine if the current mesh is ready to be rendered
  81091. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81092. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81093. * @returns true if all associated assets are ready (material, textures, shaders)
  81094. */
  81095. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  81096. /**
  81097. * 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.
  81098. */
  81099. readonly areNormalsFrozen: boolean;
  81100. /**
  81101. * 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.
  81102. * @returns the current mesh
  81103. */
  81104. freezeNormals(): Mesh;
  81105. /**
  81106. * 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
  81107. * @returns the current mesh
  81108. */
  81109. unfreezeNormals(): Mesh;
  81110. /**
  81111. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81112. */
  81113. overridenInstanceCount: number;
  81114. /** @hidden */
  81115. _preActivate(): Mesh;
  81116. /** @hidden */
  81117. _preActivateForIntermediateRendering(renderId: number): Mesh;
  81118. /** @hidden */
  81119. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  81120. /**
  81121. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81122. * This means the mesh underlying bounding box and sphere are recomputed.
  81123. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81124. * @returns the current mesh
  81125. */
  81126. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  81127. /** @hidden */
  81128. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  81129. /**
  81130. * This function will subdivide the mesh into multiple submeshes
  81131. * @param count defines the expected number of submeshes
  81132. */
  81133. subdivide(count: number): void;
  81134. /**
  81135. * Copy a FloatArray into a specific associated vertex buffer
  81136. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81137. * - VertexBuffer.PositionKind
  81138. * - VertexBuffer.UVKind
  81139. * - VertexBuffer.UV2Kind
  81140. * - VertexBuffer.UV3Kind
  81141. * - VertexBuffer.UV4Kind
  81142. * - VertexBuffer.UV5Kind
  81143. * - VertexBuffer.UV6Kind
  81144. * - VertexBuffer.ColorKind
  81145. * - VertexBuffer.MatricesIndicesKind
  81146. * - VertexBuffer.MatricesIndicesExtraKind
  81147. * - VertexBuffer.MatricesWeightsKind
  81148. * - VertexBuffer.MatricesWeightsExtraKind
  81149. * @param data defines the data source
  81150. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81151. * @param stride defines the data stride size (can be null)
  81152. * @returns the current mesh
  81153. */
  81154. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81155. /**
  81156. * Flags an associated vertex buffer as updatable
  81157. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81158. * - VertexBuffer.PositionKind
  81159. * - VertexBuffer.UVKind
  81160. * - VertexBuffer.UV2Kind
  81161. * - VertexBuffer.UV3Kind
  81162. * - VertexBuffer.UV4Kind
  81163. * - VertexBuffer.UV5Kind
  81164. * - VertexBuffer.UV6Kind
  81165. * - VertexBuffer.ColorKind
  81166. * - VertexBuffer.MatricesIndicesKind
  81167. * - VertexBuffer.MatricesIndicesExtraKind
  81168. * - VertexBuffer.MatricesWeightsKind
  81169. * - VertexBuffer.MatricesWeightsExtraKind
  81170. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81171. */
  81172. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  81173. /**
  81174. * Sets the mesh global Vertex Buffer
  81175. * @param buffer defines the buffer to use
  81176. * @returns the current mesh
  81177. */
  81178. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  81179. /**
  81180. * Update a specific associated vertex buffer
  81181. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81182. * - VertexBuffer.PositionKind
  81183. * - VertexBuffer.UVKind
  81184. * - VertexBuffer.UV2Kind
  81185. * - VertexBuffer.UV3Kind
  81186. * - VertexBuffer.UV4Kind
  81187. * - VertexBuffer.UV5Kind
  81188. * - VertexBuffer.UV6Kind
  81189. * - VertexBuffer.ColorKind
  81190. * - VertexBuffer.MatricesIndicesKind
  81191. * - VertexBuffer.MatricesIndicesExtraKind
  81192. * - VertexBuffer.MatricesWeightsKind
  81193. * - VertexBuffer.MatricesWeightsExtraKind
  81194. * @param data defines the data source
  81195. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81196. * @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)
  81197. * @returns the current mesh
  81198. */
  81199. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81200. /**
  81201. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81202. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81203. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81204. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81205. * @returns the current mesh
  81206. */
  81207. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  81208. /**
  81209. * Creates a un-shared specific occurence of the geometry for the mesh.
  81210. * @returns the current mesh
  81211. */
  81212. makeGeometryUnique(): Mesh;
  81213. /**
  81214. * Set the index buffer of this mesh
  81215. * @param indices defines the source data
  81216. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81217. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81218. * @returns the current mesh
  81219. */
  81220. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  81221. /**
  81222. * Update the current index buffer
  81223. * @param indices defines the source data
  81224. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81225. * @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)
  81226. * @returns the current mesh
  81227. */
  81228. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  81229. /**
  81230. * Invert the geometry to move from a right handed system to a left handed one.
  81231. * @returns the current mesh
  81232. */
  81233. toLeftHanded(): Mesh;
  81234. /** @hidden */
  81235. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  81236. /** @hidden */
  81237. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  81238. /**
  81239. * Registers for this mesh a javascript function called just before the rendering process
  81240. * @param func defines the function to call before rendering this mesh
  81241. * @returns the current mesh
  81242. */
  81243. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81244. /**
  81245. * Disposes a previously registered javascript function called before the rendering
  81246. * @param func defines the function to remove
  81247. * @returns the current mesh
  81248. */
  81249. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81250. /**
  81251. * Registers for this mesh a javascript function called just after the rendering is complete
  81252. * @param func defines the function to call after rendering this mesh
  81253. * @returns the current mesh
  81254. */
  81255. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81256. /**
  81257. * Disposes a previously registered javascript function called after the rendering.
  81258. * @param func defines the function to remove
  81259. * @returns the current mesh
  81260. */
  81261. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81262. /** @hidden */
  81263. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  81264. /** @hidden */
  81265. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  81266. /** @hidden */
  81267. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  81268. /** @hidden */
  81269. _freeze(): void;
  81270. /** @hidden */
  81271. _unFreeze(): void;
  81272. /**
  81273. * 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
  81274. * @param subMesh defines the subMesh to render
  81275. * @param enableAlphaMode defines if alpha mode can be changed
  81276. * @returns the current mesh
  81277. */
  81278. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  81279. private _onBeforeDraw;
  81280. /**
  81281. * Renormalize the mesh and patch it up if there are no weights
  81282. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81283. * However in the case of zero weights then we set just a single influence to 1.
  81284. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81285. */
  81286. cleanMatrixWeights(): void;
  81287. private normalizeSkinFourWeights;
  81288. private normalizeSkinWeightsAndExtra;
  81289. /**
  81290. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81291. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81292. * the user know there was an issue with importing the mesh
  81293. * @returns a validation object with skinned, valid and report string
  81294. */
  81295. validateSkinning(): {
  81296. skinned: boolean;
  81297. valid: boolean;
  81298. report: string;
  81299. };
  81300. /** @hidden */
  81301. _checkDelayState(): Mesh;
  81302. private _queueLoad;
  81303. /**
  81304. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81305. * A mesh is in the frustum if its bounding box intersects the frustum
  81306. * @param frustumPlanes defines the frustum to test
  81307. * @returns true if the mesh is in the frustum planes
  81308. */
  81309. isInFrustum(frustumPlanes: Plane[]): boolean;
  81310. /**
  81311. * Sets the mesh material by the material or multiMaterial `id` property
  81312. * @param id is a string identifying the material or the multiMaterial
  81313. * @returns the current mesh
  81314. */
  81315. setMaterialByID(id: string): Mesh;
  81316. /**
  81317. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81318. * @returns an array of IAnimatable
  81319. */
  81320. getAnimatables(): IAnimatable[];
  81321. /**
  81322. * Modifies the mesh geometry according to the passed transformation matrix.
  81323. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81324. * The mesh normals are modified using the same transformation.
  81325. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81326. * @param transform defines the transform matrix to use
  81327. * @see http://doc.babylonjs.com/resources/baking_transformations
  81328. * @returns the current mesh
  81329. */
  81330. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81331. /**
  81332. * Modifies the mesh geometry according to its own current World Matrix.
  81333. * The mesh World Matrix is then reset.
  81334. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81335. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81336. * @see http://doc.babylonjs.com/resources/baking_transformations
  81337. * @returns the current mesh
  81338. */
  81339. bakeCurrentTransformIntoVertices(): Mesh;
  81340. /** @hidden */
  81341. readonly _positions: Nullable<Vector3[]>;
  81342. /** @hidden */
  81343. _resetPointsArrayCache(): Mesh;
  81344. /** @hidden */
  81345. _generatePointsArray(): boolean;
  81346. /**
  81347. * Returns a new Mesh object generated from the current mesh properties.
  81348. * This method must not get confused with createInstance()
  81349. * @param name is a string, the name given to the new mesh
  81350. * @param newParent can be any Node object (default `null`)
  81351. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81352. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81353. * @returns a new mesh
  81354. */
  81355. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81356. /**
  81357. * Releases resources associated with this mesh.
  81358. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81359. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81360. */
  81361. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81362. /**
  81363. * Modifies the mesh geometry according to a displacement map.
  81364. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  81365. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81366. * @param url is a string, the URL from the image file is to be downloaded.
  81367. * @param minHeight is the lower limit of the displacement.
  81368. * @param maxHeight is the upper limit of the displacement.
  81369. * @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.
  81370. * @param uvOffset is an optional vector2 used to offset UV.
  81371. * @param uvScale is an optional vector2 used to scale UV.
  81372. * @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.
  81373. * @returns the Mesh.
  81374. */
  81375. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81376. /**
  81377. * Modifies the mesh geometry according to a displacementMap buffer.
  81378. * 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.
  81379. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81380. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81381. * @param heightMapWidth is the width of the buffer image.
  81382. * @param heightMapHeight is the height of the buffer image.
  81383. * @param minHeight is the lower limit of the displacement.
  81384. * @param maxHeight is the upper limit of the displacement.
  81385. * @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.
  81386. * @param uvOffset is an optional vector2 used to offset UV.
  81387. * @param uvScale is an optional vector2 used to scale UV.
  81388. * @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.
  81389. * @returns the Mesh.
  81390. */
  81391. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81392. /**
  81393. * Modify the mesh to get a flat shading rendering.
  81394. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81395. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81396. * @returns current mesh
  81397. */
  81398. convertToFlatShadedMesh(): Mesh;
  81399. /**
  81400. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81401. * In other words, more vertices, no more indices and a single bigger VBO.
  81402. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81403. * @returns current mesh
  81404. */
  81405. convertToUnIndexedMesh(): Mesh;
  81406. /**
  81407. * Inverses facet orientations.
  81408. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81409. * @param flipNormals will also inverts the normals
  81410. * @returns current mesh
  81411. */
  81412. flipFaces(flipNormals?: boolean): Mesh;
  81413. /**
  81414. * Increase the number of facets and hence vertices in a mesh
  81415. * Vertex normals are interpolated from existing vertex normals
  81416. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81417. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81418. */
  81419. increaseVertices(numberPerEdge: number): void;
  81420. /**
  81421. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81422. * This will undo any application of covertToFlatShadedMesh
  81423. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81424. */
  81425. forceSharedVertices(): void;
  81426. /** @hidden */
  81427. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81428. /** @hidden */
  81429. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81430. /**
  81431. * Creates a new InstancedMesh object from the mesh model.
  81432. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81433. * @param name defines the name of the new instance
  81434. * @returns a new InstancedMesh
  81435. */
  81436. createInstance(name: string): InstancedMesh;
  81437. /**
  81438. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81439. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81440. * @returns the current mesh
  81441. */
  81442. synchronizeInstances(): Mesh;
  81443. /**
  81444. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81445. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81446. * This should be used together with the simplification to avoid disappearing triangles.
  81447. * @param successCallback an optional success callback to be called after the optimization finished.
  81448. * @returns the current mesh
  81449. */
  81450. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81451. /**
  81452. * Serialize current mesh
  81453. * @param serializationObject defines the object which will receive the serialization data
  81454. */
  81455. serialize(serializationObject: any): void;
  81456. /** @hidden */
  81457. _syncGeometryWithMorphTargetManager(): void;
  81458. /** @hidden */
  81459. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81460. /**
  81461. * Returns a new Mesh object parsed from the source provided.
  81462. * @param parsedMesh is the source
  81463. * @param scene defines the hosting scene
  81464. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81465. * @returns a new Mesh
  81466. */
  81467. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81468. /**
  81469. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81470. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81471. * @param name defines the name of the mesh to create
  81472. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81473. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81474. * @param closePath creates a seam between the first and the last points of each path of the path array
  81475. * @param offset is taken in account only if the `pathArray` is containing a single path
  81476. * @param scene defines the hosting scene
  81477. * @param updatable defines if the mesh must be flagged as updatable
  81478. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81479. * @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)
  81480. * @returns a new Mesh
  81481. */
  81482. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81483. /**
  81484. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81485. * @param name defines the name of the mesh to create
  81486. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81487. * @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
  81488. * @param scene defines the hosting scene
  81489. * @param updatable defines if the mesh must be flagged as updatable
  81490. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81491. * @returns a new Mesh
  81492. */
  81493. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81494. /**
  81495. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81496. * @param name defines the name of the mesh to create
  81497. * @param size sets the size (float) of each box side (default 1)
  81498. * @param scene defines the hosting scene
  81499. * @param updatable defines if the mesh must be flagged as updatable
  81500. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81501. * @returns a new Mesh
  81502. */
  81503. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81504. /**
  81505. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81506. * @param name defines the name of the mesh to create
  81507. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81508. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81509. * @param scene defines the hosting scene
  81510. * @param updatable defines if the mesh must be flagged as updatable
  81511. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81512. * @returns a new Mesh
  81513. */
  81514. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81515. /**
  81516. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81517. * @param name defines the name of the mesh to create
  81518. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81519. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81520. * @param scene defines the hosting scene
  81521. * @returns a new Mesh
  81522. */
  81523. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81524. /**
  81525. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81526. * @param name defines the name of the mesh to create
  81527. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81528. * @param diameterTop set the top cap diameter (floats, default 1)
  81529. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81530. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81531. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81532. * @param scene defines the hosting scene
  81533. * @param updatable defines if the mesh must be flagged as updatable
  81534. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81535. * @returns a new Mesh
  81536. */
  81537. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81538. /**
  81539. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81540. * @param name defines the name of the mesh to create
  81541. * @param diameter sets the diameter size (float) of the torus (default 1)
  81542. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81543. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81544. * @param scene defines the hosting scene
  81545. * @param updatable defines if the mesh must be flagged as updatable
  81546. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81547. * @returns a new Mesh
  81548. */
  81549. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81550. /**
  81551. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81552. * @param name defines the name of the mesh to create
  81553. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81554. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81555. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81556. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81557. * @param p the number of windings on X axis (positive integers, default 2)
  81558. * @param q the number of windings on Y axis (positive integers, default 3)
  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 CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81565. /**
  81566. * Creates a line 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 points is an array successive Vector3
  81569. * @param scene defines the hosting scene
  81570. * @param updatable defines if the mesh must be flagged as updatable
  81571. * @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).
  81572. * @returns a new Mesh
  81573. */
  81574. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81575. /**
  81576. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81577. * @param name defines the name of the mesh to create
  81578. * @param points is an array successive Vector3
  81579. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81580. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81581. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81582. * @param scene defines the hosting scene
  81583. * @param updatable defines if the mesh must be flagged as updatable
  81584. * @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)
  81585. * @returns a new Mesh
  81586. */
  81587. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81588. /**
  81589. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81590. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81591. * 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.
  81592. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81593. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81594. * Remember you can only change the shape positions, not their number when updating a polygon.
  81595. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81596. * @param name defines the name of the mesh to create
  81597. * @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
  81598. * @param scene defines the hosting scene
  81599. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81600. * @param updatable defines if the mesh must be flagged as updatable
  81601. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81602. * @param earcutInjection can be used to inject your own earcut reference
  81603. * @returns a new Mesh
  81604. */
  81605. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81606. /**
  81607. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81608. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81609. * @param name defines the name of the mesh to create
  81610. * @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
  81611. * @param depth defines the height of extrusion
  81612. * @param scene defines the hosting scene
  81613. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81614. * @param updatable defines if the mesh must be flagged as updatable
  81615. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81616. * @param earcutInjection can be used to inject your own earcut reference
  81617. * @returns a new Mesh
  81618. */
  81619. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81620. /**
  81621. * Creates an extruded shape mesh.
  81622. * 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
  81623. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81624. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81625. * @param name defines the name of the mesh to create
  81626. * @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
  81627. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81628. * @param scale is the value to scale the shape
  81629. * @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
  81630. * @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
  81631. * @param scene defines the hosting scene
  81632. * @param updatable defines if the mesh must be flagged as updatable
  81633. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81634. * @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)
  81635. * @returns a new Mesh
  81636. */
  81637. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81638. /**
  81639. * Creates an custom extruded shape mesh.
  81640. * The custom extrusion is a parametric shape.
  81641. * It has no predefined shape. Its final shape will depend on the input parameters.
  81642. * Please consider using the same method from the MeshBuilder class instead
  81643. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81644. * @param name defines the name of the mesh to create
  81645. * @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
  81646. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81647. * @param scaleFunction is a custom Javascript function called on each path point
  81648. * @param rotationFunction is a custom Javascript function called on each path point
  81649. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81650. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81651. * @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
  81652. * @param scene defines the hosting scene
  81653. * @param updatable defines if the mesh must be flagged as updatable
  81654. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81655. * @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)
  81656. * @returns a new Mesh
  81657. */
  81658. 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;
  81659. /**
  81660. * Creates lathe mesh.
  81661. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81662. * Please consider using the same method from the MeshBuilder class instead
  81663. * @param name defines the name of the mesh to create
  81664. * @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
  81665. * @param radius is the radius value of the lathe
  81666. * @param tessellation is the side number of the lathe.
  81667. * @param scene defines the hosting scene
  81668. * @param updatable defines if the mesh must be flagged as updatable
  81669. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81670. * @returns a new Mesh
  81671. */
  81672. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81673. /**
  81674. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81675. * @param name defines the name of the mesh to create
  81676. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81677. * @param scene defines the hosting scene
  81678. * @param updatable defines if the mesh must be flagged as updatable
  81679. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81680. * @returns a new Mesh
  81681. */
  81682. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81683. /**
  81684. * Creates a ground mesh.
  81685. * Please consider using the same method from the MeshBuilder class instead
  81686. * @param name defines the name of the mesh to create
  81687. * @param width set the width of the ground
  81688. * @param height set the height of the ground
  81689. * @param subdivisions sets the number of subdivisions per side
  81690. * @param scene defines the hosting scene
  81691. * @param updatable defines if the mesh must be flagged as updatable
  81692. * @returns a new Mesh
  81693. */
  81694. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81695. /**
  81696. * Creates a tiled ground mesh.
  81697. * Please consider using the same method from the MeshBuilder class instead
  81698. * @param name defines the name of the mesh to create
  81699. * @param xmin set the ground minimum X coordinate
  81700. * @param zmin set the ground minimum Y coordinate
  81701. * @param xmax set the ground maximum X coordinate
  81702. * @param zmax set the ground maximum Z coordinate
  81703. * @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
  81704. * @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
  81705. * @param scene defines the hosting scene
  81706. * @param updatable defines if the mesh must be flagged as updatable
  81707. * @returns a new Mesh
  81708. */
  81709. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81710. w: number;
  81711. h: number;
  81712. }, precision: {
  81713. w: number;
  81714. h: number;
  81715. }, scene: Scene, updatable?: boolean): Mesh;
  81716. /**
  81717. * Creates a ground mesh from a height map.
  81718. * Please consider using the same method from the MeshBuilder class instead
  81719. * @see http://doc.babylonjs.com/babylon101/height_map
  81720. * @param name defines the name of the mesh to create
  81721. * @param url sets the URL of the height map image resource
  81722. * @param width set the ground width size
  81723. * @param height set the ground height size
  81724. * @param subdivisions sets the number of subdivision per side
  81725. * @param minHeight is the minimum altitude on the ground
  81726. * @param maxHeight is the maximum altitude on the ground
  81727. * @param scene defines the hosting scene
  81728. * @param updatable defines if the mesh must be flagged as updatable
  81729. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81730. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81731. * @returns a new Mesh
  81732. */
  81733. 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;
  81734. /**
  81735. * Creates a tube mesh.
  81736. * The tube is a parametric shape.
  81737. * It has no predefined shape. Its final shape will depend on the input parameters.
  81738. * Please consider using the same method from the MeshBuilder class instead
  81739. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81740. * @param name defines the name of the mesh to create
  81741. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81742. * @param radius sets the tube radius size
  81743. * @param tessellation is the number of sides on the tubular surface
  81744. * @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
  81745. * @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
  81746. * @param scene defines the hosting scene
  81747. * @param updatable defines if the mesh must be flagged as updatable
  81748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81749. * @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)
  81750. * @returns a new Mesh
  81751. */
  81752. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81753. (i: number, distance: number): number;
  81754. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81755. /**
  81756. * Creates a polyhedron mesh.
  81757. * Please consider using the same method from the MeshBuilder class instead.
  81758. * * 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
  81759. * * The parameter `size` (positive float, default 1) sets the polygon size
  81760. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81761. * * 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`
  81762. * * 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
  81763. * * 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)`)
  81764. * * 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
  81765. * * 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
  81766. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81767. * * If you create a double-sided mesh, you can choose what parts of 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
  81768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81769. * @param name defines the name of the mesh to create
  81770. * @param options defines the options used to create the mesh
  81771. * @param scene defines the hosting scene
  81772. * @returns a new Mesh
  81773. */
  81774. static CreatePolyhedron(name: string, options: {
  81775. type?: number;
  81776. size?: number;
  81777. sizeX?: number;
  81778. sizeY?: number;
  81779. sizeZ?: number;
  81780. custom?: any;
  81781. faceUV?: Vector4[];
  81782. faceColors?: Color4[];
  81783. updatable?: boolean;
  81784. sideOrientation?: number;
  81785. }, scene: Scene): Mesh;
  81786. /**
  81787. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81788. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81789. * * 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`)
  81790. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81791. * * 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
  81792. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81793. * * If you create a double-sided mesh, you can choose what parts of 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
  81794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81795. * @param name defines the name of the mesh
  81796. * @param options defines the options used to create the mesh
  81797. * @param scene defines the hosting scene
  81798. * @returns a new Mesh
  81799. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81800. */
  81801. static CreateIcoSphere(name: string, options: {
  81802. radius?: number;
  81803. flat?: boolean;
  81804. subdivisions?: number;
  81805. sideOrientation?: number;
  81806. updatable?: boolean;
  81807. }, scene: Scene): Mesh;
  81808. /**
  81809. * Creates a decal mesh.
  81810. * Please consider using the same method from the MeshBuilder class instead.
  81811. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81812. * @param name defines the name of the mesh
  81813. * @param sourceMesh defines the mesh receiving the decal
  81814. * @param position sets the position of the decal in world coordinates
  81815. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81816. * @param size sets the decal scaling
  81817. * @param angle sets the angle to rotate the decal
  81818. * @returns a new Mesh
  81819. */
  81820. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81821. /**
  81822. * Prepare internal position array for software CPU skinning
  81823. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81824. */
  81825. setPositionsForCPUSkinning(): Float32Array;
  81826. /**
  81827. * Prepare internal normal array for software CPU skinning
  81828. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81829. */
  81830. setNormalsForCPUSkinning(): Float32Array;
  81831. /**
  81832. * Updates the vertex buffer by applying transformation from the bones
  81833. * @param skeleton defines the skeleton to apply to current mesh
  81834. * @returns the current mesh
  81835. */
  81836. applySkeleton(skeleton: Skeleton): Mesh;
  81837. /**
  81838. * 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
  81839. * @param meshes defines the list of meshes to scan
  81840. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81841. */
  81842. static MinMax(meshes: AbstractMesh[]): {
  81843. min: Vector3;
  81844. max: Vector3;
  81845. };
  81846. /**
  81847. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81848. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81849. * @returns a vector3
  81850. */
  81851. static Center(meshesOrMinMaxVector: {
  81852. min: Vector3;
  81853. max: Vector3;
  81854. } | AbstractMesh[]): Vector3;
  81855. /**
  81856. * Merge the array of meshes into a single mesh for performance reasons.
  81857. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81858. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81859. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81860. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81861. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81862. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81863. * @returns a new mesh
  81864. */
  81865. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81866. /** @hidden */
  81867. addInstance(instance: InstancedMesh): void;
  81868. /** @hidden */
  81869. removeInstance(instance: InstancedMesh): void;
  81870. }
  81871. }
  81872. declare module BABYLON {
  81873. /**
  81874. * Base class for the main features of a material in Babylon.js
  81875. */
  81876. export class Material implements IAnimatable {
  81877. /**
  81878. * Returns the triangle fill mode
  81879. */
  81880. static readonly TriangleFillMode: number;
  81881. /**
  81882. * Returns the wireframe mode
  81883. */
  81884. static readonly WireFrameFillMode: number;
  81885. /**
  81886. * Returns the point fill mode
  81887. */
  81888. static readonly PointFillMode: number;
  81889. /**
  81890. * Returns the point list draw mode
  81891. */
  81892. static readonly PointListDrawMode: number;
  81893. /**
  81894. * Returns the line list draw mode
  81895. */
  81896. static readonly LineListDrawMode: number;
  81897. /**
  81898. * Returns the line loop draw mode
  81899. */
  81900. static readonly LineLoopDrawMode: number;
  81901. /**
  81902. * Returns the line strip draw mode
  81903. */
  81904. static readonly LineStripDrawMode: number;
  81905. /**
  81906. * Returns the triangle strip draw mode
  81907. */
  81908. static readonly TriangleStripDrawMode: number;
  81909. /**
  81910. * Returns the triangle fan draw mode
  81911. */
  81912. static readonly TriangleFanDrawMode: number;
  81913. /**
  81914. * Stores the clock-wise side orientation
  81915. */
  81916. static readonly ClockWiseSideOrientation: number;
  81917. /**
  81918. * Stores the counter clock-wise side orientation
  81919. */
  81920. static readonly CounterClockWiseSideOrientation: number;
  81921. /**
  81922. * The dirty texture flag value
  81923. */
  81924. static readonly TextureDirtyFlag: number;
  81925. /**
  81926. * The dirty light flag value
  81927. */
  81928. static readonly LightDirtyFlag: number;
  81929. /**
  81930. * The dirty fresnel flag value
  81931. */
  81932. static readonly FresnelDirtyFlag: number;
  81933. /**
  81934. * The dirty attribute flag value
  81935. */
  81936. static readonly AttributesDirtyFlag: number;
  81937. /**
  81938. * The dirty misc flag value
  81939. */
  81940. static readonly MiscDirtyFlag: number;
  81941. /**
  81942. * The all dirty flag value
  81943. */
  81944. static readonly AllDirtyFlag: number;
  81945. /**
  81946. * The ID of the material
  81947. */
  81948. id: string;
  81949. /**
  81950. * Gets or sets the unique id of the material
  81951. */
  81952. uniqueId: number;
  81953. /**
  81954. * The name of the material
  81955. */
  81956. name: string;
  81957. /**
  81958. * Gets or sets user defined metadata
  81959. */
  81960. metadata: any;
  81961. /**
  81962. * For internal use only. Please do not use.
  81963. */
  81964. reservedDataStore: any;
  81965. /**
  81966. * Specifies if the ready state should be checked on each call
  81967. */
  81968. checkReadyOnEveryCall: boolean;
  81969. /**
  81970. * Specifies if the ready state should be checked once
  81971. */
  81972. checkReadyOnlyOnce: boolean;
  81973. /**
  81974. * The state of the material
  81975. */
  81976. state: string;
  81977. /**
  81978. * The alpha value of the material
  81979. */
  81980. protected _alpha: number;
  81981. /**
  81982. * List of inspectable custom properties (used by the Inspector)
  81983. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81984. */
  81985. inspectableCustomProperties: IInspectable[];
  81986. /**
  81987. * Sets the alpha value of the material
  81988. */
  81989. /**
  81990. * Gets the alpha value of the material
  81991. */
  81992. alpha: number;
  81993. /**
  81994. * Specifies if back face culling is enabled
  81995. */
  81996. protected _backFaceCulling: boolean;
  81997. /**
  81998. * Sets the back-face culling state
  81999. */
  82000. /**
  82001. * Gets the back-face culling state
  82002. */
  82003. backFaceCulling: boolean;
  82004. /**
  82005. * Stores the value for side orientation
  82006. */
  82007. sideOrientation: number;
  82008. /**
  82009. * Callback triggered when the material is compiled
  82010. */
  82011. onCompiled: Nullable<(effect: Effect) => void>;
  82012. /**
  82013. * Callback triggered when an error occurs
  82014. */
  82015. onError: Nullable<(effect: Effect, errors: string) => void>;
  82016. /**
  82017. * Callback triggered to get the render target textures
  82018. */
  82019. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  82020. /**
  82021. * Gets a boolean indicating that current material needs to register RTT
  82022. */
  82023. readonly hasRenderTargetTextures: boolean;
  82024. /**
  82025. * Specifies if the material should be serialized
  82026. */
  82027. doNotSerialize: boolean;
  82028. /**
  82029. * @hidden
  82030. */
  82031. _storeEffectOnSubMeshes: boolean;
  82032. /**
  82033. * Stores the animations for the material
  82034. */
  82035. animations: Nullable<Array<Animation>>;
  82036. /**
  82037. * An event triggered when the material is disposed
  82038. */
  82039. onDisposeObservable: Observable<Material>;
  82040. /**
  82041. * An observer which watches for dispose events
  82042. */
  82043. private _onDisposeObserver;
  82044. private _onUnBindObservable;
  82045. /**
  82046. * Called during a dispose event
  82047. */
  82048. onDispose: () => void;
  82049. private _onBindObservable;
  82050. /**
  82051. * An event triggered when the material is bound
  82052. */
  82053. readonly onBindObservable: Observable<AbstractMesh>;
  82054. /**
  82055. * An observer which watches for bind events
  82056. */
  82057. private _onBindObserver;
  82058. /**
  82059. * Called during a bind event
  82060. */
  82061. onBind: (Mesh: AbstractMesh) => void;
  82062. /**
  82063. * An event triggered when the material is unbound
  82064. */
  82065. readonly onUnBindObservable: Observable<Material>;
  82066. /**
  82067. * Stores the value of the alpha mode
  82068. */
  82069. private _alphaMode;
  82070. /**
  82071. * Sets the value of the alpha mode.
  82072. *
  82073. * | Value | Type | Description |
  82074. * | --- | --- | --- |
  82075. * | 0 | ALPHA_DISABLE | |
  82076. * | 1 | ALPHA_ADD | |
  82077. * | 2 | ALPHA_COMBINE | |
  82078. * | 3 | ALPHA_SUBTRACT | |
  82079. * | 4 | ALPHA_MULTIPLY | |
  82080. * | 5 | ALPHA_MAXIMIZED | |
  82081. * | 6 | ALPHA_ONEONE | |
  82082. * | 7 | ALPHA_PREMULTIPLIED | |
  82083. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  82084. * | 9 | ALPHA_INTERPOLATE | |
  82085. * | 10 | ALPHA_SCREENMODE | |
  82086. *
  82087. */
  82088. /**
  82089. * Gets the value of the alpha mode
  82090. */
  82091. alphaMode: number;
  82092. /**
  82093. * Stores the state of the need depth pre-pass value
  82094. */
  82095. private _needDepthPrePass;
  82096. /**
  82097. * Sets the need depth pre-pass value
  82098. */
  82099. /**
  82100. * Gets the depth pre-pass value
  82101. */
  82102. needDepthPrePass: boolean;
  82103. /**
  82104. * Specifies if depth writing should be disabled
  82105. */
  82106. disableDepthWrite: boolean;
  82107. /**
  82108. * Specifies if depth writing should be forced
  82109. */
  82110. forceDepthWrite: boolean;
  82111. /**
  82112. * Specifies if there should be a separate pass for culling
  82113. */
  82114. separateCullingPass: boolean;
  82115. /**
  82116. * Stores the state specifing if fog should be enabled
  82117. */
  82118. private _fogEnabled;
  82119. /**
  82120. * Sets the state for enabling fog
  82121. */
  82122. /**
  82123. * Gets the value of the fog enabled state
  82124. */
  82125. fogEnabled: boolean;
  82126. /**
  82127. * Stores the size of points
  82128. */
  82129. pointSize: number;
  82130. /**
  82131. * Stores the z offset value
  82132. */
  82133. zOffset: number;
  82134. /**
  82135. * Gets a value specifying if wireframe mode is enabled
  82136. */
  82137. /**
  82138. * Sets the state of wireframe mode
  82139. */
  82140. wireframe: boolean;
  82141. /**
  82142. * Gets the value specifying if point clouds are enabled
  82143. */
  82144. /**
  82145. * Sets the state of point cloud mode
  82146. */
  82147. pointsCloud: boolean;
  82148. /**
  82149. * Gets the material fill mode
  82150. */
  82151. /**
  82152. * Sets the material fill mode
  82153. */
  82154. fillMode: number;
  82155. /**
  82156. * @hidden
  82157. * Stores the effects for the material
  82158. */
  82159. _effect: Nullable<Effect>;
  82160. /**
  82161. * @hidden
  82162. * Specifies if the material was previously ready
  82163. */
  82164. _wasPreviouslyReady: boolean;
  82165. /**
  82166. * Specifies if uniform buffers should be used
  82167. */
  82168. private _useUBO;
  82169. /**
  82170. * Stores a reference to the scene
  82171. */
  82172. private _scene;
  82173. /**
  82174. * Stores the fill mode state
  82175. */
  82176. private _fillMode;
  82177. /**
  82178. * Specifies if the depth write state should be cached
  82179. */
  82180. private _cachedDepthWriteState;
  82181. /**
  82182. * Stores the uniform buffer
  82183. */
  82184. protected _uniformBuffer: UniformBuffer;
  82185. /** @hidden */
  82186. _indexInSceneMaterialArray: number;
  82187. /** @hidden */
  82188. meshMap: Nullable<{
  82189. [id: string]: AbstractMesh | undefined;
  82190. }>;
  82191. /**
  82192. * Creates a material instance
  82193. * @param name defines the name of the material
  82194. * @param scene defines the scene to reference
  82195. * @param doNotAdd specifies if the material should be added to the scene
  82196. */
  82197. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  82198. /**
  82199. * Returns a string representation of the current material
  82200. * @param fullDetails defines a boolean indicating which levels of logging is desired
  82201. * @returns a string with material information
  82202. */
  82203. toString(fullDetails?: boolean): string;
  82204. /**
  82205. * Gets the class name of the material
  82206. * @returns a string with the class name of the material
  82207. */
  82208. getClassName(): string;
  82209. /**
  82210. * Specifies if updates for the material been locked
  82211. */
  82212. readonly isFrozen: boolean;
  82213. /**
  82214. * Locks updates for the material
  82215. */
  82216. freeze(): void;
  82217. /**
  82218. * Unlocks updates for the material
  82219. */
  82220. unfreeze(): void;
  82221. /**
  82222. * Specifies if the material is ready to be used
  82223. * @param mesh defines the mesh to check
  82224. * @param useInstances specifies if instances should be used
  82225. * @returns a boolean indicating if the material is ready to be used
  82226. */
  82227. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82228. /**
  82229. * Specifies that the submesh is ready to be used
  82230. * @param mesh defines the mesh to check
  82231. * @param subMesh defines which submesh to check
  82232. * @param useInstances specifies that instances should be used
  82233. * @returns a boolean indicating that the submesh is ready or not
  82234. */
  82235. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82236. /**
  82237. * Returns the material effect
  82238. * @returns the effect associated with the material
  82239. */
  82240. getEffect(): Nullable<Effect>;
  82241. /**
  82242. * Returns the current scene
  82243. * @returns a Scene
  82244. */
  82245. getScene(): Scene;
  82246. /**
  82247. * Specifies if the material will require alpha blending
  82248. * @returns a boolean specifying if alpha blending is needed
  82249. */
  82250. needAlphaBlending(): boolean;
  82251. /**
  82252. * Specifies if the mesh will require alpha blending
  82253. * @param mesh defines the mesh to check
  82254. * @returns a boolean specifying if alpha blending is needed for the mesh
  82255. */
  82256. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  82257. /**
  82258. * Specifies if this material should be rendered in alpha test mode
  82259. * @returns a boolean specifying if an alpha test is needed.
  82260. */
  82261. needAlphaTesting(): boolean;
  82262. /**
  82263. * Gets the texture used for the alpha test
  82264. * @returns the texture to use for alpha testing
  82265. */
  82266. getAlphaTestTexture(): Nullable<BaseTexture>;
  82267. /**
  82268. * Marks the material to indicate that it needs to be re-calculated
  82269. */
  82270. markDirty(): void;
  82271. /** @hidden */
  82272. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  82273. /**
  82274. * Binds the material to the mesh
  82275. * @param world defines the world transformation matrix
  82276. * @param mesh defines the mesh to bind the material to
  82277. */
  82278. bind(world: Matrix, mesh?: Mesh): void;
  82279. /**
  82280. * Binds the submesh to the material
  82281. * @param world defines the world transformation matrix
  82282. * @param mesh defines the mesh containing the submesh
  82283. * @param subMesh defines the submesh to bind the material to
  82284. */
  82285. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  82286. /**
  82287. * Binds the world matrix to the material
  82288. * @param world defines the world transformation matrix
  82289. */
  82290. bindOnlyWorldMatrix(world: Matrix): void;
  82291. /**
  82292. * Binds the scene's uniform buffer to the effect.
  82293. * @param effect defines the effect to bind to the scene uniform buffer
  82294. * @param sceneUbo defines the uniform buffer storing scene data
  82295. */
  82296. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  82297. /**
  82298. * Binds the view matrix to the effect
  82299. * @param effect defines the effect to bind the view matrix to
  82300. */
  82301. bindView(effect: Effect): void;
  82302. /**
  82303. * Binds the view projection matrix to the effect
  82304. * @param effect defines the effect to bind the view projection matrix to
  82305. */
  82306. bindViewProjection(effect: Effect): void;
  82307. /**
  82308. * Specifies if material alpha testing should be turned on for the mesh
  82309. * @param mesh defines the mesh to check
  82310. */
  82311. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82312. /**
  82313. * Processes to execute after binding the material to a mesh
  82314. * @param mesh defines the rendered mesh
  82315. */
  82316. protected _afterBind(mesh?: Mesh): void;
  82317. /**
  82318. * Unbinds the material from the mesh
  82319. */
  82320. unbind(): void;
  82321. /**
  82322. * Gets the active textures from the material
  82323. * @returns an array of textures
  82324. */
  82325. getActiveTextures(): BaseTexture[];
  82326. /**
  82327. * Specifies if the material uses a texture
  82328. * @param texture defines the texture to check against the material
  82329. * @returns a boolean specifying if the material uses the texture
  82330. */
  82331. hasTexture(texture: BaseTexture): boolean;
  82332. /**
  82333. * Makes a duplicate of the material, and gives it a new name
  82334. * @param name defines the new name for the duplicated material
  82335. * @returns the cloned material
  82336. */
  82337. clone(name: string): Nullable<Material>;
  82338. /**
  82339. * Gets the meshes bound to the material
  82340. * @returns an array of meshes bound to the material
  82341. */
  82342. getBindedMeshes(): AbstractMesh[];
  82343. /**
  82344. * Force shader compilation
  82345. * @param mesh defines the mesh associated with this material
  82346. * @param onCompiled defines a function to execute once the material is compiled
  82347. * @param options defines the options to configure the compilation
  82348. */
  82349. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82350. clipPlane: boolean;
  82351. }>): void;
  82352. /**
  82353. * Force shader compilation
  82354. * @param mesh defines the mesh that will use this material
  82355. * @param options defines additional options for compiling the shaders
  82356. * @returns a promise that resolves when the compilation completes
  82357. */
  82358. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82359. clipPlane: boolean;
  82360. }>): Promise<void>;
  82361. private static readonly _ImageProcessingDirtyCallBack;
  82362. private static readonly _TextureDirtyCallBack;
  82363. private static readonly _FresnelDirtyCallBack;
  82364. private static readonly _MiscDirtyCallBack;
  82365. private static readonly _LightsDirtyCallBack;
  82366. private static readonly _AttributeDirtyCallBack;
  82367. private static _FresnelAndMiscDirtyCallBack;
  82368. private static _TextureAndMiscDirtyCallBack;
  82369. private static readonly _DirtyCallbackArray;
  82370. private static readonly _RunDirtyCallBacks;
  82371. /**
  82372. * Marks a define in the material to indicate that it needs to be re-computed
  82373. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82374. */
  82375. markAsDirty(flag: number): void;
  82376. /**
  82377. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82378. * @param func defines a function which checks material defines against the submeshes
  82379. */
  82380. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82381. /**
  82382. * Indicates that image processing needs to be re-calculated for all submeshes
  82383. */
  82384. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82385. /**
  82386. * Indicates that textures need to be re-calculated for all submeshes
  82387. */
  82388. protected _markAllSubMeshesAsTexturesDirty(): void;
  82389. /**
  82390. * Indicates that fresnel needs to be re-calculated for all submeshes
  82391. */
  82392. protected _markAllSubMeshesAsFresnelDirty(): void;
  82393. /**
  82394. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82395. */
  82396. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82397. /**
  82398. * Indicates that lights need to be re-calculated for all submeshes
  82399. */
  82400. protected _markAllSubMeshesAsLightsDirty(): void;
  82401. /**
  82402. * Indicates that attributes need to be re-calculated for all submeshes
  82403. */
  82404. protected _markAllSubMeshesAsAttributesDirty(): void;
  82405. /**
  82406. * Indicates that misc needs to be re-calculated for all submeshes
  82407. */
  82408. protected _markAllSubMeshesAsMiscDirty(): void;
  82409. /**
  82410. * Indicates that textures and misc need to be re-calculated for all submeshes
  82411. */
  82412. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82413. /**
  82414. * Disposes the material
  82415. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82416. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82417. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82418. */
  82419. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82420. /** @hidden */
  82421. private releaseVertexArrayObject;
  82422. /**
  82423. * Serializes this material
  82424. * @returns the serialized material object
  82425. */
  82426. serialize(): any;
  82427. /**
  82428. * Creates a material from parsed material data
  82429. * @param parsedMaterial defines parsed material data
  82430. * @param scene defines the hosting scene
  82431. * @param rootUrl defines the root URL to use to load textures
  82432. * @returns a new material
  82433. */
  82434. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82435. }
  82436. }
  82437. declare module BABYLON {
  82438. /**
  82439. * Base class for submeshes
  82440. */
  82441. export class BaseSubMesh {
  82442. /** @hidden */
  82443. _materialDefines: Nullable<MaterialDefines>;
  82444. /** @hidden */
  82445. _materialEffect: Nullable<Effect>;
  82446. /**
  82447. * Gets associated effect
  82448. */
  82449. readonly effect: Nullable<Effect>;
  82450. /**
  82451. * Sets associated effect (effect used to render this submesh)
  82452. * @param effect defines the effect to associate with
  82453. * @param defines defines the set of defines used to compile this effect
  82454. */
  82455. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82456. }
  82457. /**
  82458. * Defines a subdivision inside a mesh
  82459. */
  82460. export class SubMesh extends BaseSubMesh implements ICullable {
  82461. /** the material index to use */
  82462. materialIndex: number;
  82463. /** vertex index start */
  82464. verticesStart: number;
  82465. /** vertices count */
  82466. verticesCount: number;
  82467. /** index start */
  82468. indexStart: number;
  82469. /** indices count */
  82470. indexCount: number;
  82471. /** @hidden */
  82472. _linesIndexCount: number;
  82473. private _mesh;
  82474. private _renderingMesh;
  82475. private _boundingInfo;
  82476. private _linesIndexBuffer;
  82477. /** @hidden */
  82478. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82479. /** @hidden */
  82480. _trianglePlanes: Plane[];
  82481. /** @hidden */
  82482. _lastColliderTransformMatrix: Nullable<Matrix>;
  82483. /** @hidden */
  82484. _renderId: number;
  82485. /** @hidden */
  82486. _alphaIndex: number;
  82487. /** @hidden */
  82488. _distanceToCamera: number;
  82489. /** @hidden */
  82490. _id: number;
  82491. private _currentMaterial;
  82492. /**
  82493. * Add a new submesh to a mesh
  82494. * @param materialIndex defines the material index to use
  82495. * @param verticesStart defines vertex index start
  82496. * @param verticesCount defines vertices count
  82497. * @param indexStart defines index start
  82498. * @param indexCount defines indices count
  82499. * @param mesh defines the parent mesh
  82500. * @param renderingMesh defines an optional rendering mesh
  82501. * @param createBoundingBox defines if bounding box should be created for this submesh
  82502. * @returns the new submesh
  82503. */
  82504. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82505. /**
  82506. * Creates a new submesh
  82507. * @param materialIndex defines the material index to use
  82508. * @param verticesStart defines vertex index start
  82509. * @param verticesCount defines vertices count
  82510. * @param indexStart defines index start
  82511. * @param indexCount defines indices count
  82512. * @param mesh defines the parent mesh
  82513. * @param renderingMesh defines an optional rendering mesh
  82514. * @param createBoundingBox defines if bounding box should be created for this submesh
  82515. */
  82516. constructor(
  82517. /** the material index to use */
  82518. materialIndex: number,
  82519. /** vertex index start */
  82520. verticesStart: number,
  82521. /** vertices count */
  82522. verticesCount: number,
  82523. /** index start */
  82524. indexStart: number,
  82525. /** indices count */
  82526. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82527. /**
  82528. * Returns true if this submesh covers the entire parent mesh
  82529. * @ignorenaming
  82530. */
  82531. readonly IsGlobal: boolean;
  82532. /**
  82533. * Returns the submesh BoudingInfo object
  82534. * @returns current bounding info (or mesh's one if the submesh is global)
  82535. */
  82536. getBoundingInfo(): BoundingInfo;
  82537. /**
  82538. * Sets the submesh BoundingInfo
  82539. * @param boundingInfo defines the new bounding info to use
  82540. * @returns the SubMesh
  82541. */
  82542. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82543. /**
  82544. * Returns the mesh of the current submesh
  82545. * @return the parent mesh
  82546. */
  82547. getMesh(): AbstractMesh;
  82548. /**
  82549. * Returns the rendering mesh of the submesh
  82550. * @returns the rendering mesh (could be different from parent mesh)
  82551. */
  82552. getRenderingMesh(): Mesh;
  82553. /**
  82554. * Returns the submesh material
  82555. * @returns null or the current material
  82556. */
  82557. getMaterial(): Nullable<Material>;
  82558. /**
  82559. * Sets a new updated BoundingInfo object to the submesh
  82560. * @param data defines an optional position array to use to determine the bounding info
  82561. * @returns the SubMesh
  82562. */
  82563. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82564. /** @hidden */
  82565. _checkCollision(collider: Collider): boolean;
  82566. /**
  82567. * Updates the submesh BoundingInfo
  82568. * @param world defines the world matrix to use to update the bounding info
  82569. * @returns the submesh
  82570. */
  82571. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82572. /**
  82573. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82574. * @param frustumPlanes defines the frustum planes
  82575. * @returns true if the submesh is intersecting with the frustum
  82576. */
  82577. isInFrustum(frustumPlanes: Plane[]): boolean;
  82578. /**
  82579. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82580. * @param frustumPlanes defines the frustum planes
  82581. * @returns true if the submesh is inside the frustum
  82582. */
  82583. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82584. /**
  82585. * Renders the submesh
  82586. * @param enableAlphaMode defines if alpha needs to be used
  82587. * @returns the submesh
  82588. */
  82589. render(enableAlphaMode: boolean): SubMesh;
  82590. /**
  82591. * @hidden
  82592. */
  82593. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82594. /**
  82595. * Checks if the submesh intersects with a ray
  82596. * @param ray defines the ray to test
  82597. * @returns true is the passed ray intersects the submesh bounding box
  82598. */
  82599. canIntersects(ray: Ray): boolean;
  82600. /**
  82601. * Intersects current submesh with a ray
  82602. * @param ray defines the ray to test
  82603. * @param positions defines mesh's positions array
  82604. * @param indices defines mesh's indices array
  82605. * @param fastCheck defines if only bounding info should be used
  82606. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82607. * @returns intersection info or null if no intersection
  82608. */
  82609. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82610. /** @hidden */
  82611. private _intersectLines;
  82612. /** @hidden */
  82613. private _intersectTriangles;
  82614. /** @hidden */
  82615. _rebuild(): void;
  82616. /**
  82617. * Creates a new submesh from the passed mesh
  82618. * @param newMesh defines the new hosting mesh
  82619. * @param newRenderingMesh defines an optional rendering mesh
  82620. * @returns the new submesh
  82621. */
  82622. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82623. /**
  82624. * Release associated resources
  82625. */
  82626. dispose(): void;
  82627. /**
  82628. * Gets the class name
  82629. * @returns the string "SubMesh".
  82630. */
  82631. getClassName(): string;
  82632. /**
  82633. * Creates a new submesh from indices data
  82634. * @param materialIndex the index of the main mesh material
  82635. * @param startIndex the index where to start the copy in the mesh indices array
  82636. * @param indexCount the number of indices to copy then from the startIndex
  82637. * @param mesh the main mesh to create the submesh from
  82638. * @param renderingMesh the optional rendering mesh
  82639. * @returns a new submesh
  82640. */
  82641. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82642. }
  82643. }
  82644. declare module BABYLON {
  82645. /**
  82646. * Class used to store geometry data (vertex buffers + index buffer)
  82647. */
  82648. export class Geometry implements IGetSetVerticesData {
  82649. /**
  82650. * Gets or sets the ID of the geometry
  82651. */
  82652. id: string;
  82653. /**
  82654. * Gets or sets the unique ID of the geometry
  82655. */
  82656. uniqueId: number;
  82657. /**
  82658. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82659. */
  82660. delayLoadState: number;
  82661. /**
  82662. * Gets the file containing the data to load when running in delay load state
  82663. */
  82664. delayLoadingFile: Nullable<string>;
  82665. /**
  82666. * Callback called when the geometry is updated
  82667. */
  82668. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82669. private _scene;
  82670. private _engine;
  82671. private _meshes;
  82672. private _totalVertices;
  82673. /** @hidden */
  82674. _indices: IndicesArray;
  82675. /** @hidden */
  82676. _vertexBuffers: {
  82677. [key: string]: VertexBuffer;
  82678. };
  82679. private _isDisposed;
  82680. private _extend;
  82681. private _boundingBias;
  82682. /** @hidden */
  82683. _delayInfo: Array<string>;
  82684. private _indexBuffer;
  82685. private _indexBufferIsUpdatable;
  82686. /** @hidden */
  82687. _boundingInfo: Nullable<BoundingInfo>;
  82688. /** @hidden */
  82689. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82690. /** @hidden */
  82691. _softwareSkinningFrameId: number;
  82692. private _vertexArrayObjects;
  82693. private _updatable;
  82694. /** @hidden */
  82695. _positions: Nullable<Vector3[]>;
  82696. /**
  82697. * 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
  82698. */
  82699. /**
  82700. * 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
  82701. */
  82702. boundingBias: Vector2;
  82703. /**
  82704. * Static function used to attach a new empty geometry to a mesh
  82705. * @param mesh defines the mesh to attach the geometry to
  82706. * @returns the new Geometry
  82707. */
  82708. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82709. /**
  82710. * Creates a new geometry
  82711. * @param id defines the unique ID
  82712. * @param scene defines the hosting scene
  82713. * @param vertexData defines the VertexData used to get geometry data
  82714. * @param updatable defines if geometry must be updatable (false by default)
  82715. * @param mesh defines the mesh that will be associated with the geometry
  82716. */
  82717. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82718. /**
  82719. * Gets the current extend of the geometry
  82720. */
  82721. readonly extend: {
  82722. minimum: Vector3;
  82723. maximum: Vector3;
  82724. };
  82725. /**
  82726. * Gets the hosting scene
  82727. * @returns the hosting Scene
  82728. */
  82729. getScene(): Scene;
  82730. /**
  82731. * Gets the hosting engine
  82732. * @returns the hosting Engine
  82733. */
  82734. getEngine(): Engine;
  82735. /**
  82736. * Defines if the geometry is ready to use
  82737. * @returns true if the geometry is ready to be used
  82738. */
  82739. isReady(): boolean;
  82740. /**
  82741. * Gets a value indicating that the geometry should not be serialized
  82742. */
  82743. readonly doNotSerialize: boolean;
  82744. /** @hidden */
  82745. _rebuild(): void;
  82746. /**
  82747. * Affects all geometry data in one call
  82748. * @param vertexData defines the geometry data
  82749. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82750. */
  82751. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82752. /**
  82753. * Set specific vertex data
  82754. * @param kind defines the data kind (Position, normal, etc...)
  82755. * @param data defines the vertex data to use
  82756. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82757. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82758. */
  82759. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82760. /**
  82761. * Removes a specific vertex data
  82762. * @param kind defines the data kind (Position, normal, etc...)
  82763. */
  82764. removeVerticesData(kind: string): void;
  82765. /**
  82766. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82767. * @param buffer defines the vertex buffer to use
  82768. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82769. */
  82770. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82771. /**
  82772. * Update a specific vertex buffer
  82773. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82774. * It will do nothing if the buffer is not updatable
  82775. * @param kind defines the data kind (Position, normal, etc...)
  82776. * @param data defines the data to use
  82777. * @param offset defines the offset in the target buffer where to store the data
  82778. * @param useBytes set to true if the offset is in bytes
  82779. */
  82780. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82781. /**
  82782. * Update a specific vertex buffer
  82783. * This function will create a new buffer if the current one is not updatable
  82784. * @param kind defines the data kind (Position, normal, etc...)
  82785. * @param data defines the data to use
  82786. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82787. */
  82788. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82789. private _updateBoundingInfo;
  82790. /** @hidden */
  82791. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82792. /**
  82793. * Gets total number of vertices
  82794. * @returns the total number of vertices
  82795. */
  82796. getTotalVertices(): number;
  82797. /**
  82798. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82799. * @param kind defines the data kind (Position, normal, etc...)
  82800. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82801. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82802. * @returns a float array containing vertex data
  82803. */
  82804. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82805. /**
  82806. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82807. * @param kind defines the data kind (Position, normal, etc...)
  82808. * @returns true if the vertex buffer with the specified kind is updatable
  82809. */
  82810. isVertexBufferUpdatable(kind: string): boolean;
  82811. /**
  82812. * Gets a specific vertex buffer
  82813. * @param kind defines the data kind (Position, normal, etc...)
  82814. * @returns a VertexBuffer
  82815. */
  82816. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82817. /**
  82818. * Returns all vertex buffers
  82819. * @return an object holding all vertex buffers indexed by kind
  82820. */
  82821. getVertexBuffers(): Nullable<{
  82822. [key: string]: VertexBuffer;
  82823. }>;
  82824. /**
  82825. * Gets a boolean indicating if specific vertex buffer is present
  82826. * @param kind defines the data kind (Position, normal, etc...)
  82827. * @returns true if data is present
  82828. */
  82829. isVerticesDataPresent(kind: string): boolean;
  82830. /**
  82831. * Gets a list of all attached data kinds (Position, normal, etc...)
  82832. * @returns a list of string containing all kinds
  82833. */
  82834. getVerticesDataKinds(): string[];
  82835. /**
  82836. * Update index buffer
  82837. * @param indices defines the indices to store in the index buffer
  82838. * @param offset defines the offset in the target buffer where to store the data
  82839. * @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)
  82840. */
  82841. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82842. /**
  82843. * Creates a new index buffer
  82844. * @param indices defines the indices to store in the index buffer
  82845. * @param totalVertices defines the total number of vertices (could be null)
  82846. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82847. */
  82848. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82849. /**
  82850. * Return the total number of indices
  82851. * @returns the total number of indices
  82852. */
  82853. getTotalIndices(): number;
  82854. /**
  82855. * Gets the index buffer array
  82856. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82857. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82858. * @returns the index buffer array
  82859. */
  82860. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82861. /**
  82862. * Gets the index buffer
  82863. * @return the index buffer
  82864. */
  82865. getIndexBuffer(): Nullable<DataBuffer>;
  82866. /** @hidden */
  82867. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82868. /**
  82869. * Release the associated resources for a specific mesh
  82870. * @param mesh defines the source mesh
  82871. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82872. */
  82873. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82874. /**
  82875. * Apply current geometry to a given mesh
  82876. * @param mesh defines the mesh to apply geometry to
  82877. */
  82878. applyToMesh(mesh: Mesh): void;
  82879. private _updateExtend;
  82880. private _applyToMesh;
  82881. private notifyUpdate;
  82882. /**
  82883. * Load the geometry if it was flagged as delay loaded
  82884. * @param scene defines the hosting scene
  82885. * @param onLoaded defines a callback called when the geometry is loaded
  82886. */
  82887. load(scene: Scene, onLoaded?: () => void): void;
  82888. private _queueLoad;
  82889. /**
  82890. * Invert the geometry to move from a right handed system to a left handed one.
  82891. */
  82892. toLeftHanded(): void;
  82893. /** @hidden */
  82894. _resetPointsArrayCache(): void;
  82895. /** @hidden */
  82896. _generatePointsArray(): boolean;
  82897. /**
  82898. * Gets a value indicating if the geometry is disposed
  82899. * @returns true if the geometry was disposed
  82900. */
  82901. isDisposed(): boolean;
  82902. private _disposeVertexArrayObjects;
  82903. /**
  82904. * Free all associated resources
  82905. */
  82906. dispose(): void;
  82907. /**
  82908. * Clone the current geometry into a new geometry
  82909. * @param id defines the unique ID of the new geometry
  82910. * @returns a new geometry object
  82911. */
  82912. copy(id: string): Geometry;
  82913. /**
  82914. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82915. * @return a JSON representation of the current geometry data (without the vertices data)
  82916. */
  82917. serialize(): any;
  82918. private toNumberArray;
  82919. /**
  82920. * Serialize all vertices data into a JSON oject
  82921. * @returns a JSON representation of the current geometry data
  82922. */
  82923. serializeVerticeData(): any;
  82924. /**
  82925. * Extracts a clone of a mesh geometry
  82926. * @param mesh defines the source mesh
  82927. * @param id defines the unique ID of the new geometry object
  82928. * @returns the new geometry object
  82929. */
  82930. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82931. /**
  82932. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82933. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82934. * Be aware Math.random() could cause collisions, but:
  82935. * "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"
  82936. * @returns a string containing a new GUID
  82937. */
  82938. static RandomId(): string;
  82939. /** @hidden */
  82940. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82941. private static _CleanMatricesWeights;
  82942. /**
  82943. * Create a new geometry from persisted data (Using .babylon file format)
  82944. * @param parsedVertexData defines the persisted data
  82945. * @param scene defines the hosting scene
  82946. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82947. * @returns the new geometry object
  82948. */
  82949. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82950. }
  82951. }
  82952. declare module BABYLON {
  82953. /**
  82954. * Define an interface for all classes that will get and set the data on vertices
  82955. */
  82956. export interface IGetSetVerticesData {
  82957. /**
  82958. * Gets a boolean indicating if specific vertex data is present
  82959. * @param kind defines the vertex data kind to use
  82960. * @returns true is data kind is present
  82961. */
  82962. isVerticesDataPresent(kind: string): boolean;
  82963. /**
  82964. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82965. * @param kind defines the data kind (Position, normal, etc...)
  82966. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82967. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82968. * @returns a float array containing vertex data
  82969. */
  82970. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82971. /**
  82972. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82973. * @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.
  82974. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82975. * @returns the indices array or an empty array if the mesh has no geometry
  82976. */
  82977. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82978. /**
  82979. * Set specific vertex data
  82980. * @param kind defines the data kind (Position, normal, etc...)
  82981. * @param data defines the vertex data to use
  82982. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82983. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82984. */
  82985. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82986. /**
  82987. * Update a specific associated vertex buffer
  82988. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82989. * - VertexBuffer.PositionKind
  82990. * - VertexBuffer.UVKind
  82991. * - VertexBuffer.UV2Kind
  82992. * - VertexBuffer.UV3Kind
  82993. * - VertexBuffer.UV4Kind
  82994. * - VertexBuffer.UV5Kind
  82995. * - VertexBuffer.UV6Kind
  82996. * - VertexBuffer.ColorKind
  82997. * - VertexBuffer.MatricesIndicesKind
  82998. * - VertexBuffer.MatricesIndicesExtraKind
  82999. * - VertexBuffer.MatricesWeightsKind
  83000. * - VertexBuffer.MatricesWeightsExtraKind
  83001. * @param data defines the data source
  83002. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83003. * @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)
  83004. */
  83005. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  83006. /**
  83007. * Creates a new index buffer
  83008. * @param indices defines the indices to store in the index buffer
  83009. * @param totalVertices defines the total number of vertices (could be null)
  83010. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  83011. */
  83012. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  83013. }
  83014. /**
  83015. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83016. */
  83017. export class VertexData {
  83018. /**
  83019. * Mesh side orientation : usually the external or front surface
  83020. */
  83021. static readonly FRONTSIDE: number;
  83022. /**
  83023. * Mesh side orientation : usually the internal or back surface
  83024. */
  83025. static readonly BACKSIDE: number;
  83026. /**
  83027. * Mesh side orientation : both internal and external or front and back surfaces
  83028. */
  83029. static readonly DOUBLESIDE: number;
  83030. /**
  83031. * Mesh side orientation : by default, `FRONTSIDE`
  83032. */
  83033. static readonly DEFAULTSIDE: number;
  83034. /**
  83035. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  83036. */
  83037. positions: Nullable<FloatArray>;
  83038. /**
  83039. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  83040. */
  83041. normals: Nullable<FloatArray>;
  83042. /**
  83043. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  83044. */
  83045. tangents: Nullable<FloatArray>;
  83046. /**
  83047. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83048. */
  83049. uvs: Nullable<FloatArray>;
  83050. /**
  83051. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83052. */
  83053. uvs2: Nullable<FloatArray>;
  83054. /**
  83055. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83056. */
  83057. uvs3: Nullable<FloatArray>;
  83058. /**
  83059. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83060. */
  83061. uvs4: Nullable<FloatArray>;
  83062. /**
  83063. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83064. */
  83065. uvs5: Nullable<FloatArray>;
  83066. /**
  83067. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83068. */
  83069. uvs6: Nullable<FloatArray>;
  83070. /**
  83071. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  83072. */
  83073. colors: Nullable<FloatArray>;
  83074. /**
  83075. * 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).
  83076. */
  83077. matricesIndices: Nullable<FloatArray>;
  83078. /**
  83079. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  83080. */
  83081. matricesWeights: Nullable<FloatArray>;
  83082. /**
  83083. * An array extending the number of possible indices
  83084. */
  83085. matricesIndicesExtra: Nullable<FloatArray>;
  83086. /**
  83087. * An array extending the number of possible weights when the number of indices is extended
  83088. */
  83089. matricesWeightsExtra: Nullable<FloatArray>;
  83090. /**
  83091. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  83092. */
  83093. indices: Nullable<IndicesArray>;
  83094. /**
  83095. * Uses the passed data array to set the set the values for the specified kind of data
  83096. * @param data a linear array of floating numbers
  83097. * @param kind the type of data that is being set, eg positions, colors etc
  83098. */
  83099. set(data: FloatArray, kind: string): void;
  83100. /**
  83101. * Associates the vertexData to the passed Mesh.
  83102. * Sets it as updatable or not (default `false`)
  83103. * @param mesh the mesh the vertexData is applied to
  83104. * @param updatable when used and having the value true allows new data to update the vertexData
  83105. * @returns the VertexData
  83106. */
  83107. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  83108. /**
  83109. * Associates the vertexData to the passed Geometry.
  83110. * Sets it as updatable or not (default `false`)
  83111. * @param geometry the geometry the vertexData is applied to
  83112. * @param updatable when used and having the value true allows new data to update the vertexData
  83113. * @returns VertexData
  83114. */
  83115. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  83116. /**
  83117. * Updates the associated mesh
  83118. * @param mesh the mesh to be updated
  83119. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83120. * @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
  83121. * @returns VertexData
  83122. */
  83123. updateMesh(mesh: Mesh): VertexData;
  83124. /**
  83125. * Updates the associated geometry
  83126. * @param geometry the geometry to be updated
  83127. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83128. * @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
  83129. * @returns VertexData.
  83130. */
  83131. updateGeometry(geometry: Geometry): VertexData;
  83132. private _applyTo;
  83133. private _update;
  83134. /**
  83135. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83136. * @param matrix the transforming matrix
  83137. * @returns the VertexData
  83138. */
  83139. transform(matrix: Matrix): VertexData;
  83140. /**
  83141. * Merges the passed VertexData into the current one
  83142. * @param other the VertexData to be merged into the current one
  83143. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83144. * @returns the modified VertexData
  83145. */
  83146. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  83147. private _mergeElement;
  83148. private _validate;
  83149. /**
  83150. * Serializes the VertexData
  83151. * @returns a serialized object
  83152. */
  83153. serialize(): any;
  83154. /**
  83155. * Extracts the vertexData from a mesh
  83156. * @param mesh the mesh from which to extract the VertexData
  83157. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83158. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83159. * @returns the object VertexData associated to the passed mesh
  83160. */
  83161. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83162. /**
  83163. * Extracts the vertexData from the geometry
  83164. * @param geometry the geometry from which to extract the VertexData
  83165. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83166. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83167. * @returns the object VertexData associated to the passed mesh
  83168. */
  83169. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83170. private static _ExtractFrom;
  83171. /**
  83172. * Creates the VertexData for a Ribbon
  83173. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83174. * * pathArray array of paths, each of which an array of successive Vector3
  83175. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83176. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83177. * * 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
  83178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83179. * * 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)
  83180. * * 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)
  83181. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83182. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83183. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83184. * @returns the VertexData of the ribbon
  83185. */
  83186. static CreateRibbon(options: {
  83187. pathArray: Vector3[][];
  83188. closeArray?: boolean;
  83189. closePath?: boolean;
  83190. offset?: number;
  83191. sideOrientation?: number;
  83192. frontUVs?: Vector4;
  83193. backUVs?: Vector4;
  83194. invertUV?: boolean;
  83195. uvs?: Vector2[];
  83196. colors?: Color4[];
  83197. }): VertexData;
  83198. /**
  83199. * Creates the VertexData for a box
  83200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83201. * * size sets the width, height and depth of the box to the value of size, optional default 1
  83202. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  83203. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  83204. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  83205. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  83206. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  83207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83208. * * 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)
  83209. * * 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)
  83210. * @returns the VertexData of the box
  83211. */
  83212. static CreateBox(options: {
  83213. size?: number;
  83214. width?: number;
  83215. height?: number;
  83216. depth?: number;
  83217. faceUV?: Vector4[];
  83218. faceColors?: Color4[];
  83219. sideOrientation?: number;
  83220. frontUVs?: Vector4;
  83221. backUVs?: Vector4;
  83222. }): VertexData;
  83223. /**
  83224. * Creates the VertexData for an ellipsoid, defaults to a sphere
  83225. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83226. * * segments sets the number of horizontal strips optional, default 32
  83227. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  83228. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  83229. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  83230. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  83231. * * 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
  83232. * * 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
  83233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83234. * * 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)
  83235. * * 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)
  83236. * @returns the VertexData of the ellipsoid
  83237. */
  83238. static CreateSphere(options: {
  83239. segments?: number;
  83240. diameter?: number;
  83241. diameterX?: number;
  83242. diameterY?: number;
  83243. diameterZ?: number;
  83244. arc?: number;
  83245. slice?: number;
  83246. sideOrientation?: number;
  83247. frontUVs?: Vector4;
  83248. backUVs?: Vector4;
  83249. }): VertexData;
  83250. /**
  83251. * Creates the VertexData for a cylinder, cone or prism
  83252. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83253. * * height sets the height (y direction) of the cylinder, optional, default 2
  83254. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  83255. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  83256. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  83257. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83258. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  83259. * * 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
  83260. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83261. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83262. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  83263. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  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 cylinder, cone or prism
  83268. */
  83269. static CreateCylinder(options: {
  83270. height?: number;
  83271. diameterTop?: number;
  83272. diameterBottom?: number;
  83273. diameter?: number;
  83274. tessellation?: number;
  83275. subdivisions?: number;
  83276. arc?: number;
  83277. faceColors?: Color4[];
  83278. faceUV?: Vector4[];
  83279. hasRings?: boolean;
  83280. enclose?: boolean;
  83281. sideOrientation?: number;
  83282. frontUVs?: Vector4;
  83283. backUVs?: Vector4;
  83284. }): VertexData;
  83285. /**
  83286. * Creates the VertexData for a torus
  83287. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83288. * * diameter the diameter of the torus, optional default 1
  83289. * * thickness the diameter of the tube forming the torus, optional default 0.5
  83290. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83291. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83292. * * 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)
  83293. * * 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)
  83294. * @returns the VertexData of the torus
  83295. */
  83296. static CreateTorus(options: {
  83297. diameter?: number;
  83298. thickness?: number;
  83299. tessellation?: number;
  83300. sideOrientation?: number;
  83301. frontUVs?: Vector4;
  83302. backUVs?: Vector4;
  83303. }): VertexData;
  83304. /**
  83305. * Creates the VertexData of the LineSystem
  83306. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83307. * - lines an array of lines, each line being an array of successive Vector3
  83308. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83309. * @returns the VertexData of the LineSystem
  83310. */
  83311. static CreateLineSystem(options: {
  83312. lines: Vector3[][];
  83313. colors?: Nullable<Color4[][]>;
  83314. }): VertexData;
  83315. /**
  83316. * Create the VertexData for a DashedLines
  83317. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83318. * - points an array successive Vector3
  83319. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83320. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83321. * - dashNb the intended total number of dashes, optional, default 200
  83322. * @returns the VertexData for the DashedLines
  83323. */
  83324. static CreateDashedLines(options: {
  83325. points: Vector3[];
  83326. dashSize?: number;
  83327. gapSize?: number;
  83328. dashNb?: number;
  83329. }): VertexData;
  83330. /**
  83331. * Creates the VertexData for a Ground
  83332. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83333. * - width the width (x direction) of the ground, optional, default 1
  83334. * - height the height (z direction) of the ground, optional, default 1
  83335. * - subdivisions the number of subdivisions per side, optional, default 1
  83336. * @returns the VertexData of the Ground
  83337. */
  83338. static CreateGround(options: {
  83339. width?: number;
  83340. height?: number;
  83341. subdivisions?: number;
  83342. subdivisionsX?: number;
  83343. subdivisionsY?: number;
  83344. }): VertexData;
  83345. /**
  83346. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83347. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83348. * * xmin the ground minimum X coordinate, optional, default -1
  83349. * * zmin the ground minimum Z coordinate, optional, default -1
  83350. * * xmax the ground maximum X coordinate, optional, default 1
  83351. * * zmax the ground maximum Z coordinate, optional, default 1
  83352. * * 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}
  83353. * * 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}
  83354. * @returns the VertexData of the TiledGround
  83355. */
  83356. static CreateTiledGround(options: {
  83357. xmin: number;
  83358. zmin: number;
  83359. xmax: number;
  83360. zmax: number;
  83361. subdivisions?: {
  83362. w: number;
  83363. h: number;
  83364. };
  83365. precision?: {
  83366. w: number;
  83367. h: number;
  83368. };
  83369. }): VertexData;
  83370. /**
  83371. * Creates the VertexData of the Ground designed from a heightmap
  83372. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83373. * * width the width (x direction) of the ground
  83374. * * height the height (z direction) of the ground
  83375. * * subdivisions the number of subdivisions per side
  83376. * * minHeight the minimum altitude on the ground, optional, default 0
  83377. * * maxHeight the maximum altitude on the ground, optional default 1
  83378. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83379. * * buffer the array holding the image color data
  83380. * * bufferWidth the width of image
  83381. * * bufferHeight the height of image
  83382. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83383. * @returns the VertexData of the Ground designed from a heightmap
  83384. */
  83385. static CreateGroundFromHeightMap(options: {
  83386. width: number;
  83387. height: number;
  83388. subdivisions: number;
  83389. minHeight: number;
  83390. maxHeight: number;
  83391. colorFilter: Color3;
  83392. buffer: Uint8Array;
  83393. bufferWidth: number;
  83394. bufferHeight: number;
  83395. alphaFilter: number;
  83396. }): VertexData;
  83397. /**
  83398. * Creates the VertexData for a Plane
  83399. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83400. * * size sets the width and height of the plane to the value of size, optional default 1
  83401. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83402. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83403. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83404. * * 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)
  83405. * * 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)
  83406. * @returns the VertexData of the box
  83407. */
  83408. static CreatePlane(options: {
  83409. size?: number;
  83410. width?: number;
  83411. height?: number;
  83412. sideOrientation?: number;
  83413. frontUVs?: Vector4;
  83414. backUVs?: Vector4;
  83415. }): VertexData;
  83416. /**
  83417. * Creates the VertexData of the Disc or regular Polygon
  83418. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83419. * * radius the radius of the disc, optional default 0.5
  83420. * * tessellation the number of polygon sides, optional, default 64
  83421. * * 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
  83422. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83423. * * 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)
  83424. * * 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)
  83425. * @returns the VertexData of the box
  83426. */
  83427. static CreateDisc(options: {
  83428. radius?: number;
  83429. tessellation?: number;
  83430. arc?: number;
  83431. sideOrientation?: number;
  83432. frontUVs?: Vector4;
  83433. backUVs?: Vector4;
  83434. }): VertexData;
  83435. /**
  83436. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83437. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83438. * @param polygon a mesh built from polygonTriangulation.build()
  83439. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83440. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83441. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83442. * @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)
  83443. * @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)
  83444. * @returns the VertexData of the Polygon
  83445. */
  83446. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83447. /**
  83448. * Creates the VertexData of the IcoSphere
  83449. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83450. * * radius the radius of the IcoSphere, optional default 1
  83451. * * radiusX allows stretching in the x direction, optional, default radius
  83452. * * radiusY allows stretching in the y direction, optional, default radius
  83453. * * radiusZ allows stretching in the z direction, optional, default radius
  83454. * * flat when true creates a flat shaded mesh, optional, default true
  83455. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83456. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83457. * * 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)
  83458. * * 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)
  83459. * @returns the VertexData of the IcoSphere
  83460. */
  83461. static CreateIcoSphere(options: {
  83462. radius?: number;
  83463. radiusX?: number;
  83464. radiusY?: number;
  83465. radiusZ?: number;
  83466. flat?: boolean;
  83467. subdivisions?: number;
  83468. sideOrientation?: number;
  83469. frontUVs?: Vector4;
  83470. backUVs?: Vector4;
  83471. }): VertexData;
  83472. /**
  83473. * Creates the VertexData for a Polyhedron
  83474. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83475. * * type provided types are:
  83476. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83477. * * 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)
  83478. * * size the size of the IcoSphere, optional default 1
  83479. * * sizeX allows stretching in the x direction, optional, default size
  83480. * * sizeY allows stretching in the y direction, optional, default size
  83481. * * sizeZ allows stretching in the z direction, optional, default size
  83482. * * 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
  83483. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83484. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  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 Polyhedron
  83491. */
  83492. static CreatePolyhedron(options: {
  83493. type?: number;
  83494. size?: number;
  83495. sizeX?: number;
  83496. sizeY?: number;
  83497. sizeZ?: number;
  83498. custom?: any;
  83499. faceUV?: Vector4[];
  83500. faceColors?: Color4[];
  83501. flat?: boolean;
  83502. sideOrientation?: number;
  83503. frontUVs?: Vector4;
  83504. backUVs?: Vector4;
  83505. }): VertexData;
  83506. /**
  83507. * Creates the VertexData for a TorusKnot
  83508. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83509. * * radius the radius of the torus knot, optional, default 2
  83510. * * tube the thickness of the tube, optional, default 0.5
  83511. * * radialSegments the number of sides on each tube segments, optional, default 32
  83512. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83513. * * p the number of windings around the z axis, optional, default 2
  83514. * * q the number of windings around the x axis, optional, default 3
  83515. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83516. * * 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)
  83517. * * 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)
  83518. * @returns the VertexData of the Torus Knot
  83519. */
  83520. static CreateTorusKnot(options: {
  83521. radius?: number;
  83522. tube?: number;
  83523. radialSegments?: number;
  83524. tubularSegments?: number;
  83525. p?: number;
  83526. q?: number;
  83527. sideOrientation?: number;
  83528. frontUVs?: Vector4;
  83529. backUVs?: Vector4;
  83530. }): VertexData;
  83531. /**
  83532. * Compute normals for given positions and indices
  83533. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83534. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83535. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83536. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83537. * * facetNormals : optional array of facet normals (vector3)
  83538. * * facetPositions : optional array of facet positions (vector3)
  83539. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83540. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83541. * * bInfo : optional bounding info, required for facetPartitioning computation
  83542. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83543. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83544. * * useRightHandedSystem: optional boolean to for right handed system computation
  83545. * * depthSort : optional boolean to enable the facet depth sort computation
  83546. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83547. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83548. */
  83549. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83550. facetNormals?: any;
  83551. facetPositions?: any;
  83552. facetPartitioning?: any;
  83553. ratio?: number;
  83554. bInfo?: any;
  83555. bbSize?: Vector3;
  83556. subDiv?: any;
  83557. useRightHandedSystem?: boolean;
  83558. depthSort?: boolean;
  83559. distanceTo?: Vector3;
  83560. depthSortedFacets?: any;
  83561. }): void;
  83562. /** @hidden */
  83563. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83564. /**
  83565. * Applies VertexData created from the imported parameters to the geometry
  83566. * @param parsedVertexData the parsed data from an imported file
  83567. * @param geometry the geometry to apply the VertexData to
  83568. */
  83569. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83570. }
  83571. }
  83572. declare module BABYLON {
  83573. /**
  83574. * Class containing static functions to help procedurally build meshes
  83575. */
  83576. export class DiscBuilder {
  83577. /**
  83578. * Creates a plane polygonal mesh. By default, this is a disc
  83579. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83580. * * 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
  83581. * * 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
  83582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83585. * @param name defines the name of the mesh
  83586. * @param options defines the options used to create the mesh
  83587. * @param scene defines the hosting scene
  83588. * @returns the plane polygonal mesh
  83589. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83590. */
  83591. static CreateDisc(name: string, options: {
  83592. radius?: number;
  83593. tessellation?: number;
  83594. arc?: number;
  83595. updatable?: boolean;
  83596. sideOrientation?: number;
  83597. frontUVs?: Vector4;
  83598. backUVs?: Vector4;
  83599. }, scene?: Nullable<Scene>): Mesh;
  83600. }
  83601. }
  83602. declare module BABYLON {
  83603. /**
  83604. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83605. *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.
  83606. * The SPS is also a particle system. It provides some methods to manage the particles.
  83607. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83608. *
  83609. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83610. */
  83611. export class SolidParticleSystem implements IDisposable {
  83612. /**
  83613. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83614. * Example : var p = SPS.particles[i];
  83615. */
  83616. particles: SolidParticle[];
  83617. /**
  83618. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83619. */
  83620. nbParticles: number;
  83621. /**
  83622. * If the particles must ever face the camera (default false). Useful for planar particles.
  83623. */
  83624. billboard: boolean;
  83625. /**
  83626. * Recompute normals when adding a shape
  83627. */
  83628. recomputeNormals: boolean;
  83629. /**
  83630. * This a counter ofr your own usage. It's not set by any SPS functions.
  83631. */
  83632. counter: number;
  83633. /**
  83634. * The SPS name. This name is also given to the underlying mesh.
  83635. */
  83636. name: string;
  83637. /**
  83638. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83639. */
  83640. mesh: Mesh;
  83641. /**
  83642. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83643. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83644. */
  83645. vars: any;
  83646. /**
  83647. * This array is populated when the SPS is set as 'pickable'.
  83648. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83649. * Each element of this array is an object `{idx: int, faceId: int}`.
  83650. * `idx` is the picked particle index in the `SPS.particles` array
  83651. * `faceId` is the picked face index counted within this particle.
  83652. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83653. */
  83654. pickedParticles: {
  83655. idx: number;
  83656. faceId: number;
  83657. }[];
  83658. /**
  83659. * This array is populated when `enableDepthSort` is set to true.
  83660. * Each element of this array is an instance of the class DepthSortedParticle.
  83661. */
  83662. depthSortedParticles: DepthSortedParticle[];
  83663. /**
  83664. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83665. * @hidden
  83666. */
  83667. _bSphereOnly: boolean;
  83668. /**
  83669. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83670. * @hidden
  83671. */
  83672. _bSphereRadiusFactor: number;
  83673. private _scene;
  83674. private _positions;
  83675. private _indices;
  83676. private _normals;
  83677. private _colors;
  83678. private _uvs;
  83679. private _indices32;
  83680. private _positions32;
  83681. private _normals32;
  83682. private _fixedNormal32;
  83683. private _colors32;
  83684. private _uvs32;
  83685. private _index;
  83686. private _updatable;
  83687. private _pickable;
  83688. private _isVisibilityBoxLocked;
  83689. private _alwaysVisible;
  83690. private _depthSort;
  83691. private _shapeCounter;
  83692. private _copy;
  83693. private _color;
  83694. private _computeParticleColor;
  83695. private _computeParticleTexture;
  83696. private _computeParticleRotation;
  83697. private _computeParticleVertex;
  83698. private _computeBoundingBox;
  83699. private _depthSortParticles;
  83700. private _camera;
  83701. private _mustUnrotateFixedNormals;
  83702. private _particlesIntersect;
  83703. private _needs32Bits;
  83704. /**
  83705. * Creates a SPS (Solid Particle System) object.
  83706. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83707. * @param scene (Scene) is the scene in which the SPS is added.
  83708. * @param options defines the options of the sps e.g.
  83709. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83710. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83711. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83712. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83713. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83714. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83715. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83716. */
  83717. constructor(name: string, scene: Scene, options?: {
  83718. updatable?: boolean;
  83719. isPickable?: boolean;
  83720. enableDepthSort?: boolean;
  83721. particleIntersection?: boolean;
  83722. boundingSphereOnly?: boolean;
  83723. bSphereRadiusFactor?: number;
  83724. });
  83725. /**
  83726. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83727. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83728. * @returns the created mesh
  83729. */
  83730. buildMesh(): Mesh;
  83731. /**
  83732. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83733. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83734. * Thus the particles generated from `digest()` have their property `position` set yet.
  83735. * @param mesh ( Mesh ) is the mesh to be digested
  83736. * @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
  83737. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83738. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83739. * @returns the current SPS
  83740. */
  83741. digest(mesh: Mesh, options?: {
  83742. facetNb?: number;
  83743. number?: number;
  83744. delta?: number;
  83745. }): SolidParticleSystem;
  83746. private _unrotateFixedNormals;
  83747. private _resetCopy;
  83748. private _meshBuilder;
  83749. private _posToShape;
  83750. private _uvsToShapeUV;
  83751. private _addParticle;
  83752. /**
  83753. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83754. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83755. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83756. * @param nb (positive integer) the number of particles to be created from this model
  83757. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83758. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83759. * @returns the number of shapes in the system
  83760. */
  83761. addShape(mesh: Mesh, nb: number, options?: {
  83762. positionFunction?: any;
  83763. vertexFunction?: any;
  83764. }): number;
  83765. private _rebuildParticle;
  83766. /**
  83767. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83768. * @returns the SPS.
  83769. */
  83770. rebuildMesh(): SolidParticleSystem;
  83771. /**
  83772. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83773. * This method calls `updateParticle()` for each particle of the SPS.
  83774. * For an animated SPS, it is usually called within the render loop.
  83775. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83776. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83777. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83778. * @returns the SPS.
  83779. */
  83780. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83781. /**
  83782. * Disposes the SPS.
  83783. */
  83784. dispose(): void;
  83785. /**
  83786. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83787. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83788. * @returns the SPS.
  83789. */
  83790. refreshVisibleSize(): SolidParticleSystem;
  83791. /**
  83792. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83793. * @param size the size (float) of the visibility box
  83794. * note : this doesn't lock the SPS mesh bounding box.
  83795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83796. */
  83797. setVisibilityBox(size: number): void;
  83798. /**
  83799. * Gets whether the SPS as always visible or not
  83800. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83801. */
  83802. /**
  83803. * Sets the SPS as always visible or not
  83804. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83805. */
  83806. isAlwaysVisible: boolean;
  83807. /**
  83808. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83809. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83810. */
  83811. /**
  83812. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83813. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83814. */
  83815. isVisibilityBoxLocked: boolean;
  83816. /**
  83817. * Tells to `setParticles()` to compute the particle rotations or not.
  83818. * Default value : true. The SPS is faster when it's set to false.
  83819. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83820. */
  83821. /**
  83822. * Gets if `setParticles()` computes the particle rotations or not.
  83823. * Default value : true. The SPS is faster when it's set to false.
  83824. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83825. */
  83826. computeParticleRotation: boolean;
  83827. /**
  83828. * Tells to `setParticles()` to compute the particle colors or not.
  83829. * Default value : true. The SPS is faster when it's set to false.
  83830. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83831. */
  83832. /**
  83833. * Gets if `setParticles()` computes the particle colors or not.
  83834. * Default value : true. The SPS is faster when it's set to false.
  83835. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83836. */
  83837. computeParticleColor: boolean;
  83838. /**
  83839. * Gets if `setParticles()` computes the particle textures or not.
  83840. * Default value : true. The SPS is faster when it's set to false.
  83841. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83842. */
  83843. computeParticleTexture: boolean;
  83844. /**
  83845. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83846. * Default value : false. The SPS is faster when it's set to false.
  83847. * Note : the particle custom vertex positions aren't stored values.
  83848. */
  83849. /**
  83850. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83851. * Default value : false. The SPS is faster when it's set to false.
  83852. * Note : the particle custom vertex positions aren't stored values.
  83853. */
  83854. computeParticleVertex: boolean;
  83855. /**
  83856. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83857. */
  83858. /**
  83859. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83860. */
  83861. computeBoundingBox: boolean;
  83862. /**
  83863. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83864. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83865. * Default : `true`
  83866. */
  83867. /**
  83868. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83869. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83870. * Default : `true`
  83871. */
  83872. depthSortParticles: boolean;
  83873. /**
  83874. * This function does nothing. It may be overwritten to set all the particle first values.
  83875. * The SPS doesn't call this function, you may have to call it by your own.
  83876. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83877. */
  83878. initParticles(): void;
  83879. /**
  83880. * This function does nothing. It may be overwritten to recycle a particle.
  83881. * The SPS doesn't call this function, you may have to call it by your own.
  83882. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83883. * @param particle The particle to recycle
  83884. * @returns the recycled particle
  83885. */
  83886. recycleParticle(particle: SolidParticle): SolidParticle;
  83887. /**
  83888. * Updates a particle : this function should be overwritten by the user.
  83889. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83890. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83891. * @example : just set a particle position or velocity and recycle conditions
  83892. * @param particle The particle to update
  83893. * @returns the updated particle
  83894. */
  83895. updateParticle(particle: SolidParticle): SolidParticle;
  83896. /**
  83897. * Updates a vertex of a particle : it can be overwritten by the user.
  83898. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83899. * @param particle the current particle
  83900. * @param vertex the current index of the current particle
  83901. * @param pt the index of the current vertex in the particle shape
  83902. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83903. * @example : just set a vertex particle position
  83904. * @returns the updated vertex
  83905. */
  83906. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83907. /**
  83908. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83909. * This does nothing and may be overwritten by the user.
  83910. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83911. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83912. * @param update the boolean update value actually passed to setParticles()
  83913. */
  83914. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83915. /**
  83916. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83917. * This will be passed three parameters.
  83918. * This does nothing and may be overwritten by the user.
  83919. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83920. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83921. * @param update the boolean update value actually passed to setParticles()
  83922. */
  83923. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83924. }
  83925. }
  83926. declare module BABYLON {
  83927. /**
  83928. * Represents one particle of a solid particle system.
  83929. */
  83930. export class SolidParticle {
  83931. /**
  83932. * particle global index
  83933. */
  83934. idx: number;
  83935. /**
  83936. * The color of the particle
  83937. */
  83938. color: Nullable<Color4>;
  83939. /**
  83940. * The world space position of the particle.
  83941. */
  83942. position: Vector3;
  83943. /**
  83944. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83945. */
  83946. rotation: Vector3;
  83947. /**
  83948. * The world space rotation quaternion of the particle.
  83949. */
  83950. rotationQuaternion: Nullable<Quaternion>;
  83951. /**
  83952. * The scaling of the particle.
  83953. */
  83954. scaling: Vector3;
  83955. /**
  83956. * The uvs of the particle.
  83957. */
  83958. uvs: Vector4;
  83959. /**
  83960. * The current speed of the particle.
  83961. */
  83962. velocity: Vector3;
  83963. /**
  83964. * The pivot point in the particle local space.
  83965. */
  83966. pivot: Vector3;
  83967. /**
  83968. * Must the particle be translated from its pivot point in its local space ?
  83969. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83970. * Default : false
  83971. */
  83972. translateFromPivot: boolean;
  83973. /**
  83974. * Is the particle active or not ?
  83975. */
  83976. alive: boolean;
  83977. /**
  83978. * Is the particle visible or not ?
  83979. */
  83980. isVisible: boolean;
  83981. /**
  83982. * Index of this particle in the global "positions" array (Internal use)
  83983. * @hidden
  83984. */
  83985. _pos: number;
  83986. /**
  83987. * @hidden Index of this particle in the global "indices" array (Internal use)
  83988. */
  83989. _ind: number;
  83990. /**
  83991. * @hidden ModelShape of this particle (Internal use)
  83992. */
  83993. _model: ModelShape;
  83994. /**
  83995. * ModelShape id of this particle
  83996. */
  83997. shapeId: number;
  83998. /**
  83999. * Index of the particle in its shape id (Internal use)
  84000. */
  84001. idxInShape: number;
  84002. /**
  84003. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  84004. */
  84005. _modelBoundingInfo: BoundingInfo;
  84006. /**
  84007. * @hidden Particle BoundingInfo object (Internal use)
  84008. */
  84009. _boundingInfo: BoundingInfo;
  84010. /**
  84011. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  84012. */
  84013. _sps: SolidParticleSystem;
  84014. /**
  84015. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  84016. */
  84017. _stillInvisible: boolean;
  84018. /**
  84019. * @hidden Last computed particle rotation matrix
  84020. */
  84021. _rotationMatrix: number[];
  84022. /**
  84023. * Parent particle Id, if any.
  84024. * Default null.
  84025. */
  84026. parentId: Nullable<number>;
  84027. /**
  84028. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  84029. * The possible values are :
  84030. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84031. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84032. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84033. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84034. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84035. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  84036. * */
  84037. cullingStrategy: number;
  84038. /**
  84039. * @hidden Internal global position in the SPS.
  84040. */
  84041. _globalPosition: Vector3;
  84042. /**
  84043. * Creates a Solid Particle object.
  84044. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  84045. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  84046. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  84047. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  84048. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  84049. * @param shapeId (integer) is the model shape identifier in the SPS.
  84050. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  84051. * @param sps defines the sps it is associated to
  84052. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  84053. */
  84054. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  84055. /**
  84056. * Legacy support, changed scale to scaling
  84057. */
  84058. /**
  84059. * Legacy support, changed scale to scaling
  84060. */
  84061. scale: Vector3;
  84062. /**
  84063. * Legacy support, changed quaternion to rotationQuaternion
  84064. */
  84065. /**
  84066. * Legacy support, changed quaternion to rotationQuaternion
  84067. */
  84068. quaternion: Nullable<Quaternion>;
  84069. /**
  84070. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  84071. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  84072. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  84073. * @returns true if it intersects
  84074. */
  84075. intersectsMesh(target: Mesh | SolidParticle): boolean;
  84076. /**
  84077. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  84078. * A particle is in the frustum if its bounding box intersects the frustum
  84079. * @param frustumPlanes defines the frustum to test
  84080. * @returns true if the particle is in the frustum planes
  84081. */
  84082. isInFrustum(frustumPlanes: Plane[]): boolean;
  84083. /**
  84084. * get the rotation matrix of the particle
  84085. * @hidden
  84086. */
  84087. getRotationMatrix(m: Matrix): void;
  84088. }
  84089. /**
  84090. * Represents the shape of the model used by one particle of a solid particle system.
  84091. * SPS internal tool, don't use it manually.
  84092. */
  84093. export class ModelShape {
  84094. /**
  84095. * The shape id
  84096. * @hidden
  84097. */
  84098. shapeID: number;
  84099. /**
  84100. * flat array of model positions (internal use)
  84101. * @hidden
  84102. */
  84103. _shape: Vector3[];
  84104. /**
  84105. * flat array of model UVs (internal use)
  84106. * @hidden
  84107. */
  84108. _shapeUV: number[];
  84109. /**
  84110. * length of the shape in the model indices array (internal use)
  84111. * @hidden
  84112. */
  84113. _indicesLength: number;
  84114. /**
  84115. * Custom position function (internal use)
  84116. * @hidden
  84117. */
  84118. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  84119. /**
  84120. * Custom vertex function (internal use)
  84121. * @hidden
  84122. */
  84123. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  84124. /**
  84125. * 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.
  84126. * SPS internal tool, don't use it manually.
  84127. * @hidden
  84128. */
  84129. 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>);
  84130. }
  84131. /**
  84132. * Represents a Depth Sorted Particle in the solid particle system.
  84133. */
  84134. export class DepthSortedParticle {
  84135. /**
  84136. * Index of the particle in the "indices" array
  84137. */
  84138. ind: number;
  84139. /**
  84140. * Length of the particle shape in the "indices" array
  84141. */
  84142. indicesLength: number;
  84143. /**
  84144. * Squared distance from the particle to the camera
  84145. */
  84146. sqDistance: number;
  84147. }
  84148. }
  84149. declare module BABYLON {
  84150. /**
  84151. * Class used to store all common mesh properties
  84152. */
  84153. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  84154. /** No occlusion */
  84155. static OCCLUSION_TYPE_NONE: number;
  84156. /** Occlusion set to optimisitic */
  84157. static OCCLUSION_TYPE_OPTIMISTIC: number;
  84158. /** Occlusion set to strict */
  84159. static OCCLUSION_TYPE_STRICT: number;
  84160. /** Use an accurante occlusion algorithm */
  84161. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  84162. /** Use a conservative occlusion algorithm */
  84163. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  84164. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84165. * Test order :
  84166. * Is the bounding sphere outside the frustum ?
  84167. * If not, are the bounding box vertices outside the frustum ?
  84168. * It not, then the cullable object is in the frustum.
  84169. */
  84170. static readonly CULLINGSTRATEGY_STANDARD: number;
  84171. /** Culling strategy : Bounding Sphere Only.
  84172. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84173. * It's also less accurate than the standard because some not visible objects can still be selected.
  84174. * Test : is the bounding sphere outside the frustum ?
  84175. * If not, then the cullable object is in the frustum.
  84176. */
  84177. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  84178. /** Culling strategy : Optimistic Inclusion.
  84179. * This in an inclusion test first, then the standard exclusion test.
  84180. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84181. * 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.
  84182. * Anyway, it's as accurate as the standard strategy.
  84183. * Test :
  84184. * Is the cullable object bounding sphere center in the frustum ?
  84185. * If not, apply the default culling strategy.
  84186. */
  84187. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  84188. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84189. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84190. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84191. * 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.
  84192. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84193. * Test :
  84194. * Is the cullable object bounding sphere center in the frustum ?
  84195. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84196. */
  84197. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  84198. /**
  84199. * No billboard
  84200. */
  84201. static readonly BILLBOARDMODE_NONE: number;
  84202. /** Billboard on X axis */
  84203. static readonly BILLBOARDMODE_X: number;
  84204. /** Billboard on Y axis */
  84205. static readonly BILLBOARDMODE_Y: number;
  84206. /** Billboard on Z axis */
  84207. static readonly BILLBOARDMODE_Z: number;
  84208. /** Billboard on all axes */
  84209. static readonly BILLBOARDMODE_ALL: number;
  84210. private _facetData;
  84211. /**
  84212. * The culling strategy to use to check whether the mesh must be rendered or not.
  84213. * This value can be changed at any time and will be used on the next render mesh selection.
  84214. * The possible values are :
  84215. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84216. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84217. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84218. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84219. * Please read each static variable documentation to get details about the culling process.
  84220. * */
  84221. cullingStrategy: number;
  84222. /**
  84223. * Gets the number of facets in the mesh
  84224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84225. */
  84226. readonly facetNb: number;
  84227. /**
  84228. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  84229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84230. */
  84231. partitioningSubdivisions: number;
  84232. /**
  84233. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84234. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84236. */
  84237. partitioningBBoxRatio: number;
  84238. /**
  84239. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84240. * Works only for updatable meshes.
  84241. * Doesn't work with multi-materials
  84242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84243. */
  84244. mustDepthSortFacets: boolean;
  84245. /**
  84246. * The location (Vector3) where the facet depth sort must be computed from.
  84247. * By default, the active camera position.
  84248. * Used only when facet depth sort is enabled
  84249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84250. */
  84251. facetDepthSortFrom: Vector3;
  84252. /**
  84253. * gets a boolean indicating if facetData is enabled
  84254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84255. */
  84256. readonly isFacetDataEnabled: boolean;
  84257. /** @hidden */
  84258. _updateNonUniformScalingState(value: boolean): boolean;
  84259. /**
  84260. * An event triggered when this mesh collides with another one
  84261. */
  84262. onCollideObservable: Observable<AbstractMesh>;
  84263. private _onCollideObserver;
  84264. /** Set a function to call when this mesh collides with another one */
  84265. onCollide: () => void;
  84266. /**
  84267. * An event triggered when the collision's position changes
  84268. */
  84269. onCollisionPositionChangeObservable: Observable<Vector3>;
  84270. private _onCollisionPositionChangeObserver;
  84271. /** Set a function to call when the collision's position changes */
  84272. onCollisionPositionChange: () => void;
  84273. /**
  84274. * An event triggered when material is changed
  84275. */
  84276. onMaterialChangedObservable: Observable<AbstractMesh>;
  84277. /**
  84278. * Gets or sets the orientation for POV movement & rotation
  84279. */
  84280. definedFacingForward: boolean;
  84281. /** @hidden */
  84282. _occlusionQuery: Nullable<WebGLQuery>;
  84283. private _visibility;
  84284. /** @hidden */
  84285. _isActive: boolean;
  84286. /** @hidden */
  84287. _onlyForInstances: boolean;
  84288. /** @hidden */
  84289. _renderingGroup: Nullable<RenderingGroup>;
  84290. /**
  84291. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84292. */
  84293. /**
  84294. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84295. */
  84296. visibility: number;
  84297. /** Gets or sets the alpha index used to sort transparent meshes
  84298. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  84299. */
  84300. alphaIndex: number;
  84301. /**
  84302. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  84303. */
  84304. isVisible: boolean;
  84305. /**
  84306. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84307. */
  84308. isPickable: boolean;
  84309. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84310. showSubMeshesBoundingBox: boolean;
  84311. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84312. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84313. */
  84314. isBlocker: boolean;
  84315. /**
  84316. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84317. */
  84318. enablePointerMoveEvents: boolean;
  84319. /**
  84320. * Specifies the rendering group id for this mesh (0 by default)
  84321. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84322. */
  84323. renderingGroupId: number;
  84324. private _material;
  84325. /** Gets or sets current material */
  84326. material: Nullable<Material>;
  84327. private _receiveShadows;
  84328. /**
  84329. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84330. * @see http://doc.babylonjs.com/babylon101/shadows
  84331. */
  84332. receiveShadows: boolean;
  84333. /** Defines color to use when rendering outline */
  84334. outlineColor: Color3;
  84335. /** Define width to use when rendering outline */
  84336. outlineWidth: number;
  84337. /** Defines color to use when rendering overlay */
  84338. overlayColor: Color3;
  84339. /** Defines alpha to use when rendering overlay */
  84340. overlayAlpha: number;
  84341. private _hasVertexAlpha;
  84342. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84343. hasVertexAlpha: boolean;
  84344. private _useVertexColors;
  84345. /** 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) */
  84346. useVertexColors: boolean;
  84347. private _computeBonesUsingShaders;
  84348. /**
  84349. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84350. */
  84351. computeBonesUsingShaders: boolean;
  84352. private _numBoneInfluencers;
  84353. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84354. numBoneInfluencers: number;
  84355. private _applyFog;
  84356. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84357. applyFog: boolean;
  84358. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84359. useOctreeForRenderingSelection: boolean;
  84360. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84361. useOctreeForPicking: boolean;
  84362. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84363. useOctreeForCollisions: boolean;
  84364. private _layerMask;
  84365. /**
  84366. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84367. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84368. */
  84369. layerMask: number;
  84370. /**
  84371. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84372. */
  84373. alwaysSelectAsActiveMesh: boolean;
  84374. /**
  84375. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84376. */
  84377. doNotSyncBoundingInfo: boolean;
  84378. /**
  84379. * Gets or sets the current action manager
  84380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84381. */
  84382. actionManager: Nullable<AbstractActionManager>;
  84383. private _checkCollisions;
  84384. private _collisionMask;
  84385. private _collisionGroup;
  84386. /**
  84387. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84388. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84389. */
  84390. ellipsoid: Vector3;
  84391. /**
  84392. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84393. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84394. */
  84395. ellipsoidOffset: Vector3;
  84396. private _collider;
  84397. private _oldPositionForCollisions;
  84398. private _diffPositionForCollisions;
  84399. /**
  84400. * Gets or sets a collision mask used to mask collisions (default is -1).
  84401. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84402. */
  84403. collisionMask: number;
  84404. /**
  84405. * Gets or sets the current collision group mask (-1 by default).
  84406. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84407. */
  84408. collisionGroup: number;
  84409. /**
  84410. * Defines edge width used when edgesRenderer is enabled
  84411. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84412. */
  84413. edgesWidth: number;
  84414. /**
  84415. * Defines edge color used when edgesRenderer is enabled
  84416. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84417. */
  84418. edgesColor: Color4;
  84419. /** @hidden */
  84420. _edgesRenderer: Nullable<IEdgesRenderer>;
  84421. /** @hidden */
  84422. _masterMesh: Nullable<AbstractMesh>;
  84423. /** @hidden */
  84424. _boundingInfo: Nullable<BoundingInfo>;
  84425. /** @hidden */
  84426. _renderId: number;
  84427. /**
  84428. * Gets or sets the list of subMeshes
  84429. * @see http://doc.babylonjs.com/how_to/multi_materials
  84430. */
  84431. subMeshes: SubMesh[];
  84432. /** @hidden */
  84433. _intersectionsInProgress: AbstractMesh[];
  84434. /** @hidden */
  84435. _unIndexed: boolean;
  84436. /** @hidden */
  84437. _lightSources: Light[];
  84438. /** Gets the list of lights affecting that mesh */
  84439. readonly lightSources: Light[];
  84440. /** @hidden */
  84441. readonly _positions: Nullable<Vector3[]>;
  84442. /** @hidden */
  84443. _waitingData: {
  84444. lods: Nullable<any>;
  84445. actions: Nullable<any>;
  84446. freezeWorldMatrix: Nullable<boolean>;
  84447. };
  84448. private _skeleton;
  84449. /** @hidden */
  84450. _bonesTransformMatrices: Nullable<Float32Array>;
  84451. /**
  84452. * Gets or sets a skeleton to apply skining transformations
  84453. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84454. */
  84455. skeleton: Nullable<Skeleton>;
  84456. /**
  84457. * An event triggered when the mesh is rebuilt.
  84458. */
  84459. onRebuildObservable: Observable<AbstractMesh>;
  84460. /**
  84461. * Creates a new AbstractMesh
  84462. * @param name defines the name of the mesh
  84463. * @param scene defines the hosting scene
  84464. */
  84465. constructor(name: string, scene?: Nullable<Scene>);
  84466. /**
  84467. * Returns the string "AbstractMesh"
  84468. * @returns "AbstractMesh"
  84469. */
  84470. getClassName(): string;
  84471. /**
  84472. * Gets a string representation of the current mesh
  84473. * @param fullDetails defines a boolean indicating if full details must be included
  84474. * @returns a string representation of the current mesh
  84475. */
  84476. toString(fullDetails?: boolean): string;
  84477. /**
  84478. * @hidden
  84479. */
  84480. protected _getEffectiveParent(): Nullable<Node>;
  84481. /** @hidden */
  84482. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84483. /** @hidden */
  84484. _rebuild(): void;
  84485. /** @hidden */
  84486. _resyncLightSources(): void;
  84487. /** @hidden */
  84488. _resyncLighSource(light: Light): void;
  84489. /** @hidden */
  84490. _unBindEffect(): void;
  84491. /** @hidden */
  84492. _removeLightSource(light: Light): void;
  84493. private _markSubMeshesAsDirty;
  84494. /** @hidden */
  84495. _markSubMeshesAsLightDirty(): void;
  84496. /** @hidden */
  84497. _markSubMeshesAsAttributesDirty(): void;
  84498. /** @hidden */
  84499. _markSubMeshesAsMiscDirty(): void;
  84500. /**
  84501. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84502. */
  84503. scaling: Vector3;
  84504. /**
  84505. * Returns true if the mesh is blocked. Implemented by child classes
  84506. */
  84507. readonly isBlocked: boolean;
  84508. /**
  84509. * Returns the mesh itself by default. Implemented by child classes
  84510. * @param camera defines the camera to use to pick the right LOD level
  84511. * @returns the currentAbstractMesh
  84512. */
  84513. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84514. /**
  84515. * Returns 0 by default. Implemented by child classes
  84516. * @returns an integer
  84517. */
  84518. getTotalVertices(): number;
  84519. /**
  84520. * Returns a positive integer : the total number of indices in this mesh geometry.
  84521. * @returns the numner of indices or zero if the mesh has no geometry.
  84522. */
  84523. getTotalIndices(): number;
  84524. /**
  84525. * Returns null by default. Implemented by child classes
  84526. * @returns null
  84527. */
  84528. getIndices(): Nullable<IndicesArray>;
  84529. /**
  84530. * Returns the array of the requested vertex data kind. Implemented by child classes
  84531. * @param kind defines the vertex data kind to use
  84532. * @returns null
  84533. */
  84534. getVerticesData(kind: string): Nullable<FloatArray>;
  84535. /**
  84536. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84537. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84538. * Note that a new underlying VertexBuffer object is created each call.
  84539. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84540. * @param kind defines vertex data kind:
  84541. * * VertexBuffer.PositionKind
  84542. * * VertexBuffer.UVKind
  84543. * * VertexBuffer.UV2Kind
  84544. * * VertexBuffer.UV3Kind
  84545. * * VertexBuffer.UV4Kind
  84546. * * VertexBuffer.UV5Kind
  84547. * * VertexBuffer.UV6Kind
  84548. * * VertexBuffer.ColorKind
  84549. * * VertexBuffer.MatricesIndicesKind
  84550. * * VertexBuffer.MatricesIndicesExtraKind
  84551. * * VertexBuffer.MatricesWeightsKind
  84552. * * VertexBuffer.MatricesWeightsExtraKind
  84553. * @param data defines the data source
  84554. * @param updatable defines if the data must be flagged as updatable (or static)
  84555. * @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
  84556. * @returns the current mesh
  84557. */
  84558. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84559. /**
  84560. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84561. * If the mesh has no geometry, it is simply returned as it is.
  84562. * @param kind defines vertex data kind:
  84563. * * VertexBuffer.PositionKind
  84564. * * VertexBuffer.UVKind
  84565. * * VertexBuffer.UV2Kind
  84566. * * VertexBuffer.UV3Kind
  84567. * * VertexBuffer.UV4Kind
  84568. * * VertexBuffer.UV5Kind
  84569. * * VertexBuffer.UV6Kind
  84570. * * VertexBuffer.ColorKind
  84571. * * VertexBuffer.MatricesIndicesKind
  84572. * * VertexBuffer.MatricesIndicesExtraKind
  84573. * * VertexBuffer.MatricesWeightsKind
  84574. * * VertexBuffer.MatricesWeightsExtraKind
  84575. * @param data defines the data source
  84576. * @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
  84577. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84578. * @returns the current mesh
  84579. */
  84580. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84581. /**
  84582. * Sets the mesh indices,
  84583. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84584. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84585. * @param totalVertices Defines the total number of vertices
  84586. * @returns the current mesh
  84587. */
  84588. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84589. /**
  84590. * Gets a boolean indicating if specific vertex data is present
  84591. * @param kind defines the vertex data kind to use
  84592. * @returns true is data kind is present
  84593. */
  84594. isVerticesDataPresent(kind: string): boolean;
  84595. /**
  84596. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84597. * @returns a BoundingInfo
  84598. */
  84599. getBoundingInfo(): BoundingInfo;
  84600. /**
  84601. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84602. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84603. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84604. * @returns the current mesh
  84605. */
  84606. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84607. /**
  84608. * Overwrite the current bounding info
  84609. * @param boundingInfo defines the new bounding info
  84610. * @returns the current mesh
  84611. */
  84612. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84613. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84614. readonly useBones: boolean;
  84615. /** @hidden */
  84616. _preActivate(): void;
  84617. /** @hidden */
  84618. _preActivateForIntermediateRendering(renderId: number): void;
  84619. /** @hidden */
  84620. _activate(renderId: number): boolean;
  84621. /** @hidden */
  84622. _postActivate(): void;
  84623. /** @hidden */
  84624. _freeze(): void;
  84625. /** @hidden */
  84626. _unFreeze(): void;
  84627. /**
  84628. * Gets the current world matrix
  84629. * @returns a Matrix
  84630. */
  84631. getWorldMatrix(): Matrix;
  84632. /** @hidden */
  84633. _getWorldMatrixDeterminant(): number;
  84634. /**
  84635. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  84636. */
  84637. readonly isAnInstance: boolean;
  84638. /**
  84639. * Perform relative position change from the point of view of behind the front of the mesh.
  84640. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84641. * Supports definition of mesh facing forward or backward
  84642. * @param amountRight defines the distance on the right axis
  84643. * @param amountUp defines the distance on the up axis
  84644. * @param amountForward defines the distance on the forward axis
  84645. * @returns the current mesh
  84646. */
  84647. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84648. /**
  84649. * Calculate relative position change from the point of view of behind the front of the mesh.
  84650. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84651. * Supports definition of mesh facing forward or backward
  84652. * @param amountRight defines the distance on the right axis
  84653. * @param amountUp defines the distance on the up axis
  84654. * @param amountForward defines the distance on the forward axis
  84655. * @returns the new displacement vector
  84656. */
  84657. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84658. /**
  84659. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84660. * Supports definition of mesh facing forward or backward
  84661. * @param flipBack defines the flip
  84662. * @param twirlClockwise defines the twirl
  84663. * @param tiltRight defines the tilt
  84664. * @returns the current mesh
  84665. */
  84666. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84667. /**
  84668. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84669. * Supports definition of mesh facing forward or backward.
  84670. * @param flipBack defines the flip
  84671. * @param twirlClockwise defines the twirl
  84672. * @param tiltRight defines the tilt
  84673. * @returns the new rotation vector
  84674. */
  84675. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84676. /**
  84677. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84678. * This means the mesh underlying bounding box and sphere are recomputed.
  84679. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84680. * @returns the current mesh
  84681. */
  84682. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84683. /** @hidden */
  84684. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84685. /** @hidden */
  84686. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84687. /** @hidden */
  84688. _updateBoundingInfo(): AbstractMesh;
  84689. /** @hidden */
  84690. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84691. /** @hidden */
  84692. protected _afterComputeWorldMatrix(): void;
  84693. /** @hidden */
  84694. readonly _effectiveMesh: AbstractMesh;
  84695. /**
  84696. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84697. * A mesh is in the frustum if its bounding box intersects the frustum
  84698. * @param frustumPlanes defines the frustum to test
  84699. * @returns true if the mesh is in the frustum planes
  84700. */
  84701. isInFrustum(frustumPlanes: Plane[]): boolean;
  84702. /**
  84703. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84704. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84705. * @param frustumPlanes defines the frustum to test
  84706. * @returns true if the mesh is completely in the frustum planes
  84707. */
  84708. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84709. /**
  84710. * True if the mesh intersects another mesh or a SolidParticle object
  84711. * @param mesh defines a target mesh or SolidParticle to test
  84712. * @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)
  84713. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84714. * @returns true if there is an intersection
  84715. */
  84716. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84717. /**
  84718. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84719. * @param point defines the point to test
  84720. * @returns true if there is an intersection
  84721. */
  84722. intersectsPoint(point: Vector3): boolean;
  84723. /**
  84724. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84725. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84726. */
  84727. checkCollisions: boolean;
  84728. /**
  84729. * Gets Collider object used to compute collisions (not physics)
  84730. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84731. */
  84732. readonly collider: Nullable<Collider>;
  84733. /**
  84734. * Move the mesh using collision engine
  84735. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84736. * @param displacement defines the requested displacement vector
  84737. * @returns the current mesh
  84738. */
  84739. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84740. private _onCollisionPositionChange;
  84741. /** @hidden */
  84742. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84743. /** @hidden */
  84744. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84745. /** @hidden */
  84746. _checkCollision(collider: Collider): AbstractMesh;
  84747. /** @hidden */
  84748. _generatePointsArray(): boolean;
  84749. /**
  84750. * Checks if the passed Ray intersects with the mesh
  84751. * @param ray defines the ray to use
  84752. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84753. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84754. * @returns the picking info
  84755. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84756. */
  84757. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84758. /**
  84759. * Clones the current mesh
  84760. * @param name defines the mesh name
  84761. * @param newParent defines the new mesh parent
  84762. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84763. * @returns the new mesh
  84764. */
  84765. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84766. /**
  84767. * Disposes all the submeshes of the current meshnp
  84768. * @returns the current mesh
  84769. */
  84770. releaseSubMeshes(): AbstractMesh;
  84771. /**
  84772. * Releases resources associated with this abstract mesh.
  84773. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84774. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84775. */
  84776. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84777. /**
  84778. * Adds the passed mesh as a child to the current mesh
  84779. * @param mesh defines the child mesh
  84780. * @returns the current mesh
  84781. */
  84782. addChild(mesh: AbstractMesh): AbstractMesh;
  84783. /**
  84784. * Removes the passed mesh from the current mesh children list
  84785. * @param mesh defines the child mesh
  84786. * @returns the current mesh
  84787. */
  84788. removeChild(mesh: AbstractMesh): AbstractMesh;
  84789. /** @hidden */
  84790. private _initFacetData;
  84791. /**
  84792. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84793. * This method can be called within the render loop.
  84794. * 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
  84795. * @returns the current mesh
  84796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84797. */
  84798. updateFacetData(): AbstractMesh;
  84799. /**
  84800. * Returns the facetLocalNormals array.
  84801. * The normals are expressed in the mesh local spac
  84802. * @returns an array of Vector3
  84803. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84804. */
  84805. getFacetLocalNormals(): Vector3[];
  84806. /**
  84807. * Returns the facetLocalPositions array.
  84808. * The facet positions are expressed in the mesh local space
  84809. * @returns an array of Vector3
  84810. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84811. */
  84812. getFacetLocalPositions(): Vector3[];
  84813. /**
  84814. * Returns the facetLocalPartioning array
  84815. * @returns an array of array of numbers
  84816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84817. */
  84818. getFacetLocalPartitioning(): number[][];
  84819. /**
  84820. * Returns the i-th facet position in the world system.
  84821. * This method allocates a new Vector3 per call
  84822. * @param i defines the facet index
  84823. * @returns a new Vector3
  84824. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84825. */
  84826. getFacetPosition(i: number): Vector3;
  84827. /**
  84828. * Sets the reference Vector3 with the i-th facet position in the world system
  84829. * @param i defines the facet index
  84830. * @param ref defines the target vector
  84831. * @returns the current mesh
  84832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84833. */
  84834. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84835. /**
  84836. * Returns the i-th facet normal in the world system.
  84837. * This method allocates a new Vector3 per call
  84838. * @param i defines the facet index
  84839. * @returns a new Vector3
  84840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84841. */
  84842. getFacetNormal(i: number): Vector3;
  84843. /**
  84844. * Sets the reference Vector3 with the i-th facet normal in the world system
  84845. * @param i defines the facet index
  84846. * @param ref defines the target vector
  84847. * @returns the current mesh
  84848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84849. */
  84850. getFacetNormalToRef(i: number, ref: Vector3): this;
  84851. /**
  84852. * 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)
  84853. * @param x defines x coordinate
  84854. * @param y defines y coordinate
  84855. * @param z defines z coordinate
  84856. * @returns the array of facet indexes
  84857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84858. */
  84859. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84860. /**
  84861. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84862. * @param projected sets as the (x,y,z) world projection on the facet
  84863. * @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
  84864. * @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
  84865. * @param x defines x coordinate
  84866. * @param y defines y coordinate
  84867. * @param z defines z coordinate
  84868. * @returns the face index if found (or null instead)
  84869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84870. */
  84871. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84872. /**
  84873. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84874. * @param projected sets as the (x,y,z) local projection on the facet
  84875. * @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
  84876. * @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
  84877. * @param x defines x coordinate
  84878. * @param y defines y coordinate
  84879. * @param z defines z coordinate
  84880. * @returns the face index if found (or null instead)
  84881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84882. */
  84883. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84884. /**
  84885. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84886. * @returns the parameters
  84887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84888. */
  84889. getFacetDataParameters(): any;
  84890. /**
  84891. * Disables the feature FacetData and frees the related memory
  84892. * @returns the current mesh
  84893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84894. */
  84895. disableFacetData(): AbstractMesh;
  84896. /**
  84897. * Updates the AbstractMesh indices array
  84898. * @param indices defines the data source
  84899. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84900. * @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)
  84901. * @returns the current mesh
  84902. */
  84903. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84904. /**
  84905. * Creates new normals data for the mesh
  84906. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84907. * @returns the current mesh
  84908. */
  84909. createNormals(updatable: boolean): AbstractMesh;
  84910. /**
  84911. * Align the mesh with a normal
  84912. * @param normal defines the normal to use
  84913. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84914. * @returns the current mesh
  84915. */
  84916. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84917. /** @hidden */
  84918. _checkOcclusionQuery(): boolean;
  84919. }
  84920. }
  84921. declare module BABYLON {
  84922. /**
  84923. * Interface used to define ActionEvent
  84924. */
  84925. export interface IActionEvent {
  84926. /** The mesh or sprite that triggered the action */
  84927. source: any;
  84928. /** The X mouse cursor position at the time of the event */
  84929. pointerX: number;
  84930. /** The Y mouse cursor position at the time of the event */
  84931. pointerY: number;
  84932. /** The mesh that is currently pointed at (can be null) */
  84933. meshUnderPointer: Nullable<AbstractMesh>;
  84934. /** the original (browser) event that triggered the ActionEvent */
  84935. sourceEvent?: any;
  84936. /** additional data for the event */
  84937. additionalData?: any;
  84938. }
  84939. /**
  84940. * ActionEvent is the event being sent when an action is triggered.
  84941. */
  84942. export class ActionEvent implements IActionEvent {
  84943. /** The mesh or sprite that triggered the action */
  84944. source: any;
  84945. /** The X mouse cursor position at the time of the event */
  84946. pointerX: number;
  84947. /** The Y mouse cursor position at the time of the event */
  84948. pointerY: number;
  84949. /** The mesh that is currently pointed at (can be null) */
  84950. meshUnderPointer: Nullable<AbstractMesh>;
  84951. /** the original (browser) event that triggered the ActionEvent */
  84952. sourceEvent?: any;
  84953. /** additional data for the event */
  84954. additionalData?: any;
  84955. /**
  84956. * Creates a new ActionEvent
  84957. * @param source The mesh or sprite that triggered the action
  84958. * @param pointerX The X mouse cursor position at the time of the event
  84959. * @param pointerY The Y mouse cursor position at the time of the event
  84960. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84961. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84962. * @param additionalData additional data for the event
  84963. */
  84964. constructor(
  84965. /** The mesh or sprite that triggered the action */
  84966. source: any,
  84967. /** The X mouse cursor position at the time of the event */
  84968. pointerX: number,
  84969. /** The Y mouse cursor position at the time of the event */
  84970. pointerY: number,
  84971. /** The mesh that is currently pointed at (can be null) */
  84972. meshUnderPointer: Nullable<AbstractMesh>,
  84973. /** the original (browser) event that triggered the ActionEvent */
  84974. sourceEvent?: any,
  84975. /** additional data for the event */
  84976. additionalData?: any);
  84977. /**
  84978. * Helper function to auto-create an ActionEvent from a source mesh.
  84979. * @param source The source mesh that triggered the event
  84980. * @param evt The original (browser) event
  84981. * @param additionalData additional data for the event
  84982. * @returns the new ActionEvent
  84983. */
  84984. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84985. /**
  84986. * Helper function to auto-create an ActionEvent from a source sprite
  84987. * @param source The source sprite that triggered the event
  84988. * @param scene Scene associated with the sprite
  84989. * @param evt The original (browser) event
  84990. * @param additionalData additional data for the event
  84991. * @returns the new ActionEvent
  84992. */
  84993. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84994. /**
  84995. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84996. * @param scene the scene where the event occurred
  84997. * @param evt The original (browser) event
  84998. * @returns the new ActionEvent
  84999. */
  85000. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  85001. /**
  85002. * Helper function to auto-create an ActionEvent from a primitive
  85003. * @param prim defines the target primitive
  85004. * @param pointerPos defines the pointer position
  85005. * @param evt The original (browser) event
  85006. * @param additionalData additional data for the event
  85007. * @returns the new ActionEvent
  85008. */
  85009. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  85010. }
  85011. }
  85012. declare module BABYLON {
  85013. /**
  85014. * Abstract class used to decouple action Manager from scene and meshes.
  85015. * Do not instantiate.
  85016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  85017. */
  85018. export abstract class AbstractActionManager implements IDisposable {
  85019. /** Gets the list of active triggers */
  85020. static Triggers: {
  85021. [key: string]: number;
  85022. };
  85023. /** Gets the cursor to use when hovering items */
  85024. hoverCursor: string;
  85025. /** Gets the list of actions */
  85026. actions: IAction[];
  85027. /**
  85028. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  85029. */
  85030. isRecursive: boolean;
  85031. /**
  85032. * Releases all associated resources
  85033. */
  85034. abstract dispose(): void;
  85035. /**
  85036. * Does this action manager has pointer triggers
  85037. */
  85038. abstract readonly hasPointerTriggers: boolean;
  85039. /**
  85040. * Does this action manager has pick triggers
  85041. */
  85042. abstract readonly hasPickTriggers: boolean;
  85043. /**
  85044. * Process a specific trigger
  85045. * @param trigger defines the trigger to process
  85046. * @param evt defines the event details to be processed
  85047. */
  85048. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  85049. /**
  85050. * Does this action manager handles actions of any of the given triggers
  85051. * @param triggers defines the triggers to be tested
  85052. * @return a boolean indicating whether one (or more) of the triggers is handled
  85053. */
  85054. abstract hasSpecificTriggers(triggers: number[]): boolean;
  85055. /**
  85056. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  85057. * speed.
  85058. * @param triggerA defines the trigger to be tested
  85059. * @param triggerB defines the trigger to be tested
  85060. * @return a boolean indicating whether one (or more) of the triggers is handled
  85061. */
  85062. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  85063. /**
  85064. * Does this action manager handles actions of a given trigger
  85065. * @param trigger defines the trigger to be tested
  85066. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  85067. * @return whether the trigger is handled
  85068. */
  85069. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  85070. /**
  85071. * Serialize this manager to a JSON object
  85072. * @param name defines the property name to store this manager
  85073. * @returns a JSON representation of this manager
  85074. */
  85075. abstract serialize(name: string): any;
  85076. /**
  85077. * Registers an action to this action manager
  85078. * @param action defines the action to be registered
  85079. * @return the action amended (prepared) after registration
  85080. */
  85081. abstract registerAction(action: IAction): Nullable<IAction>;
  85082. /**
  85083. * Unregisters an action to this action manager
  85084. * @param action defines the action to be unregistered
  85085. * @return a boolean indicating whether the action has been unregistered
  85086. */
  85087. abstract unregisterAction(action: IAction): Boolean;
  85088. /**
  85089. * Does exist one action manager with at least one trigger
  85090. **/
  85091. static readonly HasTriggers: boolean;
  85092. /**
  85093. * Does exist one action manager with at least one pick trigger
  85094. **/
  85095. static readonly HasPickTriggers: boolean;
  85096. /**
  85097. * Does exist one action manager that handles actions of a given trigger
  85098. * @param trigger defines the trigger to be tested
  85099. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  85100. **/
  85101. static HasSpecificTrigger(trigger: number): boolean;
  85102. }
  85103. }
  85104. declare module BABYLON {
  85105. /**
  85106. * Defines how a node can be built from a string name.
  85107. */
  85108. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  85109. /**
  85110. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  85111. */
  85112. export class Node implements IBehaviorAware<Node> {
  85113. /** @hidden */
  85114. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  85115. private static _NodeConstructors;
  85116. /**
  85117. * Add a new node constructor
  85118. * @param type defines the type name of the node to construct
  85119. * @param constructorFunc defines the constructor function
  85120. */
  85121. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  85122. /**
  85123. * Returns a node constructor based on type name
  85124. * @param type defines the type name
  85125. * @param name defines the new node name
  85126. * @param scene defines the hosting scene
  85127. * @param options defines optional options to transmit to constructors
  85128. * @returns the new constructor or null
  85129. */
  85130. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  85131. /**
  85132. * Gets or sets the name of the node
  85133. */
  85134. name: string;
  85135. /**
  85136. * Gets or sets the id of the node
  85137. */
  85138. id: string;
  85139. /**
  85140. * Gets or sets the unique id of the node
  85141. */
  85142. uniqueId: number;
  85143. /**
  85144. * Gets or sets a string used to store user defined state for the node
  85145. */
  85146. state: string;
  85147. /**
  85148. * Gets or sets an object used to store user defined information for the node
  85149. */
  85150. metadata: any;
  85151. /**
  85152. * For internal use only. Please do not use.
  85153. */
  85154. reservedDataStore: any;
  85155. /**
  85156. * List of inspectable custom properties (used by the Inspector)
  85157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85158. */
  85159. inspectableCustomProperties: IInspectable[];
  85160. /**
  85161. * Gets or sets a boolean used to define if the node must be serialized
  85162. */
  85163. doNotSerialize: boolean;
  85164. /** @hidden */
  85165. _isDisposed: boolean;
  85166. /**
  85167. * Gets a list of Animations associated with the node
  85168. */
  85169. animations: Animation[];
  85170. protected _ranges: {
  85171. [name: string]: Nullable<AnimationRange>;
  85172. };
  85173. /**
  85174. * Callback raised when the node is ready to be used
  85175. */
  85176. onReady: Nullable<(node: Node) => void>;
  85177. private _isEnabled;
  85178. private _isParentEnabled;
  85179. private _isReady;
  85180. /** @hidden */
  85181. _currentRenderId: number;
  85182. private _parentUpdateId;
  85183. /** @hidden */
  85184. _childUpdateId: number;
  85185. /** @hidden */
  85186. _waitingParentId: Nullable<string>;
  85187. /** @hidden */
  85188. _scene: Scene;
  85189. /** @hidden */
  85190. _cache: any;
  85191. private _parentNode;
  85192. private _children;
  85193. /** @hidden */
  85194. _worldMatrix: Matrix;
  85195. /** @hidden */
  85196. _worldMatrixDeterminant: number;
  85197. /** @hidden */
  85198. _worldMatrixDeterminantIsDirty: boolean;
  85199. /** @hidden */
  85200. private _sceneRootNodesIndex;
  85201. /**
  85202. * Gets a boolean indicating if the node has been disposed
  85203. * @returns true if the node was disposed
  85204. */
  85205. isDisposed(): boolean;
  85206. /**
  85207. * Gets or sets the parent of the node (without keeping the current position in the scene)
  85208. * @see https://doc.babylonjs.com/how_to/parenting
  85209. */
  85210. parent: Nullable<Node>;
  85211. private addToSceneRootNodes;
  85212. private removeFromSceneRootNodes;
  85213. private _animationPropertiesOverride;
  85214. /**
  85215. * Gets or sets the animation properties override
  85216. */
  85217. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85218. /**
  85219. * Gets a string idenfifying the name of the class
  85220. * @returns "Node" string
  85221. */
  85222. getClassName(): string;
  85223. /** @hidden */
  85224. readonly _isNode: boolean;
  85225. /**
  85226. * An event triggered when the mesh is disposed
  85227. */
  85228. onDisposeObservable: Observable<Node>;
  85229. private _onDisposeObserver;
  85230. /**
  85231. * Sets a callback that will be raised when the node will be disposed
  85232. */
  85233. onDispose: () => void;
  85234. /**
  85235. * Creates a new Node
  85236. * @param name the name and id to be given to this node
  85237. * @param scene the scene this node will be added to
  85238. * @param addToRootNodes the node will be added to scene.rootNodes
  85239. */
  85240. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  85241. /**
  85242. * Gets the scene of the node
  85243. * @returns a scene
  85244. */
  85245. getScene(): Scene;
  85246. /**
  85247. * Gets the engine of the node
  85248. * @returns a Engine
  85249. */
  85250. getEngine(): Engine;
  85251. private _behaviors;
  85252. /**
  85253. * Attach a behavior to the node
  85254. * @see http://doc.babylonjs.com/features/behaviour
  85255. * @param behavior defines the behavior to attach
  85256. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  85257. * @returns the current Node
  85258. */
  85259. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  85260. /**
  85261. * Remove an attached behavior
  85262. * @see http://doc.babylonjs.com/features/behaviour
  85263. * @param behavior defines the behavior to attach
  85264. * @returns the current Node
  85265. */
  85266. removeBehavior(behavior: Behavior<Node>): Node;
  85267. /**
  85268. * Gets the list of attached behaviors
  85269. * @see http://doc.babylonjs.com/features/behaviour
  85270. */
  85271. readonly behaviors: Behavior<Node>[];
  85272. /**
  85273. * Gets an attached behavior by name
  85274. * @param name defines the name of the behavior to look for
  85275. * @see http://doc.babylonjs.com/features/behaviour
  85276. * @returns null if behavior was not found else the requested behavior
  85277. */
  85278. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  85279. /**
  85280. * Returns the latest update of the World matrix
  85281. * @returns a Matrix
  85282. */
  85283. getWorldMatrix(): Matrix;
  85284. /** @hidden */
  85285. _getWorldMatrixDeterminant(): number;
  85286. /**
  85287. * Returns directly the latest state of the mesh World matrix.
  85288. * A Matrix is returned.
  85289. */
  85290. readonly worldMatrixFromCache: Matrix;
  85291. /** @hidden */
  85292. _initCache(): void;
  85293. /** @hidden */
  85294. updateCache(force?: boolean): void;
  85295. /** @hidden */
  85296. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  85297. /** @hidden */
  85298. _updateCache(ignoreParentClass?: boolean): void;
  85299. /** @hidden */
  85300. _isSynchronized(): boolean;
  85301. /** @hidden */
  85302. _markSyncedWithParent(): void;
  85303. /** @hidden */
  85304. isSynchronizedWithParent(): boolean;
  85305. /** @hidden */
  85306. isSynchronized(): boolean;
  85307. /**
  85308. * Is this node ready to be used/rendered
  85309. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85310. * @return true if the node is ready
  85311. */
  85312. isReady(completeCheck?: boolean): boolean;
  85313. /**
  85314. * Is this node enabled?
  85315. * 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
  85316. * @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
  85317. * @return whether this node (and its parent) is enabled
  85318. */
  85319. isEnabled(checkAncestors?: boolean): boolean;
  85320. /** @hidden */
  85321. protected _syncParentEnabledState(): void;
  85322. /**
  85323. * Set the enabled state of this node
  85324. * @param value defines the new enabled state
  85325. */
  85326. setEnabled(value: boolean): void;
  85327. /**
  85328. * Is this node a descendant of the given node?
  85329. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85330. * @param ancestor defines the parent node to inspect
  85331. * @returns a boolean indicating if this node is a descendant of the given node
  85332. */
  85333. isDescendantOf(ancestor: Node): boolean;
  85334. /** @hidden */
  85335. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85336. /**
  85337. * Will return all nodes that have this node as ascendant
  85338. * @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
  85339. * @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
  85340. * @return all children nodes of all types
  85341. */
  85342. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85343. /**
  85344. * Get all child-meshes of this node
  85345. * @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)
  85346. * @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
  85347. * @returns an array of AbstractMesh
  85348. */
  85349. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85350. /**
  85351. * Get all direct children of this node
  85352. * @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
  85353. * @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)
  85354. * @returns an array of Node
  85355. */
  85356. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85357. /** @hidden */
  85358. _setReady(state: boolean): void;
  85359. /**
  85360. * Get an animation by name
  85361. * @param name defines the name of the animation to look for
  85362. * @returns null if not found else the requested animation
  85363. */
  85364. getAnimationByName(name: string): Nullable<Animation>;
  85365. /**
  85366. * Creates an animation range for this node
  85367. * @param name defines the name of the range
  85368. * @param from defines the starting key
  85369. * @param to defines the end key
  85370. */
  85371. createAnimationRange(name: string, from: number, to: number): void;
  85372. /**
  85373. * Delete a specific animation range
  85374. * @param name defines the name of the range to delete
  85375. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85376. */
  85377. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85378. /**
  85379. * Get an animation range by name
  85380. * @param name defines the name of the animation range to look for
  85381. * @returns null if not found else the requested animation range
  85382. */
  85383. getAnimationRange(name: string): Nullable<AnimationRange>;
  85384. /**
  85385. * Gets the list of all animation ranges defined on this node
  85386. * @returns an array
  85387. */
  85388. getAnimationRanges(): Nullable<AnimationRange>[];
  85389. /**
  85390. * Will start the animation sequence
  85391. * @param name defines the range frames for animation sequence
  85392. * @param loop defines if the animation should loop (false by default)
  85393. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85394. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85395. * @returns the object created for this animation. If range does not exist, it will return null
  85396. */
  85397. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85398. /**
  85399. * Serialize animation ranges into a JSON compatible object
  85400. * @returns serialization object
  85401. */
  85402. serializeAnimationRanges(): any;
  85403. /**
  85404. * Computes the world matrix of the node
  85405. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85406. * @returns the world matrix
  85407. */
  85408. computeWorldMatrix(force?: boolean): Matrix;
  85409. /**
  85410. * Releases resources associated with this node.
  85411. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85412. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85413. */
  85414. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85415. /**
  85416. * Parse animation range data from a serialization object and store them into a given node
  85417. * @param node defines where to store the animation ranges
  85418. * @param parsedNode defines the serialization object to read data from
  85419. * @param scene defines the hosting scene
  85420. */
  85421. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85422. /**
  85423. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85424. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85425. * @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
  85426. * @returns the new bounding vectors
  85427. */
  85428. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85429. min: Vector3;
  85430. max: Vector3;
  85431. };
  85432. }
  85433. }
  85434. declare module BABYLON {
  85435. /**
  85436. * @hidden
  85437. */
  85438. export class _IAnimationState {
  85439. key: number;
  85440. repeatCount: number;
  85441. workValue?: any;
  85442. loopMode?: number;
  85443. offsetValue?: any;
  85444. highLimitValue?: any;
  85445. }
  85446. /**
  85447. * Class used to store any kind of animation
  85448. */
  85449. export class Animation {
  85450. /**Name of the animation */
  85451. name: string;
  85452. /**Property to animate */
  85453. targetProperty: string;
  85454. /**The frames per second of the animation */
  85455. framePerSecond: number;
  85456. /**The data type of the animation */
  85457. dataType: number;
  85458. /**The loop mode of the animation */
  85459. loopMode?: number | undefined;
  85460. /**Specifies if blending should be enabled */
  85461. enableBlending?: boolean | undefined;
  85462. /**
  85463. * Use matrix interpolation instead of using direct key value when animating matrices
  85464. */
  85465. static AllowMatricesInterpolation: boolean;
  85466. /**
  85467. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85468. */
  85469. static AllowMatrixDecomposeForInterpolation: boolean;
  85470. /**
  85471. * Stores the key frames of the animation
  85472. */
  85473. private _keys;
  85474. /**
  85475. * Stores the easing function of the animation
  85476. */
  85477. private _easingFunction;
  85478. /**
  85479. * @hidden Internal use only
  85480. */
  85481. _runtimeAnimations: RuntimeAnimation[];
  85482. /**
  85483. * The set of event that will be linked to this animation
  85484. */
  85485. private _events;
  85486. /**
  85487. * Stores an array of target property paths
  85488. */
  85489. targetPropertyPath: string[];
  85490. /**
  85491. * Stores the blending speed of the animation
  85492. */
  85493. blendingSpeed: number;
  85494. /**
  85495. * Stores the animation ranges for the animation
  85496. */
  85497. private _ranges;
  85498. /**
  85499. * @hidden Internal use
  85500. */
  85501. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85502. /**
  85503. * Sets up an animation
  85504. * @param property The property to animate
  85505. * @param animationType The animation type to apply
  85506. * @param framePerSecond The frames per second of the animation
  85507. * @param easingFunction The easing function used in the animation
  85508. * @returns The created animation
  85509. */
  85510. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85511. /**
  85512. * Create and start an animation on a node
  85513. * @param name defines the name of the global animation that will be run on all nodes
  85514. * @param node defines the root node where the animation will take place
  85515. * @param targetProperty defines property to animate
  85516. * @param framePerSecond defines the number of frame per second yo use
  85517. * @param totalFrame defines the number of frames in total
  85518. * @param from defines the initial value
  85519. * @param to defines the final value
  85520. * @param loopMode defines which loop mode you want to use (off by default)
  85521. * @param easingFunction defines the easing function to use (linear by default)
  85522. * @param onAnimationEnd defines the callback to call when animation end
  85523. * @returns the animatable created for this animation
  85524. */
  85525. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85526. /**
  85527. * Create and start an animation on a node and its descendants
  85528. * @param name defines the name of the global animation that will be run on all nodes
  85529. * @param node defines the root node where the animation will take place
  85530. * @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
  85531. * @param targetProperty defines property to animate
  85532. * @param framePerSecond defines the number of frame per second to use
  85533. * @param totalFrame defines the number of frames in total
  85534. * @param from defines the initial value
  85535. * @param to defines the final value
  85536. * @param loopMode defines which loop mode you want to use (off by default)
  85537. * @param easingFunction defines the easing function to use (linear by default)
  85538. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85539. * @returns the list of animatables created for all nodes
  85540. * @example https://www.babylonjs-playground.com/#MH0VLI
  85541. */
  85542. 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[]>;
  85543. /**
  85544. * Creates a new animation, merges it with the existing animations and starts it
  85545. * @param name Name of the animation
  85546. * @param node Node which contains the scene that begins the animations
  85547. * @param targetProperty Specifies which property to animate
  85548. * @param framePerSecond The frames per second of the animation
  85549. * @param totalFrame The total number of frames
  85550. * @param from The frame at the beginning of the animation
  85551. * @param to The frame at the end of the animation
  85552. * @param loopMode Specifies the loop mode of the animation
  85553. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85554. * @param onAnimationEnd Callback to run once the animation is complete
  85555. * @returns Nullable animation
  85556. */
  85557. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85558. /**
  85559. * Transition property of an host to the target Value
  85560. * @param property The property to transition
  85561. * @param targetValue The target Value of the property
  85562. * @param host The object where the property to animate belongs
  85563. * @param scene Scene used to run the animation
  85564. * @param frameRate Framerate (in frame/s) to use
  85565. * @param transition The transition type we want to use
  85566. * @param duration The duration of the animation, in milliseconds
  85567. * @param onAnimationEnd Callback trigger at the end of the animation
  85568. * @returns Nullable animation
  85569. */
  85570. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85571. /**
  85572. * Return the array of runtime animations currently using this animation
  85573. */
  85574. readonly runtimeAnimations: RuntimeAnimation[];
  85575. /**
  85576. * Specifies if any of the runtime animations are currently running
  85577. */
  85578. readonly hasRunningRuntimeAnimations: boolean;
  85579. /**
  85580. * Initializes the animation
  85581. * @param name Name of the animation
  85582. * @param targetProperty Property to animate
  85583. * @param framePerSecond The frames per second of the animation
  85584. * @param dataType The data type of the animation
  85585. * @param loopMode The loop mode of the animation
  85586. * @param enableBlending Specifies if blending should be enabled
  85587. */
  85588. constructor(
  85589. /**Name of the animation */
  85590. name: string,
  85591. /**Property to animate */
  85592. targetProperty: string,
  85593. /**The frames per second of the animation */
  85594. framePerSecond: number,
  85595. /**The data type of the animation */
  85596. dataType: number,
  85597. /**The loop mode of the animation */
  85598. loopMode?: number | undefined,
  85599. /**Specifies if blending should be enabled */
  85600. enableBlending?: boolean | undefined);
  85601. /**
  85602. * Converts the animation to a string
  85603. * @param fullDetails support for multiple levels of logging within scene loading
  85604. * @returns String form of the animation
  85605. */
  85606. toString(fullDetails?: boolean): string;
  85607. /**
  85608. * Add an event to this animation
  85609. * @param event Event to add
  85610. */
  85611. addEvent(event: AnimationEvent): void;
  85612. /**
  85613. * Remove all events found at the given frame
  85614. * @param frame The frame to remove events from
  85615. */
  85616. removeEvents(frame: number): void;
  85617. /**
  85618. * Retrieves all the events from the animation
  85619. * @returns Events from the animation
  85620. */
  85621. getEvents(): AnimationEvent[];
  85622. /**
  85623. * Creates an animation range
  85624. * @param name Name of the animation range
  85625. * @param from Starting frame of the animation range
  85626. * @param to Ending frame of the animation
  85627. */
  85628. createRange(name: string, from: number, to: number): void;
  85629. /**
  85630. * Deletes an animation range by name
  85631. * @param name Name of the animation range to delete
  85632. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85633. */
  85634. deleteRange(name: string, deleteFrames?: boolean): void;
  85635. /**
  85636. * Gets the animation range by name, or null if not defined
  85637. * @param name Name of the animation range
  85638. * @returns Nullable animation range
  85639. */
  85640. getRange(name: string): Nullable<AnimationRange>;
  85641. /**
  85642. * Gets the key frames from the animation
  85643. * @returns The key frames of the animation
  85644. */
  85645. getKeys(): Array<IAnimationKey>;
  85646. /**
  85647. * Gets the highest frame rate of the animation
  85648. * @returns Highest frame rate of the animation
  85649. */
  85650. getHighestFrame(): number;
  85651. /**
  85652. * Gets the easing function of the animation
  85653. * @returns Easing function of the animation
  85654. */
  85655. getEasingFunction(): IEasingFunction;
  85656. /**
  85657. * Sets the easing function of the animation
  85658. * @param easingFunction A custom mathematical formula for animation
  85659. */
  85660. setEasingFunction(easingFunction: EasingFunction): void;
  85661. /**
  85662. * Interpolates a scalar linearly
  85663. * @param startValue Start value of the animation curve
  85664. * @param endValue End value of the animation curve
  85665. * @param gradient Scalar amount to interpolate
  85666. * @returns Interpolated scalar value
  85667. */
  85668. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85669. /**
  85670. * Interpolates a scalar cubically
  85671. * @param startValue Start value of the animation curve
  85672. * @param outTangent End tangent of the animation
  85673. * @param endValue End value of the animation curve
  85674. * @param inTangent Start tangent of the animation curve
  85675. * @param gradient Scalar amount to interpolate
  85676. * @returns Interpolated scalar value
  85677. */
  85678. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85679. /**
  85680. * Interpolates a quaternion using a spherical linear interpolation
  85681. * @param startValue Start value of the animation curve
  85682. * @param endValue End value of the animation curve
  85683. * @param gradient Scalar amount to interpolate
  85684. * @returns Interpolated quaternion value
  85685. */
  85686. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85687. /**
  85688. * Interpolates a quaternion cubically
  85689. * @param startValue Start value of the animation curve
  85690. * @param outTangent End tangent of the animation curve
  85691. * @param endValue End value of the animation curve
  85692. * @param inTangent Start tangent of the animation curve
  85693. * @param gradient Scalar amount to interpolate
  85694. * @returns Interpolated quaternion value
  85695. */
  85696. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85697. /**
  85698. * Interpolates a Vector3 linearl
  85699. * @param startValue Start value of the animation curve
  85700. * @param endValue End value of the animation curve
  85701. * @param gradient Scalar amount to interpolate
  85702. * @returns Interpolated scalar value
  85703. */
  85704. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85705. /**
  85706. * Interpolates a Vector3 cubically
  85707. * @param startValue Start value of the animation curve
  85708. * @param outTangent End tangent of the animation
  85709. * @param endValue End value of the animation curve
  85710. * @param inTangent Start tangent of the animation curve
  85711. * @param gradient Scalar amount to interpolate
  85712. * @returns InterpolatedVector3 value
  85713. */
  85714. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85715. /**
  85716. * Interpolates a Vector2 linearly
  85717. * @param startValue Start value of the animation curve
  85718. * @param endValue End value of the animation curve
  85719. * @param gradient Scalar amount to interpolate
  85720. * @returns Interpolated Vector2 value
  85721. */
  85722. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85723. /**
  85724. * Interpolates a Vector2 cubically
  85725. * @param startValue Start value of the animation curve
  85726. * @param outTangent End tangent of the animation
  85727. * @param endValue End value of the animation curve
  85728. * @param inTangent Start tangent of the animation curve
  85729. * @param gradient Scalar amount to interpolate
  85730. * @returns Interpolated Vector2 value
  85731. */
  85732. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85733. /**
  85734. * Interpolates a size linearly
  85735. * @param startValue Start value of the animation curve
  85736. * @param endValue End value of the animation curve
  85737. * @param gradient Scalar amount to interpolate
  85738. * @returns Interpolated Size value
  85739. */
  85740. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85741. /**
  85742. * Interpolates a Color3 linearly
  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 Color3 value
  85747. */
  85748. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85749. /**
  85750. * @hidden Internal use only
  85751. */
  85752. _getKeyValue(value: any): any;
  85753. /**
  85754. * @hidden Internal use only
  85755. */
  85756. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85757. /**
  85758. * Defines the function to use to interpolate matrices
  85759. * @param startValue defines the start matrix
  85760. * @param endValue defines the end matrix
  85761. * @param gradient defines the gradient between both matrices
  85762. * @param result defines an optional target matrix where to store the interpolation
  85763. * @returns the interpolated matrix
  85764. */
  85765. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85766. /**
  85767. * Makes a copy of the animation
  85768. * @returns Cloned animation
  85769. */
  85770. clone(): Animation;
  85771. /**
  85772. * Sets the key frames of the animation
  85773. * @param values The animation key frames to set
  85774. */
  85775. setKeys(values: Array<IAnimationKey>): void;
  85776. /**
  85777. * Serializes the animation to an object
  85778. * @returns Serialized object
  85779. */
  85780. serialize(): any;
  85781. /**
  85782. * Float animation type
  85783. */
  85784. private static _ANIMATIONTYPE_FLOAT;
  85785. /**
  85786. * Vector3 animation type
  85787. */
  85788. private static _ANIMATIONTYPE_VECTOR3;
  85789. /**
  85790. * Quaternion animation type
  85791. */
  85792. private static _ANIMATIONTYPE_QUATERNION;
  85793. /**
  85794. * Matrix animation type
  85795. */
  85796. private static _ANIMATIONTYPE_MATRIX;
  85797. /**
  85798. * Color3 animation type
  85799. */
  85800. private static _ANIMATIONTYPE_COLOR3;
  85801. /**
  85802. * Vector2 animation type
  85803. */
  85804. private static _ANIMATIONTYPE_VECTOR2;
  85805. /**
  85806. * Size animation type
  85807. */
  85808. private static _ANIMATIONTYPE_SIZE;
  85809. /**
  85810. * Relative Loop Mode
  85811. */
  85812. private static _ANIMATIONLOOPMODE_RELATIVE;
  85813. /**
  85814. * Cycle Loop Mode
  85815. */
  85816. private static _ANIMATIONLOOPMODE_CYCLE;
  85817. /**
  85818. * Constant Loop Mode
  85819. */
  85820. private static _ANIMATIONLOOPMODE_CONSTANT;
  85821. /**
  85822. * Get the float animation type
  85823. */
  85824. static readonly ANIMATIONTYPE_FLOAT: number;
  85825. /**
  85826. * Get the Vector3 animation type
  85827. */
  85828. static readonly ANIMATIONTYPE_VECTOR3: number;
  85829. /**
  85830. * Get the Vector2 animation type
  85831. */
  85832. static readonly ANIMATIONTYPE_VECTOR2: number;
  85833. /**
  85834. * Get the Size animation type
  85835. */
  85836. static readonly ANIMATIONTYPE_SIZE: number;
  85837. /**
  85838. * Get the Quaternion animation type
  85839. */
  85840. static readonly ANIMATIONTYPE_QUATERNION: number;
  85841. /**
  85842. * Get the Matrix animation type
  85843. */
  85844. static readonly ANIMATIONTYPE_MATRIX: number;
  85845. /**
  85846. * Get the Color3 animation type
  85847. */
  85848. static readonly ANIMATIONTYPE_COLOR3: number;
  85849. /**
  85850. * Get the Relative Loop Mode
  85851. */
  85852. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85853. /**
  85854. * Get the Cycle Loop Mode
  85855. */
  85856. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85857. /**
  85858. * Get the Constant Loop Mode
  85859. */
  85860. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85861. /** @hidden */
  85862. static _UniversalLerp(left: any, right: any, amount: number): any;
  85863. /**
  85864. * Parses an animation object and creates an animation
  85865. * @param parsedAnimation Parsed animation object
  85866. * @returns Animation object
  85867. */
  85868. static Parse(parsedAnimation: any): Animation;
  85869. /**
  85870. * Appends the serialized animations from the source animations
  85871. * @param source Source containing the animations
  85872. * @param destination Target to store the animations
  85873. */
  85874. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85875. }
  85876. }
  85877. declare module BABYLON {
  85878. /**
  85879. * Base class of all the textures in babylon.
  85880. * It groups all the common properties the materials, post process, lights... might need
  85881. * in order to make a correct use of the texture.
  85882. */
  85883. export class BaseTexture implements IAnimatable {
  85884. /**
  85885. * Default anisotropic filtering level for the application.
  85886. * It is set to 4 as a good tradeoff between perf and quality.
  85887. */
  85888. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85889. /**
  85890. * Gets or sets the unique id of the texture
  85891. */
  85892. uniqueId: number;
  85893. /**
  85894. * Define the name of the texture.
  85895. */
  85896. name: string;
  85897. /**
  85898. * Gets or sets an object used to store user defined information.
  85899. */
  85900. metadata: any;
  85901. /**
  85902. * For internal use only. Please do not use.
  85903. */
  85904. reservedDataStore: any;
  85905. private _hasAlpha;
  85906. /**
  85907. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85908. */
  85909. hasAlpha: boolean;
  85910. /**
  85911. * Defines if the alpha value should be determined via the rgb values.
  85912. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85913. */
  85914. getAlphaFromRGB: boolean;
  85915. /**
  85916. * Intensity or strength of the texture.
  85917. * It is commonly used by materials to fine tune the intensity of the texture
  85918. */
  85919. level: number;
  85920. /**
  85921. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85922. * This is part of the texture as textures usually maps to one uv set.
  85923. */
  85924. coordinatesIndex: number;
  85925. private _coordinatesMode;
  85926. /**
  85927. * How a texture is mapped.
  85928. *
  85929. * | Value | Type | Description |
  85930. * | ----- | ----------------------------------- | ----------- |
  85931. * | 0 | EXPLICIT_MODE | |
  85932. * | 1 | SPHERICAL_MODE | |
  85933. * | 2 | PLANAR_MODE | |
  85934. * | 3 | CUBIC_MODE | |
  85935. * | 4 | PROJECTION_MODE | |
  85936. * | 5 | SKYBOX_MODE | |
  85937. * | 6 | INVCUBIC_MODE | |
  85938. * | 7 | EQUIRECTANGULAR_MODE | |
  85939. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85940. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85941. */
  85942. coordinatesMode: number;
  85943. /**
  85944. * | Value | Type | Description |
  85945. * | ----- | ------------------ | ----------- |
  85946. * | 0 | CLAMP_ADDRESSMODE | |
  85947. * | 1 | WRAP_ADDRESSMODE | |
  85948. * | 2 | MIRROR_ADDRESSMODE | |
  85949. */
  85950. wrapU: number;
  85951. /**
  85952. * | Value | Type | Description |
  85953. * | ----- | ------------------ | ----------- |
  85954. * | 0 | CLAMP_ADDRESSMODE | |
  85955. * | 1 | WRAP_ADDRESSMODE | |
  85956. * | 2 | MIRROR_ADDRESSMODE | |
  85957. */
  85958. wrapV: number;
  85959. /**
  85960. * | Value | Type | Description |
  85961. * | ----- | ------------------ | ----------- |
  85962. * | 0 | CLAMP_ADDRESSMODE | |
  85963. * | 1 | WRAP_ADDRESSMODE | |
  85964. * | 2 | MIRROR_ADDRESSMODE | |
  85965. */
  85966. wrapR: number;
  85967. /**
  85968. * With compliant hardware and browser (supporting anisotropic filtering)
  85969. * this defines the level of anisotropic filtering in the texture.
  85970. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85971. */
  85972. anisotropicFilteringLevel: number;
  85973. /**
  85974. * Define if the texture is a cube texture or if false a 2d texture.
  85975. */
  85976. isCube: boolean;
  85977. /**
  85978. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85979. */
  85980. is3D: boolean;
  85981. /**
  85982. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85983. * HDR texture are usually stored in linear space.
  85984. * This only impacts the PBR and Background materials
  85985. */
  85986. gammaSpace: boolean;
  85987. /**
  85988. * Gets whether or not the texture contains RGBD data.
  85989. */
  85990. readonly isRGBD: boolean;
  85991. /**
  85992. * Is Z inverted in the texture (useful in a cube texture).
  85993. */
  85994. invertZ: boolean;
  85995. /**
  85996. * Are mip maps generated for this texture or not.
  85997. */
  85998. readonly noMipmap: boolean;
  85999. /**
  86000. * @hidden
  86001. */
  86002. lodLevelInAlpha: boolean;
  86003. /**
  86004. * With prefiltered texture, defined the offset used during the prefiltering steps.
  86005. */
  86006. lodGenerationOffset: number;
  86007. /**
  86008. * With prefiltered texture, defined the scale used during the prefiltering steps.
  86009. */
  86010. lodGenerationScale: number;
  86011. /**
  86012. * Define if the texture is a render target.
  86013. */
  86014. isRenderTarget: boolean;
  86015. /**
  86016. * Define the unique id of the texture in the scene.
  86017. */
  86018. readonly uid: string;
  86019. /**
  86020. * Return a string representation of the texture.
  86021. * @returns the texture as a string
  86022. */
  86023. toString(): string;
  86024. /**
  86025. * Get the class name of the texture.
  86026. * @returns "BaseTexture"
  86027. */
  86028. getClassName(): string;
  86029. /**
  86030. * Define the list of animation attached to the texture.
  86031. */
  86032. animations: Animation[];
  86033. /**
  86034. * An event triggered when the texture is disposed.
  86035. */
  86036. onDisposeObservable: Observable<BaseTexture>;
  86037. private _onDisposeObserver;
  86038. /**
  86039. * Callback triggered when the texture has been disposed.
  86040. * Kept for back compatibility, you can use the onDisposeObservable instead.
  86041. */
  86042. onDispose: () => void;
  86043. /**
  86044. * Define the current state of the loading sequence when in delayed load mode.
  86045. */
  86046. delayLoadState: number;
  86047. private _scene;
  86048. /** @hidden */
  86049. _texture: Nullable<InternalTexture>;
  86050. private _uid;
  86051. /**
  86052. * Define if the texture is preventinga material to render or not.
  86053. * If not and the texture is not ready, the engine will use a default black texture instead.
  86054. */
  86055. readonly isBlocking: boolean;
  86056. /**
  86057. * Instantiates a new BaseTexture.
  86058. * Base class of all the textures in babylon.
  86059. * It groups all the common properties the materials, post process, lights... might need
  86060. * in order to make a correct use of the texture.
  86061. * @param scene Define the scene the texture blongs to
  86062. */
  86063. constructor(scene: Nullable<Scene>);
  86064. /**
  86065. * Get the scene the texture belongs to.
  86066. * @returns the scene or null if undefined
  86067. */
  86068. getScene(): Nullable<Scene>;
  86069. /**
  86070. * Get the texture transform matrix used to offset tile the texture for istance.
  86071. * @returns the transformation matrix
  86072. */
  86073. getTextureMatrix(): Matrix;
  86074. /**
  86075. * Get the texture reflection matrix used to rotate/transform the reflection.
  86076. * @returns the reflection matrix
  86077. */
  86078. getReflectionTextureMatrix(): Matrix;
  86079. /**
  86080. * Get the underlying lower level texture from Babylon.
  86081. * @returns the insternal texture
  86082. */
  86083. getInternalTexture(): Nullable<InternalTexture>;
  86084. /**
  86085. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  86086. * @returns true if ready or not blocking
  86087. */
  86088. isReadyOrNotBlocking(): boolean;
  86089. /**
  86090. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86091. * @returns true if fully ready
  86092. */
  86093. isReady(): boolean;
  86094. private _cachedSize;
  86095. /**
  86096. * Get the size of the texture.
  86097. * @returns the texture size.
  86098. */
  86099. getSize(): ISize;
  86100. /**
  86101. * Get the base size of the texture.
  86102. * It can be different from the size if the texture has been resized for POT for instance
  86103. * @returns the base size
  86104. */
  86105. getBaseSize(): ISize;
  86106. /**
  86107. * Update the sampling mode of the texture.
  86108. * Default is Trilinear mode.
  86109. *
  86110. * | Value | Type | Description |
  86111. * | ----- | ------------------ | ----------- |
  86112. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86113. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86114. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86115. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86116. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86117. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86118. * | 7 | NEAREST_LINEAR | |
  86119. * | 8 | NEAREST_NEAREST | |
  86120. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86121. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86122. * | 11 | LINEAR_LINEAR | |
  86123. * | 12 | LINEAR_NEAREST | |
  86124. *
  86125. * > _mag_: magnification filter (close to the viewer)
  86126. * > _min_: minification filter (far from the viewer)
  86127. * > _mip_: filter used between mip map levels
  86128. *@param samplingMode Define the new sampling mode of the texture
  86129. */
  86130. updateSamplingMode(samplingMode: number): void;
  86131. /**
  86132. * Scales the texture if is `canRescale()`
  86133. * @param ratio the resize factor we want to use to rescale
  86134. */
  86135. scale(ratio: number): void;
  86136. /**
  86137. * Get if the texture can rescale.
  86138. */
  86139. readonly canRescale: boolean;
  86140. /** @hidden */
  86141. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  86142. /** @hidden */
  86143. _rebuild(): void;
  86144. /**
  86145. * Triggers the load sequence in delayed load mode.
  86146. */
  86147. delayLoad(): void;
  86148. /**
  86149. * Clones the texture.
  86150. * @returns the cloned texture
  86151. */
  86152. clone(): Nullable<BaseTexture>;
  86153. /**
  86154. * Get the texture underlying type (INT, FLOAT...)
  86155. */
  86156. readonly textureType: number;
  86157. /**
  86158. * Get the texture underlying format (RGB, RGBA...)
  86159. */
  86160. readonly textureFormat: number;
  86161. /**
  86162. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  86163. * This will returns an RGBA array buffer containing either in values (0-255) or
  86164. * float values (0-1) depending of the underlying buffer type.
  86165. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  86166. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  86167. * @param buffer defines a user defined buffer to fill with data (can be null)
  86168. * @returns The Array buffer containing the pixels data.
  86169. */
  86170. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  86171. /**
  86172. * Release and destroy the underlying lower level texture aka internalTexture.
  86173. */
  86174. releaseInternalTexture(): void;
  86175. /**
  86176. * Get the polynomial representation of the texture data.
  86177. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  86178. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  86179. */
  86180. sphericalPolynomial: Nullable<SphericalPolynomial>;
  86181. /** @hidden */
  86182. readonly _lodTextureHigh: Nullable<BaseTexture>;
  86183. /** @hidden */
  86184. readonly _lodTextureMid: Nullable<BaseTexture>;
  86185. /** @hidden */
  86186. readonly _lodTextureLow: Nullable<BaseTexture>;
  86187. /**
  86188. * Dispose the texture and release its associated resources.
  86189. */
  86190. dispose(): void;
  86191. /**
  86192. * Serialize the texture into a JSON representation that can be parsed later on.
  86193. * @returns the JSON representation of the texture
  86194. */
  86195. serialize(): any;
  86196. /**
  86197. * Helper function to be called back once a list of texture contains only ready textures.
  86198. * @param textures Define the list of textures to wait for
  86199. * @param callback Define the callback triggered once the entire list will be ready
  86200. */
  86201. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  86202. }
  86203. }
  86204. declare module BABYLON {
  86205. /**
  86206. * Uniform buffer objects.
  86207. *
  86208. * Handles blocks of uniform on the GPU.
  86209. *
  86210. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86211. *
  86212. * For more information, please refer to :
  86213. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86214. */
  86215. export class UniformBuffer {
  86216. private _engine;
  86217. private _buffer;
  86218. private _data;
  86219. private _bufferData;
  86220. private _dynamic?;
  86221. private _uniformLocations;
  86222. private _uniformSizes;
  86223. private _uniformLocationPointer;
  86224. private _needSync;
  86225. private _noUBO;
  86226. private _currentEffect;
  86227. private static _MAX_UNIFORM_SIZE;
  86228. private static _tempBuffer;
  86229. /**
  86230. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86231. * This is dynamic to allow compat with webgl 1 and 2.
  86232. * You will need to pass the name of the uniform as well as the value.
  86233. */
  86234. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86235. /**
  86236. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86237. * This is dynamic to allow compat with webgl 1 and 2.
  86238. * You will need to pass the name of the uniform as well as the value.
  86239. */
  86240. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86241. /**
  86242. * Lambda to Update a single float in a uniform buffer.
  86243. * This is dynamic to allow compat with webgl 1 and 2.
  86244. * You will need to pass the name of the uniform as well as the value.
  86245. */
  86246. updateFloat: (name: string, x: number) => void;
  86247. /**
  86248. * Lambda to Update a vec2 of float in a uniform buffer.
  86249. * This is dynamic to allow compat with webgl 1 and 2.
  86250. * You will need to pass the name of the uniform as well as the value.
  86251. */
  86252. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86253. /**
  86254. * Lambda to Update a vec3 of float in a uniform buffer.
  86255. * This is dynamic to allow compat with webgl 1 and 2.
  86256. * You will need to pass the name of the uniform as well as the value.
  86257. */
  86258. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86259. /**
  86260. * Lambda to Update a vec4 of float in a uniform buffer.
  86261. * This is dynamic to allow compat with webgl 1 and 2.
  86262. * You will need to pass the name of the uniform as well as the value.
  86263. */
  86264. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86265. /**
  86266. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86267. * This is dynamic to allow compat with webgl 1 and 2.
  86268. * You will need to pass the name of the uniform as well as the value.
  86269. */
  86270. updateMatrix: (name: string, mat: Matrix) => void;
  86271. /**
  86272. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86273. * This is dynamic to allow compat with webgl 1 and 2.
  86274. * You will need to pass the name of the uniform as well as the value.
  86275. */
  86276. updateVector3: (name: string, vector: Vector3) => void;
  86277. /**
  86278. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86279. * This is dynamic to allow compat with webgl 1 and 2.
  86280. * You will need to pass the name of the uniform as well as the value.
  86281. */
  86282. updateVector4: (name: string, vector: Vector4) => void;
  86283. /**
  86284. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86285. * This is dynamic to allow compat with webgl 1 and 2.
  86286. * You will need to pass the name of the uniform as well as the value.
  86287. */
  86288. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86289. /**
  86290. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86291. * This is dynamic to allow compat with webgl 1 and 2.
  86292. * You will need to pass the name of the uniform as well as the value.
  86293. */
  86294. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86295. /**
  86296. * Instantiates a new Uniform buffer objects.
  86297. *
  86298. * Handles blocks of uniform on the GPU.
  86299. *
  86300. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86301. *
  86302. * For more information, please refer to :
  86303. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86304. * @param engine Define the engine the buffer is associated with
  86305. * @param data Define the data contained in the buffer
  86306. * @param dynamic Define if the buffer is updatable
  86307. */
  86308. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86309. /**
  86310. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86311. * or just falling back on setUniformXXX calls.
  86312. */
  86313. readonly useUbo: boolean;
  86314. /**
  86315. * Indicates if the WebGL underlying uniform buffer is in sync
  86316. * with the javascript cache data.
  86317. */
  86318. readonly isSync: boolean;
  86319. /**
  86320. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86321. * Also, a dynamic UniformBuffer will disable cache verification and always
  86322. * update the underlying WebGL uniform buffer to the GPU.
  86323. * @returns if Dynamic, otherwise false
  86324. */
  86325. isDynamic(): boolean;
  86326. /**
  86327. * The data cache on JS side.
  86328. * @returns the underlying data as a float array
  86329. */
  86330. getData(): Float32Array;
  86331. /**
  86332. * The underlying WebGL Uniform buffer.
  86333. * @returns the webgl buffer
  86334. */
  86335. getBuffer(): Nullable<DataBuffer>;
  86336. /**
  86337. * std140 layout specifies how to align data within an UBO structure.
  86338. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86339. * for specs.
  86340. */
  86341. private _fillAlignment;
  86342. /**
  86343. * Adds an uniform in the buffer.
  86344. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86345. * for the layout to be correct !
  86346. * @param name Name of the uniform, as used in the uniform block in the shader.
  86347. * @param size Data size, or data directly.
  86348. */
  86349. addUniform(name: string, size: number | number[]): void;
  86350. /**
  86351. * Adds a Matrix 4x4 to the uniform buffer.
  86352. * @param name Name of the uniform, as used in the uniform block in the shader.
  86353. * @param mat A 4x4 matrix.
  86354. */
  86355. addMatrix(name: string, mat: Matrix): void;
  86356. /**
  86357. * Adds a vec2 to the uniform buffer.
  86358. * @param name Name of the uniform, as used in the uniform block in the shader.
  86359. * @param x Define the x component value of the vec2
  86360. * @param y Define the y component value of the vec2
  86361. */
  86362. addFloat2(name: string, x: number, y: number): void;
  86363. /**
  86364. * Adds a vec3 to the uniform buffer.
  86365. * @param name Name of the uniform, as used in the uniform block in the shader.
  86366. * @param x Define the x component value of the vec3
  86367. * @param y Define the y component value of the vec3
  86368. * @param z Define the z component value of the vec3
  86369. */
  86370. addFloat3(name: string, x: number, y: number, z: number): void;
  86371. /**
  86372. * Adds a vec3 to the uniform buffer.
  86373. * @param name Name of the uniform, as used in the uniform block in the shader.
  86374. * @param color Define the vec3 from a Color
  86375. */
  86376. addColor3(name: string, color: Color3): void;
  86377. /**
  86378. * Adds a vec4 to the uniform buffer.
  86379. * @param name Name of the uniform, as used in the uniform block in the shader.
  86380. * @param color Define the rgb components from a Color
  86381. * @param alpha Define the a component of the vec4
  86382. */
  86383. addColor4(name: string, color: Color3, alpha: number): void;
  86384. /**
  86385. * Adds a vec3 to the uniform buffer.
  86386. * @param name Name of the uniform, as used in the uniform block in the shader.
  86387. * @param vector Define the vec3 components from a Vector
  86388. */
  86389. addVector3(name: string, vector: Vector3): void;
  86390. /**
  86391. * Adds a Matrix 3x3 to the uniform buffer.
  86392. * @param name Name of the uniform, as used in the uniform block in the shader.
  86393. */
  86394. addMatrix3x3(name: string): void;
  86395. /**
  86396. * Adds a Matrix 2x2 to the uniform buffer.
  86397. * @param name Name of the uniform, as used in the uniform block in the shader.
  86398. */
  86399. addMatrix2x2(name: string): void;
  86400. /**
  86401. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86402. */
  86403. create(): void;
  86404. /** @hidden */
  86405. _rebuild(): void;
  86406. /**
  86407. * Updates the WebGL Uniform Buffer on the GPU.
  86408. * If the `dynamic` flag is set to true, no cache comparison is done.
  86409. * Otherwise, the buffer will be updated only if the cache differs.
  86410. */
  86411. update(): void;
  86412. /**
  86413. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86414. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86415. * @param data Define the flattened data
  86416. * @param size Define the size of the data.
  86417. */
  86418. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86419. private _updateMatrix3x3ForUniform;
  86420. private _updateMatrix3x3ForEffect;
  86421. private _updateMatrix2x2ForEffect;
  86422. private _updateMatrix2x2ForUniform;
  86423. private _updateFloatForEffect;
  86424. private _updateFloatForUniform;
  86425. private _updateFloat2ForEffect;
  86426. private _updateFloat2ForUniform;
  86427. private _updateFloat3ForEffect;
  86428. private _updateFloat3ForUniform;
  86429. private _updateFloat4ForEffect;
  86430. private _updateFloat4ForUniform;
  86431. private _updateMatrixForEffect;
  86432. private _updateMatrixForUniform;
  86433. private _updateVector3ForEffect;
  86434. private _updateVector3ForUniform;
  86435. private _updateVector4ForEffect;
  86436. private _updateVector4ForUniform;
  86437. private _updateColor3ForEffect;
  86438. private _updateColor3ForUniform;
  86439. private _updateColor4ForEffect;
  86440. private _updateColor4ForUniform;
  86441. /**
  86442. * Sets a sampler uniform on the effect.
  86443. * @param name Define the name of the sampler.
  86444. * @param texture Define the texture to set in the sampler
  86445. */
  86446. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86447. /**
  86448. * Directly updates the value of the uniform in the cache AND on the GPU.
  86449. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86450. * @param data Define the flattened data
  86451. */
  86452. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86453. /**
  86454. * Binds this uniform buffer to an effect.
  86455. * @param effect Define the effect to bind the buffer to
  86456. * @param name Name of the uniform block in the shader.
  86457. */
  86458. bindToEffect(effect: Effect, name: string): void;
  86459. /**
  86460. * Disposes the uniform buffer.
  86461. */
  86462. dispose(): void;
  86463. }
  86464. }
  86465. declare module BABYLON {
  86466. /**
  86467. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86469. */
  86470. export class Analyser {
  86471. /**
  86472. * Gets or sets the smoothing
  86473. * @ignorenaming
  86474. */
  86475. SMOOTHING: number;
  86476. /**
  86477. * Gets or sets the FFT table size
  86478. * @ignorenaming
  86479. */
  86480. FFT_SIZE: number;
  86481. /**
  86482. * Gets or sets the bar graph amplitude
  86483. * @ignorenaming
  86484. */
  86485. BARGRAPHAMPLITUDE: number;
  86486. /**
  86487. * Gets or sets the position of the debug canvas
  86488. * @ignorenaming
  86489. */
  86490. DEBUGCANVASPOS: {
  86491. x: number;
  86492. y: number;
  86493. };
  86494. /**
  86495. * Gets or sets the debug canvas size
  86496. * @ignorenaming
  86497. */
  86498. DEBUGCANVASSIZE: {
  86499. width: number;
  86500. height: number;
  86501. };
  86502. private _byteFreqs;
  86503. private _byteTime;
  86504. private _floatFreqs;
  86505. private _webAudioAnalyser;
  86506. private _debugCanvas;
  86507. private _debugCanvasContext;
  86508. private _scene;
  86509. private _registerFunc;
  86510. private _audioEngine;
  86511. /**
  86512. * Creates a new analyser
  86513. * @param scene defines hosting scene
  86514. */
  86515. constructor(scene: Scene);
  86516. /**
  86517. * Get the number of data values you will have to play with for the visualization
  86518. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86519. * @returns a number
  86520. */
  86521. getFrequencyBinCount(): number;
  86522. /**
  86523. * Gets the current frequency data as a byte array
  86524. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86525. * @returns a Uint8Array
  86526. */
  86527. getByteFrequencyData(): Uint8Array;
  86528. /**
  86529. * Gets the current waveform as a byte array
  86530. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86531. * @returns a Uint8Array
  86532. */
  86533. getByteTimeDomainData(): Uint8Array;
  86534. /**
  86535. * Gets the current frequency data as a float array
  86536. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86537. * @returns a Float32Array
  86538. */
  86539. getFloatFrequencyData(): Float32Array;
  86540. /**
  86541. * Renders the debug canvas
  86542. */
  86543. drawDebugCanvas(): void;
  86544. /**
  86545. * Stops rendering the debug canvas and removes it
  86546. */
  86547. stopDebugCanvas(): void;
  86548. /**
  86549. * Connects two audio nodes
  86550. * @param inputAudioNode defines first node to connect
  86551. * @param outputAudioNode defines second node to connect
  86552. */
  86553. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86554. /**
  86555. * Releases all associated resources
  86556. */
  86557. dispose(): void;
  86558. }
  86559. }
  86560. declare module BABYLON {
  86561. /**
  86562. * This represents an audio engine and it is responsible
  86563. * to play, synchronize and analyse sounds throughout the application.
  86564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86565. */
  86566. export interface IAudioEngine extends IDisposable {
  86567. /**
  86568. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86569. */
  86570. readonly canUseWebAudio: boolean;
  86571. /**
  86572. * Gets the current AudioContext if available.
  86573. */
  86574. readonly audioContext: Nullable<AudioContext>;
  86575. /**
  86576. * The master gain node defines the global audio volume of your audio engine.
  86577. */
  86578. readonly masterGain: GainNode;
  86579. /**
  86580. * Gets whether or not mp3 are supported by your browser.
  86581. */
  86582. readonly isMP3supported: boolean;
  86583. /**
  86584. * Gets whether or not ogg are supported by your browser.
  86585. */
  86586. readonly isOGGsupported: boolean;
  86587. /**
  86588. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86589. * @ignoreNaming
  86590. */
  86591. WarnedWebAudioUnsupported: boolean;
  86592. /**
  86593. * Defines if the audio engine relies on a custom unlocked button.
  86594. * In this case, the embedded button will not be displayed.
  86595. */
  86596. useCustomUnlockedButton: boolean;
  86597. /**
  86598. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86599. */
  86600. readonly unlocked: boolean;
  86601. /**
  86602. * Event raised when audio has been unlocked on the browser.
  86603. */
  86604. onAudioUnlockedObservable: Observable<AudioEngine>;
  86605. /**
  86606. * Event raised when audio has been locked on the browser.
  86607. */
  86608. onAudioLockedObservable: Observable<AudioEngine>;
  86609. /**
  86610. * Flags the audio engine in Locked state.
  86611. * This happens due to new browser policies preventing audio to autoplay.
  86612. */
  86613. lock(): void;
  86614. /**
  86615. * Unlocks the audio engine once a user action has been done on the dom.
  86616. * This is helpful to resume play once browser policies have been satisfied.
  86617. */
  86618. unlock(): void;
  86619. }
  86620. /**
  86621. * This represents the default audio engine used in babylon.
  86622. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86624. */
  86625. export class AudioEngine implements IAudioEngine {
  86626. private _audioContext;
  86627. private _audioContextInitialized;
  86628. private _muteButton;
  86629. private _hostElement;
  86630. /**
  86631. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86632. */
  86633. canUseWebAudio: boolean;
  86634. /**
  86635. * The master gain node defines the global audio volume of your audio engine.
  86636. */
  86637. masterGain: GainNode;
  86638. /**
  86639. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86640. * @ignoreNaming
  86641. */
  86642. WarnedWebAudioUnsupported: boolean;
  86643. /**
  86644. * Gets whether or not mp3 are supported by your browser.
  86645. */
  86646. isMP3supported: boolean;
  86647. /**
  86648. * Gets whether or not ogg are supported by your browser.
  86649. */
  86650. isOGGsupported: boolean;
  86651. /**
  86652. * Gets whether audio has been unlocked on the device.
  86653. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86654. * a user interaction has happened.
  86655. */
  86656. unlocked: boolean;
  86657. /**
  86658. * Defines if the audio engine relies on a custom unlocked button.
  86659. * In this case, the embedded button will not be displayed.
  86660. */
  86661. useCustomUnlockedButton: boolean;
  86662. /**
  86663. * Event raised when audio has been unlocked on the browser.
  86664. */
  86665. onAudioUnlockedObservable: Observable<AudioEngine>;
  86666. /**
  86667. * Event raised when audio has been locked on the browser.
  86668. */
  86669. onAudioLockedObservable: Observable<AudioEngine>;
  86670. /**
  86671. * Gets the current AudioContext if available.
  86672. */
  86673. readonly audioContext: Nullable<AudioContext>;
  86674. private _connectedAnalyser;
  86675. /**
  86676. * Instantiates a new audio engine.
  86677. *
  86678. * There should be only one per page as some browsers restrict the number
  86679. * of audio contexts you can create.
  86680. * @param hostElement defines the host element where to display the mute icon if necessary
  86681. */
  86682. constructor(hostElement?: Nullable<HTMLElement>);
  86683. /**
  86684. * Flags the audio engine in Locked state.
  86685. * This happens due to new browser policies preventing audio to autoplay.
  86686. */
  86687. lock(): void;
  86688. /**
  86689. * Unlocks the audio engine once a user action has been done on the dom.
  86690. * This is helpful to resume play once browser policies have been satisfied.
  86691. */
  86692. unlock(): void;
  86693. private _resumeAudioContext;
  86694. private _initializeAudioContext;
  86695. private _tryToRun;
  86696. private _triggerRunningState;
  86697. private _triggerSuspendedState;
  86698. private _displayMuteButton;
  86699. private _moveButtonToTopLeft;
  86700. private _onResize;
  86701. private _hideMuteButton;
  86702. /**
  86703. * Destroy and release the resources associated with the audio ccontext.
  86704. */
  86705. dispose(): void;
  86706. /**
  86707. * Gets the global volume sets on the master gain.
  86708. * @returns the global volume if set or -1 otherwise
  86709. */
  86710. getGlobalVolume(): number;
  86711. /**
  86712. * Sets the global volume of your experience (sets on the master gain).
  86713. * @param newVolume Defines the new global volume of the application
  86714. */
  86715. setGlobalVolume(newVolume: number): void;
  86716. /**
  86717. * Connect the audio engine to an audio analyser allowing some amazing
  86718. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86720. * @param analyser The analyser to connect to the engine
  86721. */
  86722. connectToAnalyser(analyser: Analyser): void;
  86723. }
  86724. }
  86725. declare module BABYLON {
  86726. /**
  86727. * Interface used to present a loading screen while loading a scene
  86728. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86729. */
  86730. export interface ILoadingScreen {
  86731. /**
  86732. * Function called to display the loading screen
  86733. */
  86734. displayLoadingUI: () => void;
  86735. /**
  86736. * Function called to hide the loading screen
  86737. */
  86738. hideLoadingUI: () => void;
  86739. /**
  86740. * Gets or sets the color to use for the background
  86741. */
  86742. loadingUIBackgroundColor: string;
  86743. /**
  86744. * Gets or sets the text to display while loading
  86745. */
  86746. loadingUIText: string;
  86747. }
  86748. /**
  86749. * Class used for the default loading screen
  86750. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86751. */
  86752. export class DefaultLoadingScreen implements ILoadingScreen {
  86753. private _renderingCanvas;
  86754. private _loadingText;
  86755. private _loadingDivBackgroundColor;
  86756. private _loadingDiv;
  86757. private _loadingTextDiv;
  86758. /**
  86759. * Creates a new default loading screen
  86760. * @param _renderingCanvas defines the canvas used to render the scene
  86761. * @param _loadingText defines the default text to display
  86762. * @param _loadingDivBackgroundColor defines the default background color
  86763. */
  86764. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86765. /**
  86766. * Function called to display the loading screen
  86767. */
  86768. displayLoadingUI(): void;
  86769. /**
  86770. * Function called to hide the loading screen
  86771. */
  86772. hideLoadingUI(): void;
  86773. /**
  86774. * Gets or sets the text to display while loading
  86775. */
  86776. loadingUIText: string;
  86777. /**
  86778. * Gets or sets the color to use for the background
  86779. */
  86780. loadingUIBackgroundColor: string;
  86781. private _resizeLoadingUI;
  86782. }
  86783. }
  86784. declare module BABYLON {
  86785. /** @hidden */
  86786. export class WebGLPipelineContext implements IPipelineContext {
  86787. engine: Engine;
  86788. program: Nullable<WebGLProgram>;
  86789. context?: WebGLRenderingContext;
  86790. vertexShader?: WebGLShader;
  86791. fragmentShader?: WebGLShader;
  86792. isParallelCompiled: boolean;
  86793. onCompiled?: () => void;
  86794. transformFeedback?: WebGLTransformFeedback | null;
  86795. readonly isAsync: boolean;
  86796. readonly isReady: boolean;
  86797. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86798. }
  86799. }
  86800. declare module BABYLON {
  86801. /** @hidden */
  86802. export class WebGLDataBuffer extends DataBuffer {
  86803. private _buffer;
  86804. constructor(resource: WebGLBuffer);
  86805. readonly underlyingResource: any;
  86806. }
  86807. }
  86808. declare module BABYLON {
  86809. /**
  86810. * Settings for finer control over video usage
  86811. */
  86812. export interface VideoTextureSettings {
  86813. /**
  86814. * Applies `autoplay` to video, if specified
  86815. */
  86816. autoPlay?: boolean;
  86817. /**
  86818. * Applies `loop` to video, if specified
  86819. */
  86820. loop?: boolean;
  86821. /**
  86822. * Automatically updates internal texture from video at every frame in the render loop
  86823. */
  86824. autoUpdateTexture: boolean;
  86825. /**
  86826. * Image src displayed during the video loading or until the user interacts with the video.
  86827. */
  86828. poster?: string;
  86829. }
  86830. /**
  86831. * If you want to display a video in your scene, this is the special texture for that.
  86832. * This special texture works similar to other textures, with the exception of a few parameters.
  86833. * @see https://doc.babylonjs.com/how_to/video_texture
  86834. */
  86835. export class VideoTexture extends Texture {
  86836. /**
  86837. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86838. */
  86839. readonly autoUpdateTexture: boolean;
  86840. /**
  86841. * The video instance used by the texture internally
  86842. */
  86843. readonly video: HTMLVideoElement;
  86844. private _onUserActionRequestedObservable;
  86845. /**
  86846. * Event triggerd when a dom action is required by the user to play the video.
  86847. * This happens due to recent changes in browser policies preventing video to auto start.
  86848. */
  86849. readonly onUserActionRequestedObservable: Observable<Texture>;
  86850. private _generateMipMaps;
  86851. private _engine;
  86852. private _stillImageCaptured;
  86853. private _displayingPosterTexture;
  86854. private _settings;
  86855. private _createInternalTextureOnEvent;
  86856. /**
  86857. * Creates a video texture.
  86858. * If you want to display a video in your scene, this is the special texture for that.
  86859. * This special texture works similar to other textures, with the exception of a few parameters.
  86860. * @see https://doc.babylonjs.com/how_to/video_texture
  86861. * @param name optional name, will detect from video source, if not defined
  86862. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86863. * @param scene is obviously the current scene.
  86864. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86865. * @param invertY is false by default but can be used to invert video on Y axis
  86866. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86867. * @param settings allows finer control over video usage
  86868. */
  86869. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86870. private _getName;
  86871. private _getVideo;
  86872. private _createInternalTexture;
  86873. private reset;
  86874. /**
  86875. * @hidden Internal method to initiate `update`.
  86876. */
  86877. _rebuild(): void;
  86878. /**
  86879. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86880. */
  86881. update(): void;
  86882. /**
  86883. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86884. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86885. */
  86886. updateTexture(isVisible: boolean): void;
  86887. protected _updateInternalTexture: () => void;
  86888. /**
  86889. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86890. * @param url New url.
  86891. */
  86892. updateURL(url: string): void;
  86893. /**
  86894. * Dispose the texture and release its associated resources.
  86895. */
  86896. dispose(): void;
  86897. /**
  86898. * Creates a video texture straight from a stream.
  86899. * @param scene Define the scene the texture should be created in
  86900. * @param stream Define the stream the texture should be created from
  86901. * @returns The created video texture as a promise
  86902. */
  86903. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86904. /**
  86905. * Creates a video texture straight from your WebCam video feed.
  86906. * @param scene Define the scene the texture should be created in
  86907. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86908. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86909. * @returns The created video texture as a promise
  86910. */
  86911. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86912. minWidth: number;
  86913. maxWidth: number;
  86914. minHeight: number;
  86915. maxHeight: number;
  86916. deviceId: string;
  86917. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86918. /**
  86919. * Creates a video texture straight from your WebCam video feed.
  86920. * @param scene Define the scene the texture should be created in
  86921. * @param onReady Define a callback to triggered once the texture will be ready
  86922. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86923. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86924. */
  86925. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86926. minWidth: number;
  86927. maxWidth: number;
  86928. minHeight: number;
  86929. maxHeight: number;
  86930. deviceId: string;
  86931. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86932. }
  86933. }
  86934. declare module BABYLON {
  86935. /**
  86936. * Interface for attribute information associated with buffer instanciation
  86937. */
  86938. export class InstancingAttributeInfo {
  86939. /**
  86940. * Index/offset of the attribute in the vertex shader
  86941. */
  86942. index: number;
  86943. /**
  86944. * size of the attribute, 1, 2, 3 or 4
  86945. */
  86946. attributeSize: number;
  86947. /**
  86948. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86949. * default is FLOAT
  86950. */
  86951. attribyteType: number;
  86952. /**
  86953. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86954. */
  86955. normalized: boolean;
  86956. /**
  86957. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86958. */
  86959. offset: number;
  86960. /**
  86961. * Name of the GLSL attribute, for debugging purpose only
  86962. */
  86963. attributeName: string;
  86964. }
  86965. /**
  86966. * Define options used to create a depth texture
  86967. */
  86968. export class DepthTextureCreationOptions {
  86969. /** Specifies whether or not a stencil should be allocated in the texture */
  86970. generateStencil?: boolean;
  86971. /** Specifies whether or not bilinear filtering is enable on the texture */
  86972. bilinearFiltering?: boolean;
  86973. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86974. comparisonFunction?: number;
  86975. /** Specifies if the created texture is a cube texture */
  86976. isCube?: boolean;
  86977. }
  86978. /**
  86979. * Class used to describe the capabilities of the engine relatively to the current browser
  86980. */
  86981. export class EngineCapabilities {
  86982. /** Maximum textures units per fragment shader */
  86983. maxTexturesImageUnits: number;
  86984. /** Maximum texture units per vertex shader */
  86985. maxVertexTextureImageUnits: number;
  86986. /** Maximum textures units in the entire pipeline */
  86987. maxCombinedTexturesImageUnits: number;
  86988. /** Maximum texture size */
  86989. maxTextureSize: number;
  86990. /** Maximum cube texture size */
  86991. maxCubemapTextureSize: number;
  86992. /** Maximum render texture size */
  86993. maxRenderTextureSize: number;
  86994. /** Maximum number of vertex attributes */
  86995. maxVertexAttribs: number;
  86996. /** Maximum number of varyings */
  86997. maxVaryingVectors: number;
  86998. /** Maximum number of uniforms per vertex shader */
  86999. maxVertexUniformVectors: number;
  87000. /** Maximum number of uniforms per fragment shader */
  87001. maxFragmentUniformVectors: number;
  87002. /** Defines if standard derivates (dx/dy) are supported */
  87003. standardDerivatives: boolean;
  87004. /** Defines if s3tc texture compression is supported */
  87005. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  87006. /** Defines if pvrtc texture compression is supported */
  87007. pvrtc: any;
  87008. /** Defines if etc1 texture compression is supported */
  87009. etc1: any;
  87010. /** Defines if etc2 texture compression is supported */
  87011. etc2: any;
  87012. /** Defines if astc texture compression is supported */
  87013. astc: any;
  87014. /** Defines if float textures are supported */
  87015. textureFloat: boolean;
  87016. /** Defines if vertex array objects are supported */
  87017. vertexArrayObject: boolean;
  87018. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  87019. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  87020. /** Gets the maximum level of anisotropy supported */
  87021. maxAnisotropy: number;
  87022. /** Defines if instancing is supported */
  87023. instancedArrays: boolean;
  87024. /** Defines if 32 bits indices are supported */
  87025. uintIndices: boolean;
  87026. /** Defines if high precision shaders are supported */
  87027. highPrecisionShaderSupported: boolean;
  87028. /** Defines if depth reading in the fragment shader is supported */
  87029. fragmentDepthSupported: boolean;
  87030. /** Defines if float texture linear filtering is supported*/
  87031. textureFloatLinearFiltering: boolean;
  87032. /** Defines if rendering to float textures is supported */
  87033. textureFloatRender: boolean;
  87034. /** Defines if half float textures are supported*/
  87035. textureHalfFloat: boolean;
  87036. /** Defines if half float texture linear filtering is supported*/
  87037. textureHalfFloatLinearFiltering: boolean;
  87038. /** Defines if rendering to half float textures is supported */
  87039. textureHalfFloatRender: boolean;
  87040. /** Defines if textureLOD shader command is supported */
  87041. textureLOD: boolean;
  87042. /** Defines if draw buffers extension is supported */
  87043. drawBuffersExtension: boolean;
  87044. /** Defines if depth textures are supported */
  87045. depthTextureExtension: boolean;
  87046. /** Defines if float color buffer are supported */
  87047. colorBufferFloat: boolean;
  87048. /** Gets disjoint timer query extension (null if not supported) */
  87049. timerQuery: EXT_disjoint_timer_query;
  87050. /** Defines if timestamp can be used with timer query */
  87051. canUseTimestampForTimerQuery: boolean;
  87052. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  87053. multiview: any;
  87054. /** Function used to let the system compiles shaders in background */
  87055. parallelShaderCompile: {
  87056. COMPLETION_STATUS_KHR: number;
  87057. };
  87058. }
  87059. /** Interface defining initialization parameters for Engine class */
  87060. export interface EngineOptions extends WebGLContextAttributes {
  87061. /**
  87062. * Defines if the engine should no exceed a specified device ratio
  87063. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  87064. */
  87065. limitDeviceRatio?: number;
  87066. /**
  87067. * Defines if webvr should be enabled automatically
  87068. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87069. */
  87070. autoEnableWebVR?: boolean;
  87071. /**
  87072. * Defines if webgl2 should be turned off even if supported
  87073. * @see http://doc.babylonjs.com/features/webgl2
  87074. */
  87075. disableWebGL2Support?: boolean;
  87076. /**
  87077. * Defines if webaudio should be initialized as well
  87078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87079. */
  87080. audioEngine?: boolean;
  87081. /**
  87082. * Defines if animations should run using a deterministic lock step
  87083. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87084. */
  87085. deterministicLockstep?: boolean;
  87086. /** Defines the maximum steps to use with deterministic lock step mode */
  87087. lockstepMaxSteps?: number;
  87088. /**
  87089. * Defines that engine should ignore context lost events
  87090. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  87091. */
  87092. doNotHandleContextLost?: boolean;
  87093. /**
  87094. * Defines that engine should ignore modifying touch action attribute and style
  87095. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  87096. */
  87097. doNotHandleTouchAction?: boolean;
  87098. /**
  87099. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  87100. */
  87101. useHighPrecisionFloats?: boolean;
  87102. }
  87103. /**
  87104. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  87105. */
  87106. export class Engine {
  87107. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  87108. static ExceptionList: ({
  87109. key: string;
  87110. capture: string;
  87111. captureConstraint: number;
  87112. targets: string[];
  87113. } | {
  87114. key: string;
  87115. capture: null;
  87116. captureConstraint: null;
  87117. targets: string[];
  87118. })[];
  87119. /** Gets the list of created engines */
  87120. static readonly Instances: Engine[];
  87121. /**
  87122. * Gets the latest created engine
  87123. */
  87124. static readonly LastCreatedEngine: Nullable<Engine>;
  87125. /**
  87126. * Gets the latest created scene
  87127. */
  87128. static readonly LastCreatedScene: Nullable<Scene>;
  87129. /**
  87130. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  87131. * @param flag defines which part of the materials must be marked as dirty
  87132. * @param predicate defines a predicate used to filter which materials should be affected
  87133. */
  87134. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  87135. /**
  87136. * Hidden
  87137. */
  87138. static _TextureLoaders: IInternalTextureLoader[];
  87139. /** Defines that alpha blending is disabled */
  87140. static readonly ALPHA_DISABLE: number;
  87141. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  87142. static readonly ALPHA_ADD: number;
  87143. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  87144. static readonly ALPHA_COMBINE: number;
  87145. /** Defines that alpha blending to DEST - SRC * DEST */
  87146. static readonly ALPHA_SUBTRACT: number;
  87147. /** Defines that alpha blending to SRC * DEST */
  87148. static readonly ALPHA_MULTIPLY: number;
  87149. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  87150. static readonly ALPHA_MAXIMIZED: number;
  87151. /** Defines that alpha blending to SRC + DEST */
  87152. static readonly ALPHA_ONEONE: number;
  87153. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  87154. static readonly ALPHA_PREMULTIPLIED: number;
  87155. /**
  87156. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  87157. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  87158. */
  87159. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  87160. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  87161. static readonly ALPHA_INTERPOLATE: number;
  87162. /**
  87163. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  87164. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  87165. */
  87166. static readonly ALPHA_SCREENMODE: number;
  87167. /** Defines that the ressource is not delayed*/
  87168. static readonly DELAYLOADSTATE_NONE: number;
  87169. /** Defines that the ressource was successfully delay loaded */
  87170. static readonly DELAYLOADSTATE_LOADED: number;
  87171. /** Defines that the ressource is currently delay loading */
  87172. static readonly DELAYLOADSTATE_LOADING: number;
  87173. /** Defines that the ressource is delayed and has not started loading */
  87174. static readonly DELAYLOADSTATE_NOTLOADED: number;
  87175. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  87176. static readonly NEVER: number;
  87177. /** 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 */
  87178. static readonly ALWAYS: number;
  87179. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  87180. static readonly LESS: number;
  87181. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  87182. static readonly EQUAL: number;
  87183. /** 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 */
  87184. static readonly LEQUAL: number;
  87185. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  87186. static readonly GREATER: number;
  87187. /** 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 */
  87188. static readonly GEQUAL: number;
  87189. /** 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 */
  87190. static readonly NOTEQUAL: number;
  87191. /** Passed to stencilOperation to specify that stencil value must be kept */
  87192. static readonly KEEP: number;
  87193. /** Passed to stencilOperation to specify that stencil value must be replaced */
  87194. static readonly REPLACE: number;
  87195. /** Passed to stencilOperation to specify that stencil value must be incremented */
  87196. static readonly INCR: number;
  87197. /** Passed to stencilOperation to specify that stencil value must be decremented */
  87198. static readonly DECR: number;
  87199. /** Passed to stencilOperation to specify that stencil value must be inverted */
  87200. static readonly INVERT: number;
  87201. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  87202. static readonly INCR_WRAP: number;
  87203. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  87204. static readonly DECR_WRAP: number;
  87205. /** Texture is not repeating outside of 0..1 UVs */
  87206. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  87207. /** Texture is repeating outside of 0..1 UVs */
  87208. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  87209. /** Texture is repeating and mirrored */
  87210. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  87211. /** ALPHA */
  87212. static readonly TEXTUREFORMAT_ALPHA: number;
  87213. /** LUMINANCE */
  87214. static readonly TEXTUREFORMAT_LUMINANCE: number;
  87215. /** LUMINANCE_ALPHA */
  87216. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  87217. /** RGB */
  87218. static readonly TEXTUREFORMAT_RGB: number;
  87219. /** RGBA */
  87220. static readonly TEXTUREFORMAT_RGBA: number;
  87221. /** RED */
  87222. static readonly TEXTUREFORMAT_RED: number;
  87223. /** RED (2nd reference) */
  87224. static readonly TEXTUREFORMAT_R: number;
  87225. /** RG */
  87226. static readonly TEXTUREFORMAT_RG: number;
  87227. /** RED_INTEGER */
  87228. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  87229. /** RED_INTEGER (2nd reference) */
  87230. static readonly TEXTUREFORMAT_R_INTEGER: number;
  87231. /** RG_INTEGER */
  87232. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  87233. /** RGB_INTEGER */
  87234. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  87235. /** RGBA_INTEGER */
  87236. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  87237. /** UNSIGNED_BYTE */
  87238. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  87239. /** UNSIGNED_BYTE (2nd reference) */
  87240. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  87241. /** FLOAT */
  87242. static readonly TEXTURETYPE_FLOAT: number;
  87243. /** HALF_FLOAT */
  87244. static readonly TEXTURETYPE_HALF_FLOAT: number;
  87245. /** BYTE */
  87246. static readonly TEXTURETYPE_BYTE: number;
  87247. /** SHORT */
  87248. static readonly TEXTURETYPE_SHORT: number;
  87249. /** UNSIGNED_SHORT */
  87250. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  87251. /** INT */
  87252. static readonly TEXTURETYPE_INT: number;
  87253. /** UNSIGNED_INT */
  87254. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  87255. /** UNSIGNED_SHORT_4_4_4_4 */
  87256. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  87257. /** UNSIGNED_SHORT_5_5_5_1 */
  87258. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  87259. /** UNSIGNED_SHORT_5_6_5 */
  87260. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  87261. /** UNSIGNED_INT_2_10_10_10_REV */
  87262. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  87263. /** UNSIGNED_INT_24_8 */
  87264. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  87265. /** UNSIGNED_INT_10F_11F_11F_REV */
  87266. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  87267. /** UNSIGNED_INT_5_9_9_9_REV */
  87268. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  87269. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  87270. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  87271. /** nearest is mag = nearest and min = nearest and mip = linear */
  87272. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  87273. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87274. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  87275. /** Trilinear is mag = linear and min = linear and mip = linear */
  87276. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  87277. /** nearest is mag = nearest and min = nearest and mip = linear */
  87278. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  87279. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87280. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  87281. /** Trilinear is mag = linear and min = linear and mip = linear */
  87282. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  87283. /** mag = nearest and min = nearest and mip = nearest */
  87284. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  87285. /** mag = nearest and min = linear and mip = nearest */
  87286. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  87287. /** mag = nearest and min = linear and mip = linear */
  87288. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  87289. /** mag = nearest and min = linear and mip = none */
  87290. static readonly TEXTURE_NEAREST_LINEAR: number;
  87291. /** mag = nearest and min = nearest and mip = none */
  87292. static readonly TEXTURE_NEAREST_NEAREST: number;
  87293. /** mag = linear and min = nearest and mip = nearest */
  87294. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  87295. /** mag = linear and min = nearest and mip = linear */
  87296. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  87297. /** mag = linear and min = linear and mip = none */
  87298. static readonly TEXTURE_LINEAR_LINEAR: number;
  87299. /** mag = linear and min = nearest and mip = none */
  87300. static readonly TEXTURE_LINEAR_NEAREST: number;
  87301. /** Explicit coordinates mode */
  87302. static readonly TEXTURE_EXPLICIT_MODE: number;
  87303. /** Spherical coordinates mode */
  87304. static readonly TEXTURE_SPHERICAL_MODE: number;
  87305. /** Planar coordinates mode */
  87306. static readonly TEXTURE_PLANAR_MODE: number;
  87307. /** Cubic coordinates mode */
  87308. static readonly TEXTURE_CUBIC_MODE: number;
  87309. /** Projection coordinates mode */
  87310. static readonly TEXTURE_PROJECTION_MODE: number;
  87311. /** Skybox coordinates mode */
  87312. static readonly TEXTURE_SKYBOX_MODE: number;
  87313. /** Inverse Cubic coordinates mode */
  87314. static readonly TEXTURE_INVCUBIC_MODE: number;
  87315. /** Equirectangular coordinates mode */
  87316. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87317. /** Equirectangular Fixed coordinates mode */
  87318. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87319. /** Equirectangular Fixed Mirrored coordinates mode */
  87320. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87321. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87322. static readonly SCALEMODE_FLOOR: number;
  87323. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87324. static readonly SCALEMODE_NEAREST: number;
  87325. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87326. static readonly SCALEMODE_CEILING: number;
  87327. /**
  87328. * Returns the current npm package of the sdk
  87329. */
  87330. static readonly NpmPackage: string;
  87331. /**
  87332. * Returns the current version of the framework
  87333. */
  87334. static readonly Version: string;
  87335. /**
  87336. * Returns a string describing the current engine
  87337. */
  87338. readonly description: string;
  87339. /**
  87340. * Gets or sets the epsilon value used by collision engine
  87341. */
  87342. static CollisionsEpsilon: number;
  87343. /**
  87344. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87345. */
  87346. static ShadersRepository: string;
  87347. /**
  87348. * Method called to create the default loading screen.
  87349. * This can be overriden in your own app.
  87350. * @param canvas The rendering canvas element
  87351. * @returns The loading screen
  87352. */
  87353. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87354. /**
  87355. * Method called to create the default rescale post process on each engine.
  87356. */
  87357. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87358. /**
  87359. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87360. */
  87361. forcePOTTextures: boolean;
  87362. /**
  87363. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87364. */
  87365. isFullscreen: boolean;
  87366. /**
  87367. * Gets a boolean indicating if the pointer is currently locked
  87368. */
  87369. isPointerLock: boolean;
  87370. /**
  87371. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87372. */
  87373. cullBackFaces: boolean;
  87374. /**
  87375. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87376. */
  87377. renderEvenInBackground: boolean;
  87378. /**
  87379. * Gets or sets a boolean indicating that cache can be kept between frames
  87380. */
  87381. preventCacheWipeBetweenFrames: boolean;
  87382. /**
  87383. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87384. **/
  87385. enableOfflineSupport: boolean;
  87386. /**
  87387. * 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)
  87388. **/
  87389. disableManifestCheck: boolean;
  87390. /**
  87391. * Gets the list of created scenes
  87392. */
  87393. scenes: Scene[];
  87394. /**
  87395. * Event raised when a new scene is created
  87396. */
  87397. onNewSceneAddedObservable: Observable<Scene>;
  87398. /**
  87399. * Gets the list of created postprocesses
  87400. */
  87401. postProcesses: PostProcess[];
  87402. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87403. validateShaderPrograms: boolean;
  87404. /**
  87405. * Observable event triggered each time the rendering canvas is resized
  87406. */
  87407. onResizeObservable: Observable<Engine>;
  87408. /**
  87409. * Observable event triggered each time the canvas loses focus
  87410. */
  87411. onCanvasBlurObservable: Observable<Engine>;
  87412. /**
  87413. * Observable event triggered each time the canvas gains focus
  87414. */
  87415. onCanvasFocusObservable: Observable<Engine>;
  87416. /**
  87417. * Observable event triggered each time the canvas receives pointerout event
  87418. */
  87419. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87420. /**
  87421. * Observable event triggered before each texture is initialized
  87422. */
  87423. onBeforeTextureInitObservable: Observable<Texture>;
  87424. /**
  87425. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87426. */
  87427. disableUniformBuffers: boolean;
  87428. /** @hidden */
  87429. _uniformBuffers: UniformBuffer[];
  87430. /**
  87431. * Gets a boolean indicating that the engine supports uniform buffers
  87432. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87433. */
  87434. readonly supportsUniformBuffers: boolean;
  87435. /**
  87436. * Observable raised when the engine begins a new frame
  87437. */
  87438. onBeginFrameObservable: Observable<Engine>;
  87439. /**
  87440. * If set, will be used to request the next animation frame for the render loop
  87441. */
  87442. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87443. /**
  87444. * Observable raised when the engine ends the current frame
  87445. */
  87446. onEndFrameObservable: Observable<Engine>;
  87447. /**
  87448. * Observable raised when the engine is about to compile a shader
  87449. */
  87450. onBeforeShaderCompilationObservable: Observable<Engine>;
  87451. /**
  87452. * Observable raised when the engine has jsut compiled a shader
  87453. */
  87454. onAfterShaderCompilationObservable: Observable<Engine>;
  87455. /** @hidden */
  87456. _gl: WebGLRenderingContext;
  87457. private _renderingCanvas;
  87458. private _windowIsBackground;
  87459. private _webGLVersion;
  87460. protected _highPrecisionShadersAllowed: boolean;
  87461. /** @hidden */
  87462. readonly _shouldUseHighPrecisionShader: boolean;
  87463. /**
  87464. * Gets a boolean indicating that only power of 2 textures are supported
  87465. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87466. */
  87467. readonly needPOTTextures: boolean;
  87468. /** @hidden */
  87469. _badOS: boolean;
  87470. /** @hidden */
  87471. _badDesktopOS: boolean;
  87472. /**
  87473. * Gets the audio engine
  87474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87475. * @ignorenaming
  87476. */
  87477. static audioEngine: IAudioEngine;
  87478. /**
  87479. * Default AudioEngine factory responsible of creating the Audio Engine.
  87480. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87481. */
  87482. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87483. /**
  87484. * Default offline support factory responsible of creating a tool used to store data locally.
  87485. * By default, this will create a Database object if the workload has been embedded.
  87486. */
  87487. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87488. private _onFocus;
  87489. private _onBlur;
  87490. private _onCanvasPointerOut;
  87491. private _onCanvasBlur;
  87492. private _onCanvasFocus;
  87493. private _onFullscreenChange;
  87494. private _onPointerLockChange;
  87495. private _hardwareScalingLevel;
  87496. /** @hidden */
  87497. _caps: EngineCapabilities;
  87498. private _pointerLockRequested;
  87499. private _isStencilEnable;
  87500. private _colorWrite;
  87501. private _loadingScreen;
  87502. /** @hidden */
  87503. _drawCalls: PerfCounter;
  87504. private _glVersion;
  87505. private _glRenderer;
  87506. private _glVendor;
  87507. private _videoTextureSupported;
  87508. private _renderingQueueLaunched;
  87509. private _activeRenderLoops;
  87510. private _deterministicLockstep;
  87511. private _lockstepMaxSteps;
  87512. /**
  87513. * Observable signaled when a context lost event is raised
  87514. */
  87515. onContextLostObservable: Observable<Engine>;
  87516. /**
  87517. * Observable signaled when a context restored event is raised
  87518. */
  87519. onContextRestoredObservable: Observable<Engine>;
  87520. private _onContextLost;
  87521. private _onContextRestored;
  87522. private _contextWasLost;
  87523. /** @hidden */
  87524. _doNotHandleContextLost: boolean;
  87525. /**
  87526. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87527. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87528. */
  87529. doNotHandleContextLost: boolean;
  87530. private _performanceMonitor;
  87531. private _fps;
  87532. private _deltaTime;
  87533. /**
  87534. * Turn this value on if you want to pause FPS computation when in background
  87535. */
  87536. disablePerformanceMonitorInBackground: boolean;
  87537. /**
  87538. * Gets the performance monitor attached to this engine
  87539. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87540. */
  87541. readonly performanceMonitor: PerformanceMonitor;
  87542. /**
  87543. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87544. */
  87545. disableVertexArrayObjects: boolean;
  87546. /** @hidden */
  87547. protected _depthCullingState: _DepthCullingState;
  87548. /** @hidden */
  87549. protected _stencilState: _StencilState;
  87550. /** @hidden */
  87551. protected _alphaState: _AlphaState;
  87552. /** @hidden */
  87553. protected _alphaMode: number;
  87554. /** @hidden */
  87555. _internalTexturesCache: InternalTexture[];
  87556. /** @hidden */
  87557. protected _activeChannel: number;
  87558. private _currentTextureChannel;
  87559. /** @hidden */
  87560. protected _boundTexturesCache: {
  87561. [key: string]: Nullable<InternalTexture>;
  87562. };
  87563. /** @hidden */
  87564. protected _currentEffect: Nullable<Effect>;
  87565. /** @hidden */
  87566. protected _currentProgram: Nullable<WebGLProgram>;
  87567. private _compiledEffects;
  87568. private _vertexAttribArraysEnabled;
  87569. /** @hidden */
  87570. protected _cachedViewport: Nullable<Viewport>;
  87571. private _cachedVertexArrayObject;
  87572. /** @hidden */
  87573. protected _cachedVertexBuffers: any;
  87574. /** @hidden */
  87575. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87576. /** @hidden */
  87577. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87578. /** @hidden */
  87579. _currentRenderTarget: Nullable<InternalTexture>;
  87580. private _uintIndicesCurrentlySet;
  87581. private _currentBoundBuffer;
  87582. /** @hidden */
  87583. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87584. private _currentBufferPointers;
  87585. private _currentInstanceLocations;
  87586. private _currentInstanceBuffers;
  87587. private _textureUnits;
  87588. /** @hidden */
  87589. _workingCanvas: Nullable<HTMLCanvasElement>;
  87590. /** @hidden */
  87591. _workingContext: Nullable<CanvasRenderingContext2D>;
  87592. private _rescalePostProcess;
  87593. private _dummyFramebuffer;
  87594. private _externalData;
  87595. /** @hidden */
  87596. _bindedRenderFunction: any;
  87597. private _vaoRecordInProgress;
  87598. private _mustWipeVertexAttributes;
  87599. private _emptyTexture;
  87600. private _emptyCubeTexture;
  87601. private _emptyTexture3D;
  87602. /** @hidden */
  87603. _frameHandler: number;
  87604. private _nextFreeTextureSlots;
  87605. private _maxSimultaneousTextures;
  87606. private _activeRequests;
  87607. private _texturesSupported;
  87608. /** @hidden */
  87609. _textureFormatInUse: Nullable<string>;
  87610. /**
  87611. * Gets the list of texture formats supported
  87612. */
  87613. readonly texturesSupported: Array<string>;
  87614. /**
  87615. * Gets the list of texture formats in use
  87616. */
  87617. readonly textureFormatInUse: Nullable<string>;
  87618. /**
  87619. * Gets the current viewport
  87620. */
  87621. readonly currentViewport: Nullable<Viewport>;
  87622. /**
  87623. * Gets the default empty texture
  87624. */
  87625. readonly emptyTexture: InternalTexture;
  87626. /**
  87627. * Gets the default empty 3D texture
  87628. */
  87629. readonly emptyTexture3D: InternalTexture;
  87630. /**
  87631. * Gets the default empty cube texture
  87632. */
  87633. readonly emptyCubeTexture: InternalTexture;
  87634. /**
  87635. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87636. */
  87637. readonly premultipliedAlpha: boolean;
  87638. /**
  87639. * Creates a new engine
  87640. * @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
  87641. * @param antialias defines enable antialiasing (default: false)
  87642. * @param options defines further options to be sent to the getContext() function
  87643. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87644. */
  87645. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87646. /**
  87647. * Initializes a webVR display and starts listening to display change events
  87648. * The onVRDisplayChangedObservable will be notified upon these changes
  87649. * @returns The onVRDisplayChangedObservable
  87650. */
  87651. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87652. /** @hidden */
  87653. _prepareVRComponent(): void;
  87654. /** @hidden */
  87655. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  87656. /** @hidden */
  87657. _submitVRFrame(): void;
  87658. /**
  87659. * Call this function to leave webVR mode
  87660. * Will do nothing if webVR is not supported or if there is no webVR device
  87661. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87662. */
  87663. disableVR(): void;
  87664. /**
  87665. * Gets a boolean indicating that the system is in VR mode and is presenting
  87666. * @returns true if VR mode is engaged
  87667. */
  87668. isVRPresenting(): boolean;
  87669. /** @hidden */
  87670. _requestVRFrame(): void;
  87671. private _disableTouchAction;
  87672. private _rebuildInternalTextures;
  87673. private _rebuildEffects;
  87674. /**
  87675. * Gets a boolean indicating if all created effects are ready
  87676. * @returns true if all effects are ready
  87677. */
  87678. areAllEffectsReady(): boolean;
  87679. private _rebuildBuffers;
  87680. private _initGLContext;
  87681. /**
  87682. * Gets version of the current webGL context
  87683. */
  87684. readonly webGLVersion: number;
  87685. /**
  87686. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87687. */
  87688. readonly isStencilEnable: boolean;
  87689. /** @hidden */
  87690. _prepareWorkingCanvas(): void;
  87691. /**
  87692. * Reset the texture cache to empty state
  87693. */
  87694. resetTextureCache(): void;
  87695. /**
  87696. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87697. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87698. * @returns true if engine is in deterministic lock step mode
  87699. */
  87700. isDeterministicLockStep(): boolean;
  87701. /**
  87702. * Gets the max steps when engine is running in deterministic lock step
  87703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87704. * @returns the max steps
  87705. */
  87706. getLockstepMaxSteps(): number;
  87707. /**
  87708. * Gets an object containing information about the current webGL context
  87709. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87710. */
  87711. getGlInfo(): {
  87712. vendor: string;
  87713. renderer: string;
  87714. version: string;
  87715. };
  87716. /**
  87717. * Gets current aspect ratio
  87718. * @param camera defines the camera to use to get the aspect ratio
  87719. * @param useScreen defines if screen size must be used (or the current render target if any)
  87720. * @returns a number defining the aspect ratio
  87721. */
  87722. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87723. /**
  87724. * Gets current screen aspect ratio
  87725. * @returns a number defining the aspect ratio
  87726. */
  87727. getScreenAspectRatio(): number;
  87728. /**
  87729. * Gets the current render width
  87730. * @param useScreen defines if screen size must be used (or the current render target if any)
  87731. * @returns a number defining the current render width
  87732. */
  87733. getRenderWidth(useScreen?: boolean): number;
  87734. /**
  87735. * Gets the current render height
  87736. * @param useScreen defines if screen size must be used (or the current render target if any)
  87737. * @returns a number defining the current render height
  87738. */
  87739. getRenderHeight(useScreen?: boolean): number;
  87740. /**
  87741. * Gets the HTML canvas attached with the current webGL context
  87742. * @returns a HTML canvas
  87743. */
  87744. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87745. /**
  87746. * Gets the client rect of the HTML canvas attached with the current webGL context
  87747. * @returns a client rectanglee
  87748. */
  87749. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87750. /**
  87751. * Defines the hardware scaling level.
  87752. * By default the hardware scaling level is computed from the window device ratio.
  87753. * 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.
  87754. * @param level defines the level to use
  87755. */
  87756. setHardwareScalingLevel(level: number): void;
  87757. /**
  87758. * Gets the current hardware scaling level.
  87759. * By default the hardware scaling level is computed from the window device ratio.
  87760. * 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.
  87761. * @returns a number indicating the current hardware scaling level
  87762. */
  87763. getHardwareScalingLevel(): number;
  87764. /**
  87765. * Gets the list of loaded textures
  87766. * @returns an array containing all loaded textures
  87767. */
  87768. getLoadedTexturesCache(): InternalTexture[];
  87769. /**
  87770. * Gets the object containing all engine capabilities
  87771. * @returns the EngineCapabilities object
  87772. */
  87773. getCaps(): EngineCapabilities;
  87774. /**
  87775. * Gets the current depth function
  87776. * @returns a number defining the depth function
  87777. */
  87778. getDepthFunction(): Nullable<number>;
  87779. /**
  87780. * Sets the current depth function
  87781. * @param depthFunc defines the function to use
  87782. */
  87783. setDepthFunction(depthFunc: number): void;
  87784. /**
  87785. * Sets the current depth function to GREATER
  87786. */
  87787. setDepthFunctionToGreater(): void;
  87788. /**
  87789. * Sets the current depth function to GEQUAL
  87790. */
  87791. setDepthFunctionToGreaterOrEqual(): void;
  87792. /**
  87793. * Sets the current depth function to LESS
  87794. */
  87795. setDepthFunctionToLess(): void;
  87796. private _cachedStencilBuffer;
  87797. private _cachedStencilFunction;
  87798. private _cachedStencilMask;
  87799. private _cachedStencilOperationPass;
  87800. private _cachedStencilOperationFail;
  87801. private _cachedStencilOperationDepthFail;
  87802. private _cachedStencilReference;
  87803. /**
  87804. * Caches the the state of the stencil buffer
  87805. */
  87806. cacheStencilState(): void;
  87807. /**
  87808. * Restores the state of the stencil buffer
  87809. */
  87810. restoreStencilState(): void;
  87811. /**
  87812. * Sets the current depth function to LEQUAL
  87813. */
  87814. setDepthFunctionToLessOrEqual(): void;
  87815. /**
  87816. * Gets a boolean indicating if stencil buffer is enabled
  87817. * @returns the current stencil buffer state
  87818. */
  87819. getStencilBuffer(): boolean;
  87820. /**
  87821. * Enable or disable the stencil buffer
  87822. * @param enable defines if the stencil buffer must be enabled or disabled
  87823. */
  87824. setStencilBuffer(enable: boolean): void;
  87825. /**
  87826. * Gets the current stencil mask
  87827. * @returns a number defining the new stencil mask to use
  87828. */
  87829. getStencilMask(): number;
  87830. /**
  87831. * Sets the current stencil mask
  87832. * @param mask defines the new stencil mask to use
  87833. */
  87834. setStencilMask(mask: number): void;
  87835. /**
  87836. * Gets the current stencil function
  87837. * @returns a number defining the stencil function to use
  87838. */
  87839. getStencilFunction(): number;
  87840. /**
  87841. * Gets the current stencil reference value
  87842. * @returns a number defining the stencil reference value to use
  87843. */
  87844. getStencilFunctionReference(): number;
  87845. /**
  87846. * Gets the current stencil mask
  87847. * @returns a number defining the stencil mask to use
  87848. */
  87849. getStencilFunctionMask(): number;
  87850. /**
  87851. * Sets the current stencil function
  87852. * @param stencilFunc defines the new stencil function to use
  87853. */
  87854. setStencilFunction(stencilFunc: number): void;
  87855. /**
  87856. * Sets the current stencil reference
  87857. * @param reference defines the new stencil reference to use
  87858. */
  87859. setStencilFunctionReference(reference: number): void;
  87860. /**
  87861. * Sets the current stencil mask
  87862. * @param mask defines the new stencil mask to use
  87863. */
  87864. setStencilFunctionMask(mask: number): void;
  87865. /**
  87866. * Gets the current stencil operation when stencil fails
  87867. * @returns a number defining stencil operation to use when stencil fails
  87868. */
  87869. getStencilOperationFail(): number;
  87870. /**
  87871. * Gets the current stencil operation when depth fails
  87872. * @returns a number defining stencil operation to use when depth fails
  87873. */
  87874. getStencilOperationDepthFail(): number;
  87875. /**
  87876. * Gets the current stencil operation when stencil passes
  87877. * @returns a number defining stencil operation to use when stencil passes
  87878. */
  87879. getStencilOperationPass(): number;
  87880. /**
  87881. * Sets the stencil operation to use when stencil fails
  87882. * @param operation defines the stencil operation to use when stencil fails
  87883. */
  87884. setStencilOperationFail(operation: number): void;
  87885. /**
  87886. * Sets the stencil operation to use when depth fails
  87887. * @param operation defines the stencil operation to use when depth fails
  87888. */
  87889. setStencilOperationDepthFail(operation: number): void;
  87890. /**
  87891. * Sets the stencil operation to use when stencil passes
  87892. * @param operation defines the stencil operation to use when stencil passes
  87893. */
  87894. setStencilOperationPass(operation: number): void;
  87895. /**
  87896. * Sets a boolean indicating if the dithering state is enabled or disabled
  87897. * @param value defines the dithering state
  87898. */
  87899. setDitheringState(value: boolean): void;
  87900. /**
  87901. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87902. * @param value defines the rasterizer state
  87903. */
  87904. setRasterizerState(value: boolean): void;
  87905. /**
  87906. * stop executing a render loop function and remove it from the execution array
  87907. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87908. */
  87909. stopRenderLoop(renderFunction?: () => void): void;
  87910. /** @hidden */
  87911. _renderLoop(): void;
  87912. /**
  87913. * Register and execute a render loop. The engine can have more than one render function
  87914. * @param renderFunction defines the function to continuously execute
  87915. */
  87916. runRenderLoop(renderFunction: () => void): void;
  87917. /**
  87918. * Toggle full screen mode
  87919. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87920. */
  87921. switchFullscreen(requestPointerLock: boolean): void;
  87922. /**
  87923. * Enters full screen mode
  87924. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87925. */
  87926. enterFullscreen(requestPointerLock: boolean): void;
  87927. /**
  87928. * Exits full screen mode
  87929. */
  87930. exitFullscreen(): void;
  87931. /**
  87932. * Clear the current render buffer or the current render target (if any is set up)
  87933. * @param color defines the color to use
  87934. * @param backBuffer defines if the back buffer must be cleared
  87935. * @param depth defines if the depth buffer must be cleared
  87936. * @param stencil defines if the stencil buffer must be cleared
  87937. */
  87938. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87939. /**
  87940. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87941. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87942. * @param y defines the y-coordinate of the corner of the clear rectangle
  87943. * @param width defines the width of the clear rectangle
  87944. * @param height defines the height of the clear rectangle
  87945. * @param clearColor defines the clear color
  87946. */
  87947. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87948. /**
  87949. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87950. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87951. * @param y defines the y-coordinate of the corner of the clear rectangle
  87952. * @param width defines the width of the clear rectangle
  87953. * @param height defines the height of the clear rectangle
  87954. */
  87955. enableScissor(x: number, y: number, width: number, height: number): void;
  87956. /**
  87957. * Disable previously set scissor test rectangle
  87958. */
  87959. disableScissor(): void;
  87960. private _viewportCached;
  87961. /** @hidden */
  87962. _viewport(x: number, y: number, width: number, height: number): void;
  87963. /**
  87964. * Set the WebGL's viewport
  87965. * @param viewport defines the viewport element to be used
  87966. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87967. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87968. */
  87969. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87970. /**
  87971. * Directly set the WebGL Viewport
  87972. * @param x defines the x coordinate of the viewport (in screen space)
  87973. * @param y defines the y coordinate of the viewport (in screen space)
  87974. * @param width defines the width of the viewport (in screen space)
  87975. * @param height defines the height of the viewport (in screen space)
  87976. * @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
  87977. */
  87978. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87979. /**
  87980. * Begin a new frame
  87981. */
  87982. beginFrame(): void;
  87983. /**
  87984. * Enf the current frame
  87985. */
  87986. endFrame(): void;
  87987. /**
  87988. * Resize the view according to the canvas' size
  87989. */
  87990. resize(): void;
  87991. /**
  87992. * Force a specific size of the canvas
  87993. * @param width defines the new canvas' width
  87994. * @param height defines the new canvas' height
  87995. */
  87996. setSize(width: number, height: number): void;
  87997. /**
  87998. * Binds the frame buffer to the specified texture.
  87999. * @param texture The texture to render to or null for the default canvas
  88000. * @param faceIndex The face of the texture to render to in case of cube texture
  88001. * @param requiredWidth The width of the target to render to
  88002. * @param requiredHeight The height of the target to render to
  88003. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  88004. * @param depthStencilTexture The depth stencil texture to use to render
  88005. * @param lodLevel defines le lod level to bind to the frame buffer
  88006. */
  88007. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  88008. /** @hidden */
  88009. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  88010. /**
  88011. * Unbind the current render target texture from the webGL context
  88012. * @param texture defines the render target texture to unbind
  88013. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  88014. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  88015. */
  88016. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  88017. /**
  88018. * Force the mipmap generation for the given render target texture
  88019. * @param texture defines the render target texture to use
  88020. */
  88021. generateMipMapsForCubemap(texture: InternalTexture): void;
  88022. /**
  88023. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  88024. */
  88025. flushFramebuffer(): void;
  88026. /**
  88027. * Unbind the current render target and bind the default framebuffer
  88028. */
  88029. restoreDefaultFramebuffer(): void;
  88030. /**
  88031. * Create an uniform buffer
  88032. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88033. * @param elements defines the content of the uniform buffer
  88034. * @returns the webGL uniform buffer
  88035. */
  88036. createUniformBuffer(elements: FloatArray): DataBuffer;
  88037. /**
  88038. * Create a dynamic uniform buffer
  88039. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88040. * @param elements defines the content of the uniform buffer
  88041. * @returns the webGL uniform buffer
  88042. */
  88043. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88044. /**
  88045. * Update an existing uniform buffer
  88046. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88047. * @param uniformBuffer defines the target uniform buffer
  88048. * @param elements defines the content to update
  88049. * @param offset defines the offset in the uniform buffer where update should start
  88050. * @param count defines the size of the data to update
  88051. */
  88052. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88053. private _resetVertexBufferBinding;
  88054. /**
  88055. * Creates a vertex buffer
  88056. * @param data the data for the vertex buffer
  88057. * @returns the new WebGL static buffer
  88058. */
  88059. createVertexBuffer(data: DataArray): DataBuffer;
  88060. /**
  88061. * Creates a dynamic vertex buffer
  88062. * @param data the data for the dynamic vertex buffer
  88063. * @returns the new WebGL dynamic buffer
  88064. */
  88065. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  88066. /**
  88067. * Update a dynamic index buffer
  88068. * @param indexBuffer defines the target index buffer
  88069. * @param indices defines the data to update
  88070. * @param offset defines the offset in the target index buffer where update should start
  88071. */
  88072. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  88073. /**
  88074. * Updates a dynamic vertex buffer.
  88075. * @param vertexBuffer the vertex buffer to update
  88076. * @param data the data used to update the vertex buffer
  88077. * @param byteOffset the byte offset of the data
  88078. * @param byteLength the byte length of the data
  88079. */
  88080. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  88081. private _resetIndexBufferBinding;
  88082. /**
  88083. * Creates a new index buffer
  88084. * @param indices defines the content of the index buffer
  88085. * @param updatable defines if the index buffer must be updatable
  88086. * @returns a new webGL buffer
  88087. */
  88088. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  88089. /**
  88090. * Bind a webGL buffer to the webGL context
  88091. * @param buffer defines the buffer to bind
  88092. */
  88093. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  88094. /**
  88095. * Bind an uniform buffer to the current webGL context
  88096. * @param buffer defines the buffer to bind
  88097. */
  88098. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88099. /**
  88100. * Bind a buffer to the current webGL context at a given location
  88101. * @param buffer defines the buffer to bind
  88102. * @param location defines the index where to bind the buffer
  88103. */
  88104. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88105. /**
  88106. * Bind a specific block at a given index in a specific shader program
  88107. * @param pipelineContext defines the pipeline context to use
  88108. * @param blockName defines the block name
  88109. * @param index defines the index where to bind the block
  88110. */
  88111. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88112. private bindIndexBuffer;
  88113. private bindBuffer;
  88114. /**
  88115. * update the bound buffer with the given data
  88116. * @param data defines the data to update
  88117. */
  88118. updateArrayBuffer(data: Float32Array): void;
  88119. private _vertexAttribPointer;
  88120. private _bindIndexBufferWithCache;
  88121. private _bindVertexBuffersAttributes;
  88122. /**
  88123. * Records a vertex array object
  88124. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88125. * @param vertexBuffers defines the list of vertex buffers to store
  88126. * @param indexBuffer defines the index buffer to store
  88127. * @param effect defines the effect to store
  88128. * @returns the new vertex array object
  88129. */
  88130. recordVertexArrayObject(vertexBuffers: {
  88131. [key: string]: VertexBuffer;
  88132. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  88133. /**
  88134. * Bind a specific vertex array object
  88135. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88136. * @param vertexArrayObject defines the vertex array object to bind
  88137. * @param indexBuffer defines the index buffer to bind
  88138. */
  88139. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  88140. /**
  88141. * Bind webGl buffers directly to the webGL context
  88142. * @param vertexBuffer defines the vertex buffer to bind
  88143. * @param indexBuffer defines the index buffer to bind
  88144. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  88145. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  88146. * @param effect defines the effect associated with the vertex buffer
  88147. */
  88148. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  88149. private _unbindVertexArrayObject;
  88150. /**
  88151. * Bind a list of vertex buffers to the webGL context
  88152. * @param vertexBuffers defines the list of vertex buffers to bind
  88153. * @param indexBuffer defines the index buffer to bind
  88154. * @param effect defines the effect associated with the vertex buffers
  88155. */
  88156. bindBuffers(vertexBuffers: {
  88157. [key: string]: Nullable<VertexBuffer>;
  88158. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  88159. /**
  88160. * Unbind all instance attributes
  88161. */
  88162. unbindInstanceAttributes(): void;
  88163. /**
  88164. * Release and free the memory of a vertex array object
  88165. * @param vao defines the vertex array object to delete
  88166. */
  88167. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  88168. /** @hidden */
  88169. _releaseBuffer(buffer: DataBuffer): boolean;
  88170. /**
  88171. * Creates a webGL buffer to use with instanciation
  88172. * @param capacity defines the size of the buffer
  88173. * @returns the webGL buffer
  88174. */
  88175. createInstancesBuffer(capacity: number): DataBuffer;
  88176. /**
  88177. * Delete a webGL buffer used with instanciation
  88178. * @param buffer defines the webGL buffer to delete
  88179. */
  88180. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  88181. /**
  88182. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  88183. * @param instancesBuffer defines the webGL buffer to update and bind
  88184. * @param data defines the data to store in the buffer
  88185. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  88186. */
  88187. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  88188. /**
  88189. * Apply all cached states (depth, culling, stencil and alpha)
  88190. */
  88191. applyStates(): void;
  88192. /**
  88193. * Send a draw order
  88194. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88195. * @param indexStart defines the starting index
  88196. * @param indexCount defines the number of index to draw
  88197. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88198. */
  88199. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  88200. /**
  88201. * Draw a list of points
  88202. * @param verticesStart defines the index of first vertex to draw
  88203. * @param verticesCount defines the count of vertices to draw
  88204. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88205. */
  88206. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88207. /**
  88208. * Draw a list of unindexed primitives
  88209. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88210. * @param verticesStart defines the index of first vertex to draw
  88211. * @param verticesCount defines the count of vertices to draw
  88212. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88213. */
  88214. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88215. /**
  88216. * Draw a list of indexed primitives
  88217. * @param fillMode defines the primitive to use
  88218. * @param indexStart defines the starting index
  88219. * @param indexCount defines the number of index to draw
  88220. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88221. */
  88222. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  88223. /**
  88224. * Draw a list of unindexed primitives
  88225. * @param fillMode defines the primitive to use
  88226. * @param verticesStart defines the index of first vertex to draw
  88227. * @param verticesCount defines the count of vertices to draw
  88228. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88229. */
  88230. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88231. private _drawMode;
  88232. /** @hidden */
  88233. _releaseEffect(effect: Effect): void;
  88234. /** @hidden */
  88235. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  88236. /**
  88237. * Create a new effect (used to store vertex/fragment shaders)
  88238. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  88239. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  88240. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  88241. * @param samplers defines an array of string used to represent textures
  88242. * @param defines defines the string containing the defines to use to compile the shaders
  88243. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  88244. * @param onCompiled defines a function to call when the effect creation is successful
  88245. * @param onError defines a function to call when the effect creation has failed
  88246. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  88247. * @returns the new Effect
  88248. */
  88249. 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;
  88250. private _compileShader;
  88251. private _compileRawShader;
  88252. /**
  88253. * Directly creates a webGL program
  88254. * @param pipelineContext defines the pipeline context to attach to
  88255. * @param vertexCode defines the vertex shader code to use
  88256. * @param fragmentCode defines the fragment shader code to use
  88257. * @param context defines the webGL context to use (if not set, the current one will be used)
  88258. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88259. * @returns the new webGL program
  88260. */
  88261. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88262. /**
  88263. * Creates a webGL program
  88264. * @param pipelineContext defines the pipeline context to attach to
  88265. * @param vertexCode defines the vertex shader code to use
  88266. * @param fragmentCode defines the fragment shader code to use
  88267. * @param defines defines the string containing the defines to use to compile the shaders
  88268. * @param context defines the webGL context to use (if not set, the current one will be used)
  88269. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88270. * @returns the new webGL program
  88271. */
  88272. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88273. /**
  88274. * Creates a new pipeline context
  88275. * @returns the new pipeline
  88276. */
  88277. createPipelineContext(): WebGLPipelineContext;
  88278. private _createShaderProgram;
  88279. private _finalizePipelineContext;
  88280. /** @hidden */
  88281. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88282. /** @hidden */
  88283. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88284. /** @hidden */
  88285. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88286. /**
  88287. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88288. * @param pipelineContext defines the pipeline context to use
  88289. * @param uniformsNames defines the list of uniform names
  88290. * @returns an array of webGL uniform locations
  88291. */
  88292. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88293. /**
  88294. * Gets the lsit of active attributes for a given webGL program
  88295. * @param pipelineContext defines the pipeline context to use
  88296. * @param attributesNames defines the list of attribute names to get
  88297. * @returns an array of indices indicating the offset of each attribute
  88298. */
  88299. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88300. /**
  88301. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88302. * @param effect defines the effect to activate
  88303. */
  88304. enableEffect(effect: Nullable<Effect>): void;
  88305. /**
  88306. * Set the value of an uniform to an array of int32
  88307. * @param uniform defines the webGL uniform location where to store the value
  88308. * @param array defines the array of int32 to store
  88309. */
  88310. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88311. /**
  88312. * Set the value of an uniform to an array of int32 (stored as vec2)
  88313. * @param uniform defines the webGL uniform location where to store the value
  88314. * @param array defines the array of int32 to store
  88315. */
  88316. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88317. /**
  88318. * Set the value of an uniform to an array of int32 (stored as vec3)
  88319. * @param uniform defines the webGL uniform location where to store the value
  88320. * @param array defines the array of int32 to store
  88321. */
  88322. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88323. /**
  88324. * Set the value of an uniform to an array of int32 (stored as vec4)
  88325. * @param uniform defines the webGL uniform location where to store the value
  88326. * @param array defines the array of int32 to store
  88327. */
  88328. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88329. /**
  88330. * Set the value of an uniform to an array of float32
  88331. * @param uniform defines the webGL uniform location where to store the value
  88332. * @param array defines the array of float32 to store
  88333. */
  88334. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88335. /**
  88336. * Set the value of an uniform to an array of float32 (stored as vec2)
  88337. * @param uniform defines the webGL uniform location where to store the value
  88338. * @param array defines the array of float32 to store
  88339. */
  88340. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88341. /**
  88342. * Set the value of an uniform to an array of float32 (stored as vec3)
  88343. * @param uniform defines the webGL uniform location where to store the value
  88344. * @param array defines the array of float32 to store
  88345. */
  88346. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88347. /**
  88348. * Set the value of an uniform to an array of float32 (stored as vec4)
  88349. * @param uniform defines the webGL uniform location where to store the value
  88350. * @param array defines the array of float32 to store
  88351. */
  88352. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88353. /**
  88354. * Set the value of an uniform to an array of number
  88355. * @param uniform defines the webGL uniform location where to store the value
  88356. * @param array defines the array of number to store
  88357. */
  88358. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88359. /**
  88360. * Set the value of an uniform to an array of number (stored as vec2)
  88361. * @param uniform defines the webGL uniform location where to store the value
  88362. * @param array defines the array of number to store
  88363. */
  88364. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88365. /**
  88366. * Set the value of an uniform to an array of number (stored as vec3)
  88367. * @param uniform defines the webGL uniform location where to store the value
  88368. * @param array defines the array of number to store
  88369. */
  88370. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88371. /**
  88372. * Set the value of an uniform to an array of number (stored as vec4)
  88373. * @param uniform defines the webGL uniform location where to store the value
  88374. * @param array defines the array of number to store
  88375. */
  88376. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88377. /**
  88378. * Set the value of an uniform to an array of float32 (stored as matrices)
  88379. * @param uniform defines the webGL uniform location where to store the value
  88380. * @param matrices defines the array of float32 to store
  88381. */
  88382. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88383. /**
  88384. * Set the value of an uniform to a matrix
  88385. * @param uniform defines the webGL uniform location where to store the value
  88386. * @param matrix defines the matrix to store
  88387. */
  88388. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88389. /**
  88390. * Set the value of an uniform to a matrix (3x3)
  88391. * @param uniform defines the webGL uniform location where to store the value
  88392. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88393. */
  88394. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88395. /**
  88396. * Set the value of an uniform to a matrix (2x2)
  88397. * @param uniform defines the webGL uniform location where to store the value
  88398. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88399. */
  88400. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88401. /**
  88402. * Set the value of an uniform to a number (int)
  88403. * @param uniform defines the webGL uniform location where to store the value
  88404. * @param value defines the int number to store
  88405. */
  88406. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88407. /**
  88408. * Set the value of an uniform to a number (float)
  88409. * @param uniform defines the webGL uniform location where to store the value
  88410. * @param value defines the float number to store
  88411. */
  88412. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88413. /**
  88414. * Set the value of an uniform to a vec2
  88415. * @param uniform defines the webGL uniform location where to store the value
  88416. * @param x defines the 1st component of the value
  88417. * @param y defines the 2nd component of the value
  88418. */
  88419. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88420. /**
  88421. * Set the value of an uniform to a vec3
  88422. * @param uniform defines the webGL uniform location where to store the value
  88423. * @param x defines the 1st component of the value
  88424. * @param y defines the 2nd component of the value
  88425. * @param z defines the 3rd component of the value
  88426. */
  88427. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88428. /**
  88429. * Set the value of an uniform to a boolean
  88430. * @param uniform defines the webGL uniform location where to store the value
  88431. * @param bool defines the boolean to store
  88432. */
  88433. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88434. /**
  88435. * Set the value of an uniform to a vec4
  88436. * @param uniform defines the webGL uniform location where to store the value
  88437. * @param x defines the 1st component of the value
  88438. * @param y defines the 2nd component of the value
  88439. * @param z defines the 3rd component of the value
  88440. * @param w defines the 4th component of the value
  88441. */
  88442. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88443. /**
  88444. * Set the value of an uniform to a Color3
  88445. * @param uniform defines the webGL uniform location where to store the value
  88446. * @param color3 defines the color to store
  88447. */
  88448. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88449. /**
  88450. * Set the value of an uniform to a Color3 and an alpha value
  88451. * @param uniform defines the webGL uniform location where to store the value
  88452. * @param color3 defines the color to store
  88453. * @param alpha defines the alpha component to store
  88454. */
  88455. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88456. /**
  88457. * Sets a Color4 on a uniform variable
  88458. * @param uniform defines the uniform location
  88459. * @param color4 defines the value to be set
  88460. */
  88461. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88462. /**
  88463. * Set various states to the webGL context
  88464. * @param culling defines backface culling state
  88465. * @param zOffset defines the value to apply to zOffset (0 by default)
  88466. * @param force defines if states must be applied even if cache is up to date
  88467. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88468. */
  88469. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88470. /**
  88471. * Set the z offset to apply to current rendering
  88472. * @param value defines the offset to apply
  88473. */
  88474. setZOffset(value: number): void;
  88475. /**
  88476. * Gets the current value of the zOffset
  88477. * @returns the current zOffset state
  88478. */
  88479. getZOffset(): number;
  88480. /**
  88481. * Enable or disable depth buffering
  88482. * @param enable defines the state to set
  88483. */
  88484. setDepthBuffer(enable: boolean): void;
  88485. /**
  88486. * Gets a boolean indicating if depth writing is enabled
  88487. * @returns the current depth writing state
  88488. */
  88489. getDepthWrite(): boolean;
  88490. /**
  88491. * Enable or disable depth writing
  88492. * @param enable defines the state to set
  88493. */
  88494. setDepthWrite(enable: boolean): void;
  88495. /**
  88496. * Enable or disable color writing
  88497. * @param enable defines the state to set
  88498. */
  88499. setColorWrite(enable: boolean): void;
  88500. /**
  88501. * Gets a boolean indicating if color writing is enabled
  88502. * @returns the current color writing state
  88503. */
  88504. getColorWrite(): boolean;
  88505. /**
  88506. * Sets alpha constants used by some alpha blending modes
  88507. * @param r defines the red component
  88508. * @param g defines the green component
  88509. * @param b defines the blue component
  88510. * @param a defines the alpha component
  88511. */
  88512. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88513. /**
  88514. * Sets the current alpha mode
  88515. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88516. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88517. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88518. */
  88519. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88520. /**
  88521. * Gets the current alpha mode
  88522. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88523. * @returns the current alpha mode
  88524. */
  88525. getAlphaMode(): number;
  88526. /**
  88527. * Clears the list of texture accessible through engine.
  88528. * This can help preventing texture load conflict due to name collision.
  88529. */
  88530. clearInternalTexturesCache(): void;
  88531. /**
  88532. * Force the entire cache to be cleared
  88533. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88534. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88535. */
  88536. wipeCaches(bruteForce?: boolean): void;
  88537. /**
  88538. * Set the compressed texture format to use, based on the formats you have, and the formats
  88539. * supported by the hardware / browser.
  88540. *
  88541. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88542. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88543. * to API arguments needed to compressed textures. This puts the burden on the container
  88544. * generator to house the arcane code for determining these for current & future formats.
  88545. *
  88546. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88547. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88548. *
  88549. * Note: The result of this call is not taken into account when a texture is base64.
  88550. *
  88551. * @param formatsAvailable defines the list of those format families you have created
  88552. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88553. *
  88554. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88555. * @returns The extension selected.
  88556. */
  88557. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88558. /** @hidden */
  88559. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88560. min: number;
  88561. mag: number;
  88562. };
  88563. /** @hidden */
  88564. _createTexture(): WebGLTexture;
  88565. /**
  88566. * Usually called from Texture.ts.
  88567. * Passed information to create a WebGLTexture
  88568. * @param urlArg defines a value which contains one of the following:
  88569. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88570. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88571. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88572. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88573. * @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)
  88574. * @param scene needed for loading to the correct scene
  88575. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88576. * @param onLoad optional callback to be called upon successful completion
  88577. * @param onError optional callback to be called upon failure
  88578. * @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
  88579. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88580. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88581. * @param forcedExtension defines the extension to use to pick the right loader
  88582. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88583. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88584. */
  88585. 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;
  88586. private _rescaleTexture;
  88587. private _unpackFlipYCached;
  88588. /**
  88589. * In case you are sharing the context with other applications, it might
  88590. * be interested to not cache the unpack flip y state to ensure a consistent
  88591. * value would be set.
  88592. */
  88593. enableUnpackFlipYCached: boolean;
  88594. /** @hidden */
  88595. _unpackFlipY(value: boolean): void;
  88596. /** @hidden */
  88597. _getUnpackAlignement(): number;
  88598. /**
  88599. * Creates a dynamic texture
  88600. * @param width defines the width of the texture
  88601. * @param height defines the height of the texture
  88602. * @param generateMipMaps defines if the engine should generate the mip levels
  88603. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88604. * @returns the dynamic texture inside an InternalTexture
  88605. */
  88606. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88607. /**
  88608. * Update the sampling mode of a given texture
  88609. * @param samplingMode defines the required sampling mode
  88610. * @param texture defines the texture to update
  88611. */
  88612. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88613. /**
  88614. * Update the content of a dynamic texture
  88615. * @param texture defines the texture to update
  88616. * @param canvas defines the canvas containing the source
  88617. * @param invertY defines if data must be stored with Y axis inverted
  88618. * @param premulAlpha defines if alpha is stored as premultiplied
  88619. * @param format defines the format of the data
  88620. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88621. */
  88622. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88623. /**
  88624. * Update a video texture
  88625. * @param texture defines the texture to update
  88626. * @param video defines the video element to use
  88627. * @param invertY defines if data must be stored with Y axis inverted
  88628. */
  88629. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88630. /**
  88631. * Updates a depth texture Comparison Mode and Function.
  88632. * If the comparison Function is equal to 0, the mode will be set to none.
  88633. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88634. * @param texture The texture to set the comparison function for
  88635. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88636. */
  88637. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88638. /** @hidden */
  88639. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88640. width: number;
  88641. height: number;
  88642. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88643. /**
  88644. * Creates a depth stencil texture.
  88645. * This is only available in WebGL 2 or with the depth texture extension available.
  88646. * @param size The size of face edge in the texture.
  88647. * @param options The options defining the texture.
  88648. * @returns The texture
  88649. */
  88650. createDepthStencilTexture(size: number | {
  88651. width: number;
  88652. height: number;
  88653. }, options: DepthTextureCreationOptions): InternalTexture;
  88654. /**
  88655. * Creates a depth stencil texture.
  88656. * This is only available in WebGL 2 or with the depth texture extension available.
  88657. * @param size The size of face edge in the texture.
  88658. * @param options The options defining the texture.
  88659. * @returns The texture
  88660. */
  88661. private _createDepthStencilTexture;
  88662. /**
  88663. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88664. * @param renderTarget The render target to set the frame buffer for
  88665. */
  88666. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88667. /**
  88668. * Creates a new render target texture
  88669. * @param size defines the size of the texture
  88670. * @param options defines the options used to create the texture
  88671. * @returns a new render target texture stored in an InternalTexture
  88672. */
  88673. createRenderTargetTexture(size: number | {
  88674. width: number;
  88675. height: number;
  88676. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88677. /** @hidden */
  88678. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88679. /**
  88680. * Updates the sample count of a render target texture
  88681. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88682. * @param texture defines the texture to update
  88683. * @param samples defines the sample count to set
  88684. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88685. */
  88686. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88687. /** @hidden */
  88688. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88689. /** @hidden */
  88690. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88691. /** @hidden */
  88692. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88693. /** @hidden */
  88694. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88695. /**
  88696. * @hidden
  88697. */
  88698. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88699. private _prepareWebGLTextureContinuation;
  88700. private _prepareWebGLTexture;
  88701. /** @hidden */
  88702. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88703. /** @hidden */
  88704. _releaseFramebufferObjects(texture: InternalTexture): void;
  88705. /** @hidden */
  88706. _releaseTexture(texture: InternalTexture): void;
  88707. private setProgram;
  88708. private _boundUniforms;
  88709. /**
  88710. * Binds an effect to the webGL context
  88711. * @param effect defines the effect to bind
  88712. */
  88713. bindSamplers(effect: Effect): void;
  88714. private _activateCurrentTexture;
  88715. /** @hidden */
  88716. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88717. /** @hidden */
  88718. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88719. /**
  88720. * Sets a texture to the webGL context from a postprocess
  88721. * @param channel defines the channel to use
  88722. * @param postProcess defines the source postprocess
  88723. */
  88724. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88725. /**
  88726. * Binds the output of the passed in post process to the texture channel specified
  88727. * @param channel The channel the texture should be bound to
  88728. * @param postProcess The post process which's output should be bound
  88729. */
  88730. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88731. /**
  88732. * Unbind all textures from the webGL context
  88733. */
  88734. unbindAllTextures(): void;
  88735. /**
  88736. * Sets a texture to the according uniform.
  88737. * @param channel The texture channel
  88738. * @param uniform The uniform to set
  88739. * @param texture The texture to apply
  88740. */
  88741. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88742. /**
  88743. * Sets a depth stencil texture from a render target to the according uniform.
  88744. * @param channel The texture channel
  88745. * @param uniform The uniform to set
  88746. * @param texture The render target texture containing the depth stencil texture to apply
  88747. */
  88748. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88749. private _bindSamplerUniformToChannel;
  88750. private _getTextureWrapMode;
  88751. private _setTexture;
  88752. /**
  88753. * Sets an array of texture to the webGL context
  88754. * @param channel defines the channel where the texture array must be set
  88755. * @param uniform defines the associated uniform location
  88756. * @param textures defines the array of textures to bind
  88757. */
  88758. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88759. /** @hidden */
  88760. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88761. private _setTextureParameterFloat;
  88762. private _setTextureParameterInteger;
  88763. /**
  88764. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88765. * @param x defines the x coordinate of the rectangle where pixels must be read
  88766. * @param y defines the y coordinate of the rectangle where pixels must be read
  88767. * @param width defines the width of the rectangle where pixels must be read
  88768. * @param height defines the height of the rectangle where pixels must be read
  88769. * @returns a Uint8Array containing RGBA colors
  88770. */
  88771. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88772. /**
  88773. * Add an externaly attached data from its key.
  88774. * This method call will fail and return false, if such key already exists.
  88775. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88776. * @param key the unique key that identifies the data
  88777. * @param data the data object to associate to the key for this Engine instance
  88778. * @return true if no such key were already present and the data was added successfully, false otherwise
  88779. */
  88780. addExternalData<T>(key: string, data: T): boolean;
  88781. /**
  88782. * Get an externaly attached data from its key
  88783. * @param key the unique key that identifies the data
  88784. * @return the associated data, if present (can be null), or undefined if not present
  88785. */
  88786. getExternalData<T>(key: string): T;
  88787. /**
  88788. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88789. * @param key the unique key that identifies the data
  88790. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88791. * @return the associated data, can be null if the factory returned null.
  88792. */
  88793. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88794. /**
  88795. * Remove an externaly attached data from the Engine instance
  88796. * @param key the unique key that identifies the data
  88797. * @return true if the data was successfully removed, false if it doesn't exist
  88798. */
  88799. removeExternalData(key: string): boolean;
  88800. /**
  88801. * Unbind all vertex attributes from the webGL context
  88802. */
  88803. unbindAllAttributes(): void;
  88804. /**
  88805. * 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
  88806. */
  88807. releaseEffects(): void;
  88808. /**
  88809. * Dispose and release all associated resources
  88810. */
  88811. dispose(): void;
  88812. /**
  88813. * Display the loading screen
  88814. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88815. */
  88816. displayLoadingUI(): void;
  88817. /**
  88818. * Hide the loading screen
  88819. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88820. */
  88821. hideLoadingUI(): void;
  88822. /**
  88823. * Gets the current loading screen object
  88824. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88825. */
  88826. /**
  88827. * Sets the current loading screen object
  88828. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88829. */
  88830. loadingScreen: ILoadingScreen;
  88831. /**
  88832. * Sets the current loading screen text
  88833. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88834. */
  88835. loadingUIText: string;
  88836. /**
  88837. * Sets the current loading screen background color
  88838. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88839. */
  88840. loadingUIBackgroundColor: string;
  88841. /**
  88842. * Attach a new callback raised when context lost event is fired
  88843. * @param callback defines the callback to call
  88844. */
  88845. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88846. /**
  88847. * Attach a new callback raised when context restored event is fired
  88848. * @param callback defines the callback to call
  88849. */
  88850. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88851. /**
  88852. * Gets the source code of the vertex shader associated with a specific webGL program
  88853. * @param program defines the program to use
  88854. * @returns a string containing the source code of the vertex shader associated with the program
  88855. */
  88856. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88857. /**
  88858. * Gets the source code of the fragment shader associated with a specific webGL program
  88859. * @param program defines the program to use
  88860. * @returns a string containing the source code of the fragment shader associated with the program
  88861. */
  88862. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88863. /**
  88864. * Get the current error code of the webGL context
  88865. * @returns the error code
  88866. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88867. */
  88868. getError(): number;
  88869. /**
  88870. * Gets the current framerate
  88871. * @returns a number representing the framerate
  88872. */
  88873. getFps(): number;
  88874. /**
  88875. * Gets the time spent between current and previous frame
  88876. * @returns a number representing the delta time in ms
  88877. */
  88878. getDeltaTime(): number;
  88879. private _measureFps;
  88880. /** @hidden */
  88881. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88882. private _canRenderToFloatFramebuffer;
  88883. private _canRenderToHalfFloatFramebuffer;
  88884. private _canRenderToFramebuffer;
  88885. /** @hidden */
  88886. _getWebGLTextureType(type: number): number;
  88887. /** @hidden */
  88888. _getInternalFormat(format: number): number;
  88889. /** @hidden */
  88890. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88891. /** @hidden */
  88892. _getRGBAMultiSampleBufferFormat(type: number): number;
  88893. /** @hidden */
  88894. _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;
  88895. /** @hidden */
  88896. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88897. /**
  88898. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88899. * @returns true if the engine can be created
  88900. * @ignorenaming
  88901. */
  88902. static isSupported(): boolean;
  88903. }
  88904. }
  88905. declare module BABYLON {
  88906. /**
  88907. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88908. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88909. */
  88910. export class EffectFallbacks {
  88911. private _defines;
  88912. private _currentRank;
  88913. private _maxRank;
  88914. private _mesh;
  88915. /**
  88916. * Removes the fallback from the bound mesh.
  88917. */
  88918. unBindMesh(): void;
  88919. /**
  88920. * Adds a fallback on the specified property.
  88921. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88922. * @param define The name of the define in the shader
  88923. */
  88924. addFallback(rank: number, define: string): void;
  88925. /**
  88926. * Sets the mesh to use CPU skinning when needing to fallback.
  88927. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88928. * @param mesh The mesh to use the fallbacks.
  88929. */
  88930. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88931. /**
  88932. * Checks to see if more fallbacks are still availible.
  88933. */
  88934. readonly isMoreFallbacks: boolean;
  88935. /**
  88936. * Removes the defines that shoould be removed when falling back.
  88937. * @param currentDefines defines the current define statements for the shader.
  88938. * @param effect defines the current effect we try to compile
  88939. * @returns The resulting defines with defines of the current rank removed.
  88940. */
  88941. reduce(currentDefines: string, effect: Effect): string;
  88942. }
  88943. /**
  88944. * Options to be used when creating an effect.
  88945. */
  88946. export class EffectCreationOptions {
  88947. /**
  88948. * Atrributes that will be used in the shader.
  88949. */
  88950. attributes: string[];
  88951. /**
  88952. * Uniform varible names that will be set in the shader.
  88953. */
  88954. uniformsNames: string[];
  88955. /**
  88956. * Uniform buffer varible names that will be set in the shader.
  88957. */
  88958. uniformBuffersNames: string[];
  88959. /**
  88960. * Sampler texture variable names that will be set in the shader.
  88961. */
  88962. samplers: string[];
  88963. /**
  88964. * Define statements that will be set in the shader.
  88965. */
  88966. defines: any;
  88967. /**
  88968. * Possible fallbacks for this effect to improve performance when needed.
  88969. */
  88970. fallbacks: Nullable<EffectFallbacks>;
  88971. /**
  88972. * Callback that will be called when the shader is compiled.
  88973. */
  88974. onCompiled: Nullable<(effect: Effect) => void>;
  88975. /**
  88976. * Callback that will be called if an error occurs during shader compilation.
  88977. */
  88978. onError: Nullable<(effect: Effect, errors: string) => void>;
  88979. /**
  88980. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88981. */
  88982. indexParameters: any;
  88983. /**
  88984. * Max number of lights that can be used in the shader.
  88985. */
  88986. maxSimultaneousLights: number;
  88987. /**
  88988. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88989. */
  88990. transformFeedbackVaryings: Nullable<string[]>;
  88991. }
  88992. /**
  88993. * Effect containing vertex and fragment shader that can be executed on an object.
  88994. */
  88995. export class Effect implements IDisposable {
  88996. /**
  88997. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88998. */
  88999. static ShadersRepository: string;
  89000. /**
  89001. * Name of the effect.
  89002. */
  89003. name: any;
  89004. /**
  89005. * String container all the define statements that should be set on the shader.
  89006. */
  89007. defines: string;
  89008. /**
  89009. * Callback that will be called when the shader is compiled.
  89010. */
  89011. onCompiled: Nullable<(effect: Effect) => void>;
  89012. /**
  89013. * Callback that will be called if an error occurs during shader compilation.
  89014. */
  89015. onError: Nullable<(effect: Effect, errors: string) => void>;
  89016. /**
  89017. * Callback that will be called when effect is bound.
  89018. */
  89019. onBind: Nullable<(effect: Effect) => void>;
  89020. /**
  89021. * Unique ID of the effect.
  89022. */
  89023. uniqueId: number;
  89024. /**
  89025. * Observable that will be called when the shader is compiled.
  89026. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  89027. */
  89028. onCompileObservable: Observable<Effect>;
  89029. /**
  89030. * Observable that will be called if an error occurs during shader compilation.
  89031. */
  89032. onErrorObservable: Observable<Effect>;
  89033. /** @hidden */
  89034. _onBindObservable: Nullable<Observable<Effect>>;
  89035. /**
  89036. * Observable that will be called when effect is bound.
  89037. */
  89038. readonly onBindObservable: Observable<Effect>;
  89039. /** @hidden */
  89040. _bonesComputationForcedToCPU: boolean;
  89041. private static _uniqueIdSeed;
  89042. private _engine;
  89043. private _uniformBuffersNames;
  89044. private _uniformsNames;
  89045. private _samplerList;
  89046. private _samplers;
  89047. private _isReady;
  89048. private _compilationError;
  89049. private _attributesNames;
  89050. private _attributes;
  89051. private _uniforms;
  89052. /**
  89053. * Key for the effect.
  89054. * @hidden
  89055. */
  89056. _key: string;
  89057. private _indexParameters;
  89058. private _fallbacks;
  89059. private _vertexSourceCode;
  89060. private _fragmentSourceCode;
  89061. private _vertexSourceCodeOverride;
  89062. private _fragmentSourceCodeOverride;
  89063. private _transformFeedbackVaryings;
  89064. /**
  89065. * Compiled shader to webGL program.
  89066. * @hidden
  89067. */
  89068. _pipelineContext: IPipelineContext;
  89069. private _valueCache;
  89070. private static _baseCache;
  89071. /**
  89072. * Instantiates an effect.
  89073. * An effect can be used to create/manage/execute vertex and fragment shaders.
  89074. * @param baseName Name of the effect.
  89075. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  89076. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  89077. * @param samplers List of sampler variables that will be passed to the shader.
  89078. * @param engine Engine to be used to render the effect
  89079. * @param defines Define statements to be added to the shader.
  89080. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  89081. * @param onCompiled Callback that will be called when the shader is compiled.
  89082. * @param onError Callback that will be called if an error occurs during shader compilation.
  89083. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89084. */
  89085. 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);
  89086. /**
  89087. * Unique key for this effect
  89088. */
  89089. readonly key: string;
  89090. /**
  89091. * If the effect has been compiled and prepared.
  89092. * @returns if the effect is compiled and prepared.
  89093. */
  89094. isReady(): boolean;
  89095. /**
  89096. * The engine the effect was initialized with.
  89097. * @returns the engine.
  89098. */
  89099. getEngine(): Engine;
  89100. /**
  89101. * The pipeline context for this effect
  89102. * @returns the associated pipeline context
  89103. */
  89104. getPipelineContext(): IPipelineContext;
  89105. /**
  89106. * The set of names of attribute variables for the shader.
  89107. * @returns An array of attribute names.
  89108. */
  89109. getAttributesNames(): string[];
  89110. /**
  89111. * Returns the attribute at the given index.
  89112. * @param index The index of the attribute.
  89113. * @returns The location of the attribute.
  89114. */
  89115. getAttributeLocation(index: number): number;
  89116. /**
  89117. * Returns the attribute based on the name of the variable.
  89118. * @param name of the attribute to look up.
  89119. * @returns the attribute location.
  89120. */
  89121. getAttributeLocationByName(name: string): number;
  89122. /**
  89123. * The number of attributes.
  89124. * @returns the numnber of attributes.
  89125. */
  89126. getAttributesCount(): number;
  89127. /**
  89128. * Gets the index of a uniform variable.
  89129. * @param uniformName of the uniform to look up.
  89130. * @returns the index.
  89131. */
  89132. getUniformIndex(uniformName: string): number;
  89133. /**
  89134. * Returns the attribute based on the name of the variable.
  89135. * @param uniformName of the uniform to look up.
  89136. * @returns the location of the uniform.
  89137. */
  89138. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  89139. /**
  89140. * Returns an array of sampler variable names
  89141. * @returns The array of sampler variable neames.
  89142. */
  89143. getSamplers(): string[];
  89144. /**
  89145. * The error from the last compilation.
  89146. * @returns the error string.
  89147. */
  89148. getCompilationError(): string;
  89149. /**
  89150. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  89151. * @param func The callback to be used.
  89152. */
  89153. executeWhenCompiled(func: (effect: Effect) => void): void;
  89154. private _checkIsReady;
  89155. /** @hidden */
  89156. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  89157. /** @hidden */
  89158. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  89159. /** @hidden */
  89160. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  89161. private _processShaderConversion;
  89162. private _processIncludes;
  89163. private _processPrecision;
  89164. /**
  89165. * Recompiles the webGL program
  89166. * @param vertexSourceCode The source code for the vertex shader.
  89167. * @param fragmentSourceCode The source code for the fragment shader.
  89168. * @param onCompiled Callback called when completed.
  89169. * @param onError Callback called on error.
  89170. * @hidden
  89171. */
  89172. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  89173. /**
  89174. * Prepares the effect
  89175. * @hidden
  89176. */
  89177. _prepareEffect(): void;
  89178. /**
  89179. * Checks if the effect is supported. (Must be called after compilation)
  89180. */
  89181. readonly isSupported: boolean;
  89182. /**
  89183. * Binds a texture to the engine to be used as output of the shader.
  89184. * @param channel Name of the output variable.
  89185. * @param texture Texture to bind.
  89186. * @hidden
  89187. */
  89188. _bindTexture(channel: string, texture: InternalTexture): void;
  89189. /**
  89190. * Sets a texture on the engine to be used in the shader.
  89191. * @param channel Name of the sampler variable.
  89192. * @param texture Texture to set.
  89193. */
  89194. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  89195. /**
  89196. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  89197. * @param channel Name of the sampler variable.
  89198. * @param texture Texture to set.
  89199. */
  89200. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  89201. /**
  89202. * Sets an array of textures on the engine to be used in the shader.
  89203. * @param channel Name of the variable.
  89204. * @param textures Textures to set.
  89205. */
  89206. setTextureArray(channel: string, textures: BaseTexture[]): void;
  89207. /**
  89208. * 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)
  89209. * @param channel Name of the sampler variable.
  89210. * @param postProcess Post process to get the input texture from.
  89211. */
  89212. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  89213. /**
  89214. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  89215. * 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)
  89216. * @param channel Name of the sampler variable.
  89217. * @param postProcess Post process to get the output texture from.
  89218. */
  89219. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  89220. /** @hidden */
  89221. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  89222. /** @hidden */
  89223. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  89224. /** @hidden */
  89225. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  89226. /** @hidden */
  89227. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  89228. /**
  89229. * Binds a buffer to a uniform.
  89230. * @param buffer Buffer to bind.
  89231. * @param name Name of the uniform variable to bind to.
  89232. */
  89233. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  89234. /**
  89235. * Binds block to a uniform.
  89236. * @param blockName Name of the block to bind.
  89237. * @param index Index to bind.
  89238. */
  89239. bindUniformBlock(blockName: string, index: number): void;
  89240. /**
  89241. * Sets an interger value on a uniform variable.
  89242. * @param uniformName Name of the variable.
  89243. * @param value Value to be set.
  89244. * @returns this effect.
  89245. */
  89246. setInt(uniformName: string, value: number): Effect;
  89247. /**
  89248. * Sets an int array on a uniform variable.
  89249. * @param uniformName Name of the variable.
  89250. * @param array array to be set.
  89251. * @returns this effect.
  89252. */
  89253. setIntArray(uniformName: string, array: Int32Array): Effect;
  89254. /**
  89255. * 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)
  89256. * @param uniformName Name of the variable.
  89257. * @param array array to be set.
  89258. * @returns this effect.
  89259. */
  89260. setIntArray2(uniformName: string, array: Int32Array): Effect;
  89261. /**
  89262. * 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)
  89263. * @param uniformName Name of the variable.
  89264. * @param array array to be set.
  89265. * @returns this effect.
  89266. */
  89267. setIntArray3(uniformName: string, array: Int32Array): Effect;
  89268. /**
  89269. * 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)
  89270. * @param uniformName Name of the variable.
  89271. * @param array array to be set.
  89272. * @returns this effect.
  89273. */
  89274. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89275. /**
  89276. * Sets an float array on a uniform variable.
  89277. * @param uniformName Name of the variable.
  89278. * @param array array to be set.
  89279. * @returns this effect.
  89280. */
  89281. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89282. /**
  89283. * 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)
  89284. * @param uniformName Name of the variable.
  89285. * @param array array to be set.
  89286. * @returns this effect.
  89287. */
  89288. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89289. /**
  89290. * 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)
  89291. * @param uniformName Name of the variable.
  89292. * @param array array to be set.
  89293. * @returns this effect.
  89294. */
  89295. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89296. /**
  89297. * 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)
  89298. * @param uniformName Name of the variable.
  89299. * @param array array to be set.
  89300. * @returns this effect.
  89301. */
  89302. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89303. /**
  89304. * Sets an array on a uniform variable.
  89305. * @param uniformName Name of the variable.
  89306. * @param array array to be set.
  89307. * @returns this effect.
  89308. */
  89309. setArray(uniformName: string, array: number[]): Effect;
  89310. /**
  89311. * 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)
  89312. * @param uniformName Name of the variable.
  89313. * @param array array to be set.
  89314. * @returns this effect.
  89315. */
  89316. setArray2(uniformName: string, array: number[]): Effect;
  89317. /**
  89318. * 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)
  89319. * @param uniformName Name of the variable.
  89320. * @param array array to be set.
  89321. * @returns this effect.
  89322. */
  89323. setArray3(uniformName: string, array: number[]): Effect;
  89324. /**
  89325. * 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)
  89326. * @param uniformName Name of the variable.
  89327. * @param array array to be set.
  89328. * @returns this effect.
  89329. */
  89330. setArray4(uniformName: string, array: number[]): Effect;
  89331. /**
  89332. * Sets matrices on a uniform variable.
  89333. * @param uniformName Name of the variable.
  89334. * @param matrices matrices to be set.
  89335. * @returns this effect.
  89336. */
  89337. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89338. /**
  89339. * Sets matrix on a uniform variable.
  89340. * @param uniformName Name of the variable.
  89341. * @param matrix matrix to be set.
  89342. * @returns this effect.
  89343. */
  89344. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89345. /**
  89346. * 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)
  89347. * @param uniformName Name of the variable.
  89348. * @param matrix matrix to be set.
  89349. * @returns this effect.
  89350. */
  89351. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89352. /**
  89353. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89354. * @param uniformName Name of the variable.
  89355. * @param matrix matrix to be set.
  89356. * @returns this effect.
  89357. */
  89358. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89359. /**
  89360. * Sets a float on a uniform variable.
  89361. * @param uniformName Name of the variable.
  89362. * @param value value to be set.
  89363. * @returns this effect.
  89364. */
  89365. setFloat(uniformName: string, value: number): Effect;
  89366. /**
  89367. * Sets a boolean on a uniform variable.
  89368. * @param uniformName Name of the variable.
  89369. * @param bool value to be set.
  89370. * @returns this effect.
  89371. */
  89372. setBool(uniformName: string, bool: boolean): Effect;
  89373. /**
  89374. * Sets a Vector2 on a uniform variable.
  89375. * @param uniformName Name of the variable.
  89376. * @param vector2 vector2 to be set.
  89377. * @returns this effect.
  89378. */
  89379. setVector2(uniformName: string, vector2: Vector2): Effect;
  89380. /**
  89381. * Sets a float2 on a uniform variable.
  89382. * @param uniformName Name of the variable.
  89383. * @param x First float in float2.
  89384. * @param y Second float in float2.
  89385. * @returns this effect.
  89386. */
  89387. setFloat2(uniformName: string, x: number, y: number): Effect;
  89388. /**
  89389. * Sets a Vector3 on a uniform variable.
  89390. * @param uniformName Name of the variable.
  89391. * @param vector3 Value to be set.
  89392. * @returns this effect.
  89393. */
  89394. setVector3(uniformName: string, vector3: Vector3): Effect;
  89395. /**
  89396. * Sets a float3 on a uniform variable.
  89397. * @param uniformName Name of the variable.
  89398. * @param x First float in float3.
  89399. * @param y Second float in float3.
  89400. * @param z Third float in float3.
  89401. * @returns this effect.
  89402. */
  89403. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89404. /**
  89405. * Sets a Vector4 on a uniform variable.
  89406. * @param uniformName Name of the variable.
  89407. * @param vector4 Value to be set.
  89408. * @returns this effect.
  89409. */
  89410. setVector4(uniformName: string, vector4: Vector4): Effect;
  89411. /**
  89412. * Sets a float4 on a uniform variable.
  89413. * @param uniformName Name of the variable.
  89414. * @param x First float in float4.
  89415. * @param y Second float in float4.
  89416. * @param z Third float in float4.
  89417. * @param w Fourth float in float4.
  89418. * @returns this effect.
  89419. */
  89420. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89421. /**
  89422. * Sets a Color3 on a uniform variable.
  89423. * @param uniformName Name of the variable.
  89424. * @param color3 Value to be set.
  89425. * @returns this effect.
  89426. */
  89427. setColor3(uniformName: string, color3: Color3): Effect;
  89428. /**
  89429. * Sets a Color4 on a uniform variable.
  89430. * @param uniformName Name of the variable.
  89431. * @param color3 Value to be set.
  89432. * @param alpha Alpha value to be set.
  89433. * @returns this effect.
  89434. */
  89435. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89436. /**
  89437. * Sets a Color4 on a uniform variable
  89438. * @param uniformName defines the name of the variable
  89439. * @param color4 defines the value to be set
  89440. * @returns this effect.
  89441. */
  89442. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89443. /** Release all associated resources */
  89444. dispose(): void;
  89445. /**
  89446. * This function will add a new shader to the shader store
  89447. * @param name the name of the shader
  89448. * @param pixelShader optional pixel shader content
  89449. * @param vertexShader optional vertex shader content
  89450. */
  89451. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89452. /**
  89453. * Store of each shader (The can be looked up using effect.key)
  89454. */
  89455. static ShadersStore: {
  89456. [key: string]: string;
  89457. };
  89458. /**
  89459. * Store of each included file for a shader (The can be looked up using effect.key)
  89460. */
  89461. static IncludesShadersStore: {
  89462. [key: string]: string;
  89463. };
  89464. /**
  89465. * Resets the cache of effects.
  89466. */
  89467. static ResetCache(): void;
  89468. }
  89469. }
  89470. declare module BABYLON {
  89471. /**
  89472. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89473. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89474. * 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;
  89475. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89476. */
  89477. export class ColorCurves {
  89478. private _dirty;
  89479. private _tempColor;
  89480. private _globalCurve;
  89481. private _highlightsCurve;
  89482. private _midtonesCurve;
  89483. private _shadowsCurve;
  89484. private _positiveCurve;
  89485. private _negativeCurve;
  89486. private _globalHue;
  89487. private _globalDensity;
  89488. private _globalSaturation;
  89489. private _globalExposure;
  89490. /**
  89491. * Gets the global Hue value.
  89492. * 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).
  89493. */
  89494. /**
  89495. * Sets the global Hue value.
  89496. * 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).
  89497. */
  89498. globalHue: number;
  89499. /**
  89500. * Gets the global Density value.
  89501. * 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.
  89502. * Values less than zero provide a filter of opposite hue.
  89503. */
  89504. /**
  89505. * Sets the global Density value.
  89506. * 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.
  89507. * Values less than zero provide a filter of opposite hue.
  89508. */
  89509. globalDensity: number;
  89510. /**
  89511. * Gets the global Saturation value.
  89512. * 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.
  89513. */
  89514. /**
  89515. * Sets the global Saturation value.
  89516. * 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.
  89517. */
  89518. globalSaturation: number;
  89519. /**
  89520. * Gets the global Exposure value.
  89521. * 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.
  89522. */
  89523. /**
  89524. * Sets the global Exposure value.
  89525. * 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.
  89526. */
  89527. globalExposure: number;
  89528. private _highlightsHue;
  89529. private _highlightsDensity;
  89530. private _highlightsSaturation;
  89531. private _highlightsExposure;
  89532. /**
  89533. * Gets the highlights Hue value.
  89534. * 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).
  89535. */
  89536. /**
  89537. * Sets the highlights Hue value.
  89538. * 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).
  89539. */
  89540. highlightsHue: number;
  89541. /**
  89542. * Gets the highlights Density value.
  89543. * 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.
  89544. * Values less than zero provide a filter of opposite hue.
  89545. */
  89546. /**
  89547. * Sets the highlights Density value.
  89548. * 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.
  89549. * Values less than zero provide a filter of opposite hue.
  89550. */
  89551. highlightsDensity: number;
  89552. /**
  89553. * Gets the highlights Saturation value.
  89554. * 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.
  89555. */
  89556. /**
  89557. * Sets the highlights Saturation value.
  89558. * 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.
  89559. */
  89560. highlightsSaturation: number;
  89561. /**
  89562. * Gets the highlights Exposure value.
  89563. * 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.
  89564. */
  89565. /**
  89566. * Sets the highlights Exposure value.
  89567. * 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.
  89568. */
  89569. highlightsExposure: number;
  89570. private _midtonesHue;
  89571. private _midtonesDensity;
  89572. private _midtonesSaturation;
  89573. private _midtonesExposure;
  89574. /**
  89575. * Gets the midtones Hue value.
  89576. * 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).
  89577. */
  89578. /**
  89579. * Sets the midtones Hue value.
  89580. * 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).
  89581. */
  89582. midtonesHue: number;
  89583. /**
  89584. * Gets the midtones Density value.
  89585. * 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.
  89586. * Values less than zero provide a filter of opposite hue.
  89587. */
  89588. /**
  89589. * Sets the midtones Density value.
  89590. * 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.
  89591. * Values less than zero provide a filter of opposite hue.
  89592. */
  89593. midtonesDensity: number;
  89594. /**
  89595. * Gets the midtones Saturation value.
  89596. * 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.
  89597. */
  89598. /**
  89599. * Sets the midtones Saturation value.
  89600. * 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.
  89601. */
  89602. midtonesSaturation: number;
  89603. /**
  89604. * Gets the midtones Exposure value.
  89605. * 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.
  89606. */
  89607. /**
  89608. * Sets the midtones Exposure value.
  89609. * 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.
  89610. */
  89611. midtonesExposure: number;
  89612. private _shadowsHue;
  89613. private _shadowsDensity;
  89614. private _shadowsSaturation;
  89615. private _shadowsExposure;
  89616. /**
  89617. * Gets the shadows Hue value.
  89618. * 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).
  89619. */
  89620. /**
  89621. * Sets the shadows Hue value.
  89622. * 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).
  89623. */
  89624. shadowsHue: number;
  89625. /**
  89626. * Gets the shadows Density value.
  89627. * 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.
  89628. * Values less than zero provide a filter of opposite hue.
  89629. */
  89630. /**
  89631. * Sets the shadows Density value.
  89632. * 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.
  89633. * Values less than zero provide a filter of opposite hue.
  89634. */
  89635. shadowsDensity: number;
  89636. /**
  89637. * Gets the shadows Saturation value.
  89638. * 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.
  89639. */
  89640. /**
  89641. * Sets the shadows Saturation value.
  89642. * 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.
  89643. */
  89644. shadowsSaturation: number;
  89645. /**
  89646. * Gets the shadows Exposure value.
  89647. * 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.
  89648. */
  89649. /**
  89650. * Sets the shadows Exposure value.
  89651. * 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.
  89652. */
  89653. shadowsExposure: number;
  89654. /**
  89655. * Returns the class name
  89656. * @returns The class name
  89657. */
  89658. getClassName(): string;
  89659. /**
  89660. * Binds the color curves to the shader.
  89661. * @param colorCurves The color curve to bind
  89662. * @param effect The effect to bind to
  89663. * @param positiveUniform The positive uniform shader parameter
  89664. * @param neutralUniform The neutral uniform shader parameter
  89665. * @param negativeUniform The negative uniform shader parameter
  89666. */
  89667. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89668. /**
  89669. * Prepare the list of uniforms associated with the ColorCurves effects.
  89670. * @param uniformsList The list of uniforms used in the effect
  89671. */
  89672. static PrepareUniforms(uniformsList: string[]): void;
  89673. /**
  89674. * Returns color grading data based on a hue, density, saturation and exposure value.
  89675. * @param filterHue The hue of the color filter.
  89676. * @param filterDensity The density of the color filter.
  89677. * @param saturation The saturation.
  89678. * @param exposure The exposure.
  89679. * @param result The result data container.
  89680. */
  89681. private getColorGradingDataToRef;
  89682. /**
  89683. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89684. * @param value The input slider value in range [-100,100].
  89685. * @returns Adjusted value.
  89686. */
  89687. private static applyColorGradingSliderNonlinear;
  89688. /**
  89689. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89690. * @param hue The hue (H) input.
  89691. * @param saturation The saturation (S) input.
  89692. * @param brightness The brightness (B) input.
  89693. * @result An RGBA color represented as Vector4.
  89694. */
  89695. private static fromHSBToRef;
  89696. /**
  89697. * Returns a value clamped between min and max
  89698. * @param value The value to clamp
  89699. * @param min The minimum of value
  89700. * @param max The maximum of value
  89701. * @returns The clamped value.
  89702. */
  89703. private static clamp;
  89704. /**
  89705. * Clones the current color curve instance.
  89706. * @return The cloned curves
  89707. */
  89708. clone(): ColorCurves;
  89709. /**
  89710. * Serializes the current color curve instance to a json representation.
  89711. * @return a JSON representation
  89712. */
  89713. serialize(): any;
  89714. /**
  89715. * Parses the color curve from a json representation.
  89716. * @param source the JSON source to parse
  89717. * @return The parsed curves
  89718. */
  89719. static Parse(source: any): ColorCurves;
  89720. }
  89721. }
  89722. declare module BABYLON {
  89723. /**
  89724. * Interface to follow in your material defines to integrate easily the
  89725. * Image proccessing functions.
  89726. * @hidden
  89727. */
  89728. export interface IImageProcessingConfigurationDefines {
  89729. IMAGEPROCESSING: boolean;
  89730. VIGNETTE: boolean;
  89731. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89732. VIGNETTEBLENDMODEOPAQUE: boolean;
  89733. TONEMAPPING: boolean;
  89734. TONEMAPPING_ACES: boolean;
  89735. CONTRAST: boolean;
  89736. EXPOSURE: boolean;
  89737. COLORCURVES: boolean;
  89738. COLORGRADING: boolean;
  89739. COLORGRADING3D: boolean;
  89740. SAMPLER3DGREENDEPTH: boolean;
  89741. SAMPLER3DBGRMAP: boolean;
  89742. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89743. }
  89744. /**
  89745. * @hidden
  89746. */
  89747. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89748. IMAGEPROCESSING: boolean;
  89749. VIGNETTE: boolean;
  89750. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89751. VIGNETTEBLENDMODEOPAQUE: boolean;
  89752. TONEMAPPING: boolean;
  89753. TONEMAPPING_ACES: boolean;
  89754. CONTRAST: boolean;
  89755. COLORCURVES: boolean;
  89756. COLORGRADING: boolean;
  89757. COLORGRADING3D: boolean;
  89758. SAMPLER3DGREENDEPTH: boolean;
  89759. SAMPLER3DBGRMAP: boolean;
  89760. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89761. EXPOSURE: boolean;
  89762. constructor();
  89763. }
  89764. /**
  89765. * This groups together the common properties used for image processing either in direct forward pass
  89766. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89767. * or not.
  89768. */
  89769. export class ImageProcessingConfiguration {
  89770. /**
  89771. * Default tone mapping applied in BabylonJS.
  89772. */
  89773. static readonly TONEMAPPING_STANDARD: number;
  89774. /**
  89775. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89776. * to other engines rendering to increase portability.
  89777. */
  89778. static readonly TONEMAPPING_ACES: number;
  89779. /**
  89780. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89781. */
  89782. colorCurves: Nullable<ColorCurves>;
  89783. private _colorCurvesEnabled;
  89784. /**
  89785. * Gets wether the color curves effect is enabled.
  89786. */
  89787. /**
  89788. * Sets wether the color curves effect is enabled.
  89789. */
  89790. colorCurvesEnabled: boolean;
  89791. private _colorGradingTexture;
  89792. /**
  89793. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89794. */
  89795. /**
  89796. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89797. */
  89798. colorGradingTexture: Nullable<BaseTexture>;
  89799. private _colorGradingEnabled;
  89800. /**
  89801. * Gets wether the color grading effect is enabled.
  89802. */
  89803. /**
  89804. * Sets wether the color grading effect is enabled.
  89805. */
  89806. colorGradingEnabled: boolean;
  89807. private _colorGradingWithGreenDepth;
  89808. /**
  89809. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89810. */
  89811. /**
  89812. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89813. */
  89814. colorGradingWithGreenDepth: boolean;
  89815. private _colorGradingBGR;
  89816. /**
  89817. * Gets wether the color grading texture contains BGR values.
  89818. */
  89819. /**
  89820. * Sets wether the color grading texture contains BGR values.
  89821. */
  89822. colorGradingBGR: boolean;
  89823. /** @hidden */
  89824. _exposure: number;
  89825. /**
  89826. * Gets the Exposure used in the effect.
  89827. */
  89828. /**
  89829. * Sets the Exposure used in the effect.
  89830. */
  89831. exposure: number;
  89832. private _toneMappingEnabled;
  89833. /**
  89834. * Gets wether the tone mapping effect is enabled.
  89835. */
  89836. /**
  89837. * Sets wether the tone mapping effect is enabled.
  89838. */
  89839. toneMappingEnabled: boolean;
  89840. private _toneMappingType;
  89841. /**
  89842. * Gets the type of tone mapping effect.
  89843. */
  89844. /**
  89845. * Sets the type of tone mapping effect used in BabylonJS.
  89846. */
  89847. toneMappingType: number;
  89848. protected _contrast: number;
  89849. /**
  89850. * Gets the contrast used in the effect.
  89851. */
  89852. /**
  89853. * Sets the contrast used in the effect.
  89854. */
  89855. contrast: number;
  89856. /**
  89857. * Vignette stretch size.
  89858. */
  89859. vignetteStretch: number;
  89860. /**
  89861. * Vignette centre X Offset.
  89862. */
  89863. vignetteCentreX: number;
  89864. /**
  89865. * Vignette centre Y Offset.
  89866. */
  89867. vignetteCentreY: number;
  89868. /**
  89869. * Vignette weight or intensity of the vignette effect.
  89870. */
  89871. vignetteWeight: number;
  89872. /**
  89873. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89874. * if vignetteEnabled is set to true.
  89875. */
  89876. vignetteColor: Color4;
  89877. /**
  89878. * Camera field of view used by the Vignette effect.
  89879. */
  89880. vignetteCameraFov: number;
  89881. private _vignetteBlendMode;
  89882. /**
  89883. * Gets the vignette blend mode allowing different kind of effect.
  89884. */
  89885. /**
  89886. * Sets the vignette blend mode allowing different kind of effect.
  89887. */
  89888. vignetteBlendMode: number;
  89889. private _vignetteEnabled;
  89890. /**
  89891. * Gets wether the vignette effect is enabled.
  89892. */
  89893. /**
  89894. * Sets wether the vignette effect is enabled.
  89895. */
  89896. vignetteEnabled: boolean;
  89897. private _applyByPostProcess;
  89898. /**
  89899. * Gets wether the image processing is applied through a post process or not.
  89900. */
  89901. /**
  89902. * Sets wether the image processing is applied through a post process or not.
  89903. */
  89904. applyByPostProcess: boolean;
  89905. private _isEnabled;
  89906. /**
  89907. * Gets wether the image processing is enabled or not.
  89908. */
  89909. /**
  89910. * Sets wether the image processing is enabled or not.
  89911. */
  89912. isEnabled: boolean;
  89913. /**
  89914. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89915. */
  89916. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89917. /**
  89918. * Method called each time the image processing information changes requires to recompile the effect.
  89919. */
  89920. protected _updateParameters(): void;
  89921. /**
  89922. * Gets the current class name.
  89923. * @return "ImageProcessingConfiguration"
  89924. */
  89925. getClassName(): string;
  89926. /**
  89927. * Prepare the list of uniforms associated with the Image Processing effects.
  89928. * @param uniforms The list of uniforms used in the effect
  89929. * @param defines the list of defines currently in use
  89930. */
  89931. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89932. /**
  89933. * Prepare the list of samplers associated with the Image Processing effects.
  89934. * @param samplersList The list of uniforms used in the effect
  89935. * @param defines the list of defines currently in use
  89936. */
  89937. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89938. /**
  89939. * Prepare the list of defines associated to the shader.
  89940. * @param defines the list of defines to complete
  89941. * @param forPostProcess Define if we are currently in post process mode or not
  89942. */
  89943. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89944. /**
  89945. * Returns true if all the image processing information are ready.
  89946. * @returns True if ready, otherwise, false
  89947. */
  89948. isReady(): boolean;
  89949. /**
  89950. * Binds the image processing to the shader.
  89951. * @param effect The effect to bind to
  89952. * @param aspectRatio Define the current aspect ratio of the effect
  89953. */
  89954. bind(effect: Effect, aspectRatio?: number): void;
  89955. /**
  89956. * Clones the current image processing instance.
  89957. * @return The cloned image processing
  89958. */
  89959. clone(): ImageProcessingConfiguration;
  89960. /**
  89961. * Serializes the current image processing instance to a json representation.
  89962. * @return a JSON representation
  89963. */
  89964. serialize(): any;
  89965. /**
  89966. * Parses the image processing from a json representation.
  89967. * @param source the JSON source to parse
  89968. * @return The parsed image processing
  89969. */
  89970. static Parse(source: any): ImageProcessingConfiguration;
  89971. private static _VIGNETTEMODE_MULTIPLY;
  89972. private static _VIGNETTEMODE_OPAQUE;
  89973. /**
  89974. * Used to apply the vignette as a mix with the pixel color.
  89975. */
  89976. static readonly VIGNETTEMODE_MULTIPLY: number;
  89977. /**
  89978. * Used to apply the vignette as a replacement of the pixel color.
  89979. */
  89980. static readonly VIGNETTEMODE_OPAQUE: number;
  89981. }
  89982. }
  89983. declare module BABYLON {
  89984. /**
  89985. * This represents all the required information to add a fresnel effect on a material:
  89986. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89987. */
  89988. export class FresnelParameters {
  89989. private _isEnabled;
  89990. /**
  89991. * Define if the fresnel effect is enable or not.
  89992. */
  89993. isEnabled: boolean;
  89994. /**
  89995. * Define the color used on edges (grazing angle)
  89996. */
  89997. leftColor: Color3;
  89998. /**
  89999. * Define the color used on center
  90000. */
  90001. rightColor: Color3;
  90002. /**
  90003. * Define bias applied to computed fresnel term
  90004. */
  90005. bias: number;
  90006. /**
  90007. * Defined the power exponent applied to fresnel term
  90008. */
  90009. power: number;
  90010. /**
  90011. * Clones the current fresnel and its valuues
  90012. * @returns a clone fresnel configuration
  90013. */
  90014. clone(): FresnelParameters;
  90015. /**
  90016. * Serializes the current fresnel parameters to a JSON representation.
  90017. * @return the JSON serialization
  90018. */
  90019. serialize(): any;
  90020. /**
  90021. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  90022. * @param parsedFresnelParameters Define the JSON representation
  90023. * @returns the parsed parameters
  90024. */
  90025. static Parse(parsedFresnelParameters: any): FresnelParameters;
  90026. }
  90027. }
  90028. declare module BABYLON {
  90029. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90030. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90031. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90032. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90033. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90034. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90035. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90036. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90037. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90038. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90039. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90040. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90041. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90042. /**
  90043. * Decorator used to define property that can be serialized as reference to a camera
  90044. * @param sourceName defines the name of the property to decorate
  90045. */
  90046. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90047. /**
  90048. * Class used to help serialization objects
  90049. */
  90050. export class SerializationHelper {
  90051. /** hidden */
  90052. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90053. /** hidden */
  90054. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90055. /** hidden */
  90056. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90057. /** hidden */
  90058. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90059. /**
  90060. * Appends the serialized animations from the source animations
  90061. * @param source Source containing the animations
  90062. * @param destination Target to store the animations
  90063. */
  90064. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90065. /**
  90066. * Static function used to serialized a specific entity
  90067. * @param entity defines the entity to serialize
  90068. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90069. * @returns a JSON compatible object representing the serialization of the entity
  90070. */
  90071. static Serialize<T>(entity: T, serializationObject?: any): any;
  90072. /**
  90073. * Creates a new entity from a serialization data object
  90074. * @param creationFunction defines a function used to instanciated the new entity
  90075. * @param source defines the source serialization data
  90076. * @param scene defines the hosting scene
  90077. * @param rootUrl defines the root url for resources
  90078. * @returns a new entity
  90079. */
  90080. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90081. /**
  90082. * Clones an object
  90083. * @param creationFunction defines the function used to instanciate the new object
  90084. * @param source defines the source object
  90085. * @returns the cloned object
  90086. */
  90087. static Clone<T>(creationFunction: () => T, source: T): T;
  90088. /**
  90089. * Instanciates a new object based on a source one (some data will be shared between both object)
  90090. * @param creationFunction defines the function used to instanciate the new object
  90091. * @param source defines the source object
  90092. * @returns the new object
  90093. */
  90094. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90095. }
  90096. }
  90097. declare module BABYLON {
  90098. /**
  90099. * This is the base class of all the camera used in the application.
  90100. * @see http://doc.babylonjs.com/features/cameras
  90101. */
  90102. export class Camera extends Node {
  90103. /** @hidden */
  90104. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90105. /**
  90106. * This is the default projection mode used by the cameras.
  90107. * It helps recreating a feeling of perspective and better appreciate depth.
  90108. * This is the best way to simulate real life cameras.
  90109. */
  90110. static readonly PERSPECTIVE_CAMERA: number;
  90111. /**
  90112. * This helps creating camera with an orthographic mode.
  90113. * 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.
  90114. */
  90115. static readonly ORTHOGRAPHIC_CAMERA: number;
  90116. /**
  90117. * This is the default FOV mode for perspective cameras.
  90118. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90119. */
  90120. static readonly FOVMODE_VERTICAL_FIXED: number;
  90121. /**
  90122. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90123. */
  90124. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90125. /**
  90126. * This specifies ther is no need for a camera rig.
  90127. * Basically only one eye is rendered corresponding to the camera.
  90128. */
  90129. static readonly RIG_MODE_NONE: number;
  90130. /**
  90131. * Simulates a camera Rig with one blue eye and one red eye.
  90132. * This can be use with 3d blue and red glasses.
  90133. */
  90134. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90135. /**
  90136. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90137. */
  90138. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90139. /**
  90140. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90141. */
  90142. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90143. /**
  90144. * Defines that both eyes of the camera will be rendered over under each other.
  90145. */
  90146. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90147. /**
  90148. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90149. */
  90150. static readonly RIG_MODE_VR: number;
  90151. /**
  90152. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90153. */
  90154. static readonly RIG_MODE_WEBVR: number;
  90155. /**
  90156. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90157. */
  90158. static readonly RIG_MODE_CUSTOM: number;
  90159. /**
  90160. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90161. */
  90162. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90163. /**
  90164. * Define the input manager associated with the camera.
  90165. */
  90166. inputs: CameraInputsManager<Camera>;
  90167. /** @hidden */
  90168. _position: Vector3;
  90169. /**
  90170. * Define the current local position of the camera in the scene
  90171. */
  90172. position: Vector3;
  90173. /**
  90174. * The vector the camera should consider as up.
  90175. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90176. */
  90177. upVector: Vector3;
  90178. /**
  90179. * Define the current limit on the left side for an orthographic camera
  90180. * In scene unit
  90181. */
  90182. orthoLeft: Nullable<number>;
  90183. /**
  90184. * Define the current limit on the right side for an orthographic camera
  90185. * In scene unit
  90186. */
  90187. orthoRight: Nullable<number>;
  90188. /**
  90189. * Define the current limit on the bottom side for an orthographic camera
  90190. * In scene unit
  90191. */
  90192. orthoBottom: Nullable<number>;
  90193. /**
  90194. * Define the current limit on the top side for an orthographic camera
  90195. * In scene unit
  90196. */
  90197. orthoTop: Nullable<number>;
  90198. /**
  90199. * Field Of View is set in Radians. (default is 0.8)
  90200. */
  90201. fov: number;
  90202. /**
  90203. * Define the minimum distance the camera can see from.
  90204. * This is important to note that the depth buffer are not infinite and the closer it starts
  90205. * the more your scene might encounter depth fighting issue.
  90206. */
  90207. minZ: number;
  90208. /**
  90209. * Define the maximum distance the camera can see to.
  90210. * This is important to note that the depth buffer are not infinite and the further it end
  90211. * the more your scene might encounter depth fighting issue.
  90212. */
  90213. maxZ: number;
  90214. /**
  90215. * Define the default inertia of the camera.
  90216. * This helps giving a smooth feeling to the camera movement.
  90217. */
  90218. inertia: number;
  90219. /**
  90220. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  90221. */
  90222. mode: number;
  90223. /**
  90224. * Define wether the camera is intermediate.
  90225. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90226. */
  90227. isIntermediate: boolean;
  90228. /**
  90229. * Define the viewport of the camera.
  90230. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90231. */
  90232. viewport: Viewport;
  90233. /**
  90234. * Restricts the camera to viewing objects with the same layerMask.
  90235. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90236. */
  90237. layerMask: number;
  90238. /**
  90239. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90240. */
  90241. fovMode: number;
  90242. /**
  90243. * Rig mode of the camera.
  90244. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90245. * This is normally controlled byt the camera themselves as internal use.
  90246. */
  90247. cameraRigMode: number;
  90248. /**
  90249. * Defines the distance between both "eyes" in case of a RIG
  90250. */
  90251. interaxialDistance: number;
  90252. /**
  90253. * Defines if stereoscopic rendering is done side by side or over under.
  90254. */
  90255. isStereoscopicSideBySide: boolean;
  90256. /**
  90257. * 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
  90258. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90259. * else in the scene.
  90260. */
  90261. customRenderTargets: RenderTargetTexture[];
  90262. /**
  90263. * When set, the camera will render to this render target instead of the default canvas
  90264. */
  90265. outputRenderTarget: Nullable<RenderTargetTexture>;
  90266. /**
  90267. * Observable triggered when the camera view matrix has changed.
  90268. */
  90269. onViewMatrixChangedObservable: Observable<Camera>;
  90270. /**
  90271. * Observable triggered when the camera Projection matrix has changed.
  90272. */
  90273. onProjectionMatrixChangedObservable: Observable<Camera>;
  90274. /**
  90275. * Observable triggered when the inputs have been processed.
  90276. */
  90277. onAfterCheckInputsObservable: Observable<Camera>;
  90278. /**
  90279. * Observable triggered when reset has been called and applied to the camera.
  90280. */
  90281. onRestoreStateObservable: Observable<Camera>;
  90282. /** @hidden */
  90283. _cameraRigParams: any;
  90284. /** @hidden */
  90285. _rigCameras: Camera[];
  90286. /** @hidden */
  90287. _rigPostProcess: Nullable<PostProcess>;
  90288. protected _webvrViewMatrix: Matrix;
  90289. /** @hidden */
  90290. _skipRendering: boolean;
  90291. /** @hidden */
  90292. _projectionMatrix: Matrix;
  90293. /** @hidden */
  90294. _postProcesses: Nullable<PostProcess>[];
  90295. /** @hidden */
  90296. _activeMeshes: SmartArray<AbstractMesh>;
  90297. protected _globalPosition: Vector3;
  90298. /** hidden */
  90299. _computedViewMatrix: Matrix;
  90300. private _doNotComputeProjectionMatrix;
  90301. private _transformMatrix;
  90302. private _frustumPlanes;
  90303. private _refreshFrustumPlanes;
  90304. private _storedFov;
  90305. private _stateStored;
  90306. /**
  90307. * Instantiates a new camera object.
  90308. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90309. * @see http://doc.babylonjs.com/features/cameras
  90310. * @param name Defines the name of the camera in the scene
  90311. * @param position Defines the position of the camera
  90312. * @param scene Defines the scene the camera belongs too
  90313. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90314. */
  90315. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90316. /**
  90317. * Store current camera state (fov, position, etc..)
  90318. * @returns the camera
  90319. */
  90320. storeState(): Camera;
  90321. /**
  90322. * Restores the camera state values if it has been stored. You must call storeState() first
  90323. */
  90324. protected _restoreStateValues(): boolean;
  90325. /**
  90326. * Restored camera state. You must call storeState() first.
  90327. * @returns true if restored and false otherwise
  90328. */
  90329. restoreState(): boolean;
  90330. /**
  90331. * Gets the class name of the camera.
  90332. * @returns the class name
  90333. */
  90334. getClassName(): string;
  90335. /** @hidden */
  90336. readonly _isCamera: boolean;
  90337. /**
  90338. * Gets a string representation of the camera useful for debug purpose.
  90339. * @param fullDetails Defines that a more verboe level of logging is required
  90340. * @returns the string representation
  90341. */
  90342. toString(fullDetails?: boolean): string;
  90343. /**
  90344. * Gets the current world space position of the camera.
  90345. */
  90346. readonly globalPosition: Vector3;
  90347. /**
  90348. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90349. * @returns the active meshe list
  90350. */
  90351. getActiveMeshes(): SmartArray<AbstractMesh>;
  90352. /**
  90353. * Check wether a mesh is part of the current active mesh list of the camera
  90354. * @param mesh Defines the mesh to check
  90355. * @returns true if active, false otherwise
  90356. */
  90357. isActiveMesh(mesh: Mesh): boolean;
  90358. /**
  90359. * Is this camera ready to be used/rendered
  90360. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90361. * @return true if the camera is ready
  90362. */
  90363. isReady(completeCheck?: boolean): boolean;
  90364. /** @hidden */
  90365. _initCache(): void;
  90366. /** @hidden */
  90367. _updateCache(ignoreParentClass?: boolean): void;
  90368. /** @hidden */
  90369. _isSynchronized(): boolean;
  90370. /** @hidden */
  90371. _isSynchronizedViewMatrix(): boolean;
  90372. /** @hidden */
  90373. _isSynchronizedProjectionMatrix(): boolean;
  90374. /**
  90375. * Attach the input controls to a specific dom element to get the input from.
  90376. * @param element Defines the element the controls should be listened from
  90377. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90378. */
  90379. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90380. /**
  90381. * Detach the current controls from the specified dom element.
  90382. * @param element Defines the element to stop listening the inputs from
  90383. */
  90384. detachControl(element: HTMLElement): void;
  90385. /**
  90386. * Update the camera state according to the different inputs gathered during the frame.
  90387. */
  90388. update(): void;
  90389. /** @hidden */
  90390. _checkInputs(): void;
  90391. /** @hidden */
  90392. readonly rigCameras: Camera[];
  90393. /**
  90394. * Gets the post process used by the rig cameras
  90395. */
  90396. readonly rigPostProcess: Nullable<PostProcess>;
  90397. /**
  90398. * Internal, gets the first post proces.
  90399. * @returns the first post process to be run on this camera.
  90400. */
  90401. _getFirstPostProcess(): Nullable<PostProcess>;
  90402. private _cascadePostProcessesToRigCams;
  90403. /**
  90404. * Attach a post process to the camera.
  90405. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90406. * @param postProcess The post process to attach to the camera
  90407. * @param insertAt The position of the post process in case several of them are in use in the scene
  90408. * @returns the position the post process has been inserted at
  90409. */
  90410. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90411. /**
  90412. * Detach a post process to the camera.
  90413. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90414. * @param postProcess The post process to detach from the camera
  90415. */
  90416. detachPostProcess(postProcess: PostProcess): void;
  90417. /**
  90418. * Gets the current world matrix of the camera
  90419. */
  90420. getWorldMatrix(): Matrix;
  90421. /** @hidden */
  90422. _getViewMatrix(): Matrix;
  90423. /**
  90424. * Gets the current view matrix of the camera.
  90425. * @param force forces the camera to recompute the matrix without looking at the cached state
  90426. * @returns the view matrix
  90427. */
  90428. getViewMatrix(force?: boolean): Matrix;
  90429. /**
  90430. * Freeze the projection matrix.
  90431. * It will prevent the cache check of the camera projection compute and can speed up perf
  90432. * if no parameter of the camera are meant to change
  90433. * @param projection Defines manually a projection if necessary
  90434. */
  90435. freezeProjectionMatrix(projection?: Matrix): void;
  90436. /**
  90437. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90438. */
  90439. unfreezeProjectionMatrix(): void;
  90440. /**
  90441. * Gets the current projection matrix of the camera.
  90442. * @param force forces the camera to recompute the matrix without looking at the cached state
  90443. * @returns the projection matrix
  90444. */
  90445. getProjectionMatrix(force?: boolean): Matrix;
  90446. /**
  90447. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90448. * @returns a Matrix
  90449. */
  90450. getTransformationMatrix(): Matrix;
  90451. private _updateFrustumPlanes;
  90452. /**
  90453. * Checks if a cullable object (mesh...) is in the camera frustum
  90454. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90455. * @param target The object to check
  90456. * @returns true if the object is in frustum otherwise false
  90457. */
  90458. isInFrustum(target: ICullable): boolean;
  90459. /**
  90460. * Checks if a cullable object (mesh...) is in the camera frustum
  90461. * Unlike isInFrustum this cheks the full bounding box
  90462. * @param target The object to check
  90463. * @returns true if the object is in frustum otherwise false
  90464. */
  90465. isCompletelyInFrustum(target: ICullable): boolean;
  90466. /**
  90467. * Gets a ray in the forward direction from the camera.
  90468. * @param length Defines the length of the ray to create
  90469. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90470. * @param origin Defines the start point of the ray which defaults to the camera position
  90471. * @returns the forward ray
  90472. */
  90473. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90474. /**
  90475. * Releases resources associated with this node.
  90476. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90477. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90478. */
  90479. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90480. /** @hidden */
  90481. _isLeftCamera: boolean;
  90482. /**
  90483. * Gets the left camera of a rig setup in case of Rigged Camera
  90484. */
  90485. readonly isLeftCamera: boolean;
  90486. /** @hidden */
  90487. _isRightCamera: boolean;
  90488. /**
  90489. * Gets the right camera of a rig setup in case of Rigged Camera
  90490. */
  90491. readonly isRightCamera: boolean;
  90492. /**
  90493. * Gets the left camera of a rig setup in case of Rigged Camera
  90494. */
  90495. readonly leftCamera: Nullable<FreeCamera>;
  90496. /**
  90497. * Gets the right camera of a rig setup in case of Rigged Camera
  90498. */
  90499. readonly rightCamera: Nullable<FreeCamera>;
  90500. /**
  90501. * Gets the left camera target of a rig setup in case of Rigged Camera
  90502. * @returns the target position
  90503. */
  90504. getLeftTarget(): Nullable<Vector3>;
  90505. /**
  90506. * Gets the right camera target of a rig setup in case of Rigged Camera
  90507. * @returns the target position
  90508. */
  90509. getRightTarget(): Nullable<Vector3>;
  90510. /**
  90511. * @hidden
  90512. */
  90513. setCameraRigMode(mode: number, rigParams: any): void;
  90514. /** @hidden */
  90515. static _setStereoscopicRigMode(camera: Camera): void;
  90516. /** @hidden */
  90517. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90518. /** @hidden */
  90519. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90520. /** @hidden */
  90521. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90522. /** @hidden */
  90523. _getVRProjectionMatrix(): Matrix;
  90524. protected _updateCameraRotationMatrix(): void;
  90525. protected _updateWebVRCameraRotationMatrix(): void;
  90526. /**
  90527. * This function MUST be overwritten by the different WebVR cameras available.
  90528. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90529. * @hidden
  90530. */
  90531. _getWebVRProjectionMatrix(): Matrix;
  90532. /**
  90533. * This function MUST be overwritten by the different WebVR cameras available.
  90534. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90535. * @hidden
  90536. */
  90537. _getWebVRViewMatrix(): Matrix;
  90538. /** @hidden */
  90539. setCameraRigParameter(name: string, value: any): void;
  90540. /**
  90541. * needs to be overridden by children so sub has required properties to be copied
  90542. * @hidden
  90543. */
  90544. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90545. /**
  90546. * May need to be overridden by children
  90547. * @hidden
  90548. */
  90549. _updateRigCameras(): void;
  90550. /** @hidden */
  90551. _setupInputs(): void;
  90552. /**
  90553. * Serialiaze the camera setup to a json represention
  90554. * @returns the JSON representation
  90555. */
  90556. serialize(): any;
  90557. /**
  90558. * Clones the current camera.
  90559. * @param name The cloned camera name
  90560. * @returns the cloned camera
  90561. */
  90562. clone(name: string): Camera;
  90563. /**
  90564. * Gets the direction of the camera relative to a given local axis.
  90565. * @param localAxis Defines the reference axis to provide a relative direction.
  90566. * @return the direction
  90567. */
  90568. getDirection(localAxis: Vector3): Vector3;
  90569. /**
  90570. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90571. * @param localAxis Defines the reference axis to provide a relative direction.
  90572. * @param result Defines the vector to store the result in
  90573. */
  90574. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90575. /**
  90576. * Gets a camera constructor for a given camera type
  90577. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90578. * @param name The name of the camera the result will be able to instantiate
  90579. * @param scene The scene the result will construct the camera in
  90580. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90581. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90582. * @returns a factory method to construc the camera
  90583. */
  90584. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90585. /**
  90586. * Compute the world matrix of the camera.
  90587. * @returns the camera workd matrix
  90588. */
  90589. computeWorldMatrix(): Matrix;
  90590. /**
  90591. * Parse a JSON and creates the camera from the parsed information
  90592. * @param parsedCamera The JSON to parse
  90593. * @param scene The scene to instantiate the camera in
  90594. * @returns the newly constructed camera
  90595. */
  90596. static Parse(parsedCamera: any, scene: Scene): Camera;
  90597. }
  90598. }
  90599. declare module BABYLON {
  90600. /**
  90601. * Interface for any object that can request an animation frame
  90602. */
  90603. export interface ICustomAnimationFrameRequester {
  90604. /**
  90605. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90606. */
  90607. renderFunction?: Function;
  90608. /**
  90609. * Called to request the next frame to render to
  90610. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90611. */
  90612. requestAnimationFrame: Function;
  90613. /**
  90614. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90615. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90616. */
  90617. requestID?: number;
  90618. }
  90619. /**
  90620. * Interface containing an array of animations
  90621. */
  90622. export interface IAnimatable {
  90623. /**
  90624. * Array of animations
  90625. */
  90626. animations: Nullable<Array<Animation>>;
  90627. }
  90628. /** Interface used by value gradients (color, factor, ...) */
  90629. export interface IValueGradient {
  90630. /**
  90631. * Gets or sets the gradient value (between 0 and 1)
  90632. */
  90633. gradient: number;
  90634. }
  90635. /** Class used to store color4 gradient */
  90636. export class ColorGradient implements IValueGradient {
  90637. /**
  90638. * Gets or sets the gradient value (between 0 and 1)
  90639. */
  90640. gradient: number;
  90641. /**
  90642. * Gets or sets first associated color
  90643. */
  90644. color1: Color4;
  90645. /**
  90646. * Gets or sets second associated color
  90647. */
  90648. color2?: Color4;
  90649. /**
  90650. * Will get a color picked randomly between color1 and color2.
  90651. * If color2 is undefined then color1 will be used
  90652. * @param result defines the target Color4 to store the result in
  90653. */
  90654. getColorToRef(result: Color4): void;
  90655. }
  90656. /** Class used to store color 3 gradient */
  90657. export class Color3Gradient implements IValueGradient {
  90658. /**
  90659. * Gets or sets the gradient value (between 0 and 1)
  90660. */
  90661. gradient: number;
  90662. /**
  90663. * Gets or sets the associated color
  90664. */
  90665. color: Color3;
  90666. }
  90667. /** Class used to store factor gradient */
  90668. export class FactorGradient implements IValueGradient {
  90669. /**
  90670. * Gets or sets the gradient value (between 0 and 1)
  90671. */
  90672. gradient: number;
  90673. /**
  90674. * Gets or sets first associated factor
  90675. */
  90676. factor1: number;
  90677. /**
  90678. * Gets or sets second associated factor
  90679. */
  90680. factor2?: number;
  90681. /**
  90682. * Will get a number picked randomly between factor1 and factor2.
  90683. * If factor2 is undefined then factor1 will be used
  90684. * @returns the picked number
  90685. */
  90686. getFactor(): number;
  90687. }
  90688. /**
  90689. * @ignore
  90690. * Application error to support additional information when loading a file
  90691. */
  90692. export class LoadFileError extends Error {
  90693. /** defines the optional web request */
  90694. request?: WebRequest | undefined;
  90695. private static _setPrototypeOf;
  90696. /**
  90697. * Creates a new LoadFileError
  90698. * @param message defines the message of the error
  90699. * @param request defines the optional web request
  90700. */
  90701. constructor(message: string,
  90702. /** defines the optional web request */
  90703. request?: WebRequest | undefined);
  90704. }
  90705. /**
  90706. * Class used to define a retry strategy when error happens while loading assets
  90707. */
  90708. export class RetryStrategy {
  90709. /**
  90710. * Function used to defines an exponential back off strategy
  90711. * @param maxRetries defines the maximum number of retries (3 by default)
  90712. * @param baseInterval defines the interval between retries
  90713. * @returns the strategy function to use
  90714. */
  90715. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90716. }
  90717. /**
  90718. * File request interface
  90719. */
  90720. export interface IFileRequest {
  90721. /**
  90722. * Raised when the request is complete (success or error).
  90723. */
  90724. onCompleteObservable: Observable<IFileRequest>;
  90725. /**
  90726. * Aborts the request for a file.
  90727. */
  90728. abort: () => void;
  90729. }
  90730. /**
  90731. * Class containing a set of static utilities functions
  90732. */
  90733. export class Tools {
  90734. /**
  90735. * Gets or sets the base URL to use to load assets
  90736. */
  90737. static BaseUrl: string;
  90738. /**
  90739. * Enable/Disable Custom HTTP Request Headers globally.
  90740. * default = false
  90741. * @see CustomRequestHeaders
  90742. */
  90743. static UseCustomRequestHeaders: boolean;
  90744. /**
  90745. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90746. * i.e. when loading files, where the server/service expects an Authorization header
  90747. */
  90748. static CustomRequestHeaders: {
  90749. [key: string]: string;
  90750. };
  90751. /**
  90752. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90753. */
  90754. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90755. /**
  90756. * Default behaviour for cors in the application.
  90757. * It can be a string if the expected behavior is identical in the entire app.
  90758. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90759. */
  90760. static CorsBehavior: string | ((url: string | string[]) => string);
  90761. /**
  90762. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90763. * @ignorenaming
  90764. */
  90765. static UseFallbackTexture: boolean;
  90766. /**
  90767. * Use this object to register external classes like custom textures or material
  90768. * to allow the laoders to instantiate them
  90769. */
  90770. static RegisteredExternalClasses: {
  90771. [key: string]: Object;
  90772. };
  90773. /**
  90774. * Texture content used if a texture cannot loaded
  90775. * @ignorenaming
  90776. */
  90777. static fallbackTexture: string;
  90778. /**
  90779. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90780. * @param u defines the coordinate on X axis
  90781. * @param v defines the coordinate on Y axis
  90782. * @param width defines the width of the source data
  90783. * @param height defines the height of the source data
  90784. * @param pixels defines the source byte array
  90785. * @param color defines the output color
  90786. */
  90787. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90788. /**
  90789. * Interpolates between a and b via alpha
  90790. * @param a The lower value (returned when alpha = 0)
  90791. * @param b The upper value (returned when alpha = 1)
  90792. * @param alpha The interpolation-factor
  90793. * @return The mixed value
  90794. */
  90795. static Mix(a: number, b: number, alpha: number): number;
  90796. /**
  90797. * Tries to instantiate a new object from a given class name
  90798. * @param className defines the class name to instantiate
  90799. * @returns the new object or null if the system was not able to do the instantiation
  90800. */
  90801. static Instantiate(className: string): any;
  90802. /**
  90803. * Provides a slice function that will work even on IE
  90804. * @param data defines the array to slice
  90805. * @param start defines the start of the data (optional)
  90806. * @param end defines the end of the data (optional)
  90807. * @returns the new sliced array
  90808. */
  90809. static Slice<T>(data: T, start?: number, end?: number): T;
  90810. /**
  90811. * Polyfill for setImmediate
  90812. * @param action defines the action to execute after the current execution block
  90813. */
  90814. static SetImmediate(action: () => void): void;
  90815. /**
  90816. * Function indicating if a number is an exponent of 2
  90817. * @param value defines the value to test
  90818. * @returns true if the value is an exponent of 2
  90819. */
  90820. static IsExponentOfTwo(value: number): boolean;
  90821. private static _tmpFloatArray;
  90822. /**
  90823. * Returns the nearest 32-bit single precision float representation of a Number
  90824. * @param value A Number. If the parameter is of a different type, it will get converted
  90825. * to a number or to NaN if it cannot be converted
  90826. * @returns number
  90827. */
  90828. static FloatRound(value: number): number;
  90829. /**
  90830. * Find the next highest power of two.
  90831. * @param x Number to start search from.
  90832. * @return Next highest power of two.
  90833. */
  90834. static CeilingPOT(x: number): number;
  90835. /**
  90836. * Find the next lowest power of two.
  90837. * @param x Number to start search from.
  90838. * @return Next lowest power of two.
  90839. */
  90840. static FloorPOT(x: number): number;
  90841. /**
  90842. * Find the nearest power of two.
  90843. * @param x Number to start search from.
  90844. * @return Next nearest power of two.
  90845. */
  90846. static NearestPOT(x: number): number;
  90847. /**
  90848. * Get the closest exponent of two
  90849. * @param value defines the value to approximate
  90850. * @param max defines the maximum value to return
  90851. * @param mode defines how to define the closest value
  90852. * @returns closest exponent of two of the given value
  90853. */
  90854. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90855. /**
  90856. * Extracts the filename from a path
  90857. * @param path defines the path to use
  90858. * @returns the filename
  90859. */
  90860. static GetFilename(path: string): string;
  90861. /**
  90862. * Extracts the "folder" part of a path (everything before the filename).
  90863. * @param uri The URI to extract the info from
  90864. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90865. * @returns The "folder" part of the path
  90866. */
  90867. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90868. /**
  90869. * Extracts text content from a DOM element hierarchy
  90870. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90871. */
  90872. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90873. /**
  90874. * Convert an angle in radians to degrees
  90875. * @param angle defines the angle to convert
  90876. * @returns the angle in degrees
  90877. */
  90878. static ToDegrees(angle: number): number;
  90879. /**
  90880. * Convert an angle in degrees to radians
  90881. * @param angle defines the angle to convert
  90882. * @returns the angle in radians
  90883. */
  90884. static ToRadians(angle: number): number;
  90885. /**
  90886. * Encode a buffer to a base64 string
  90887. * @param buffer defines the buffer to encode
  90888. * @returns the encoded string
  90889. */
  90890. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90891. /**
  90892. * Extracts minimum and maximum values from a list of indexed positions
  90893. * @param positions defines the positions to use
  90894. * @param indices defines the indices to the positions
  90895. * @param indexStart defines the start index
  90896. * @param indexCount defines the end index
  90897. * @param bias defines bias value to add to the result
  90898. * @return minimum and maximum values
  90899. */
  90900. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90901. minimum: Vector3;
  90902. maximum: Vector3;
  90903. };
  90904. /**
  90905. * Extracts minimum and maximum values from a list of positions
  90906. * @param positions defines the positions to use
  90907. * @param start defines the start index in the positions array
  90908. * @param count defines the number of positions to handle
  90909. * @param bias defines bias value to add to the result
  90910. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90911. * @return minimum and maximum values
  90912. */
  90913. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90914. minimum: Vector3;
  90915. maximum: Vector3;
  90916. };
  90917. /**
  90918. * Returns an array if obj is not an array
  90919. * @param obj defines the object to evaluate as an array
  90920. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90921. * @returns either obj directly if obj is an array or a new array containing obj
  90922. */
  90923. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90924. /**
  90925. * Gets the pointer prefix to use
  90926. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90927. */
  90928. static GetPointerPrefix(): string;
  90929. /**
  90930. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90931. * @param func - the function to be called
  90932. * @param requester - the object that will request the next frame. Falls back to window.
  90933. * @returns frame number
  90934. */
  90935. static QueueNewFrame(func: () => void, requester?: any): number;
  90936. /**
  90937. * Ask the browser to promote the current element to fullscreen rendering mode
  90938. * @param element defines the DOM element to promote
  90939. */
  90940. static RequestFullscreen(element: HTMLElement): void;
  90941. /**
  90942. * Asks the browser to exit fullscreen mode
  90943. */
  90944. static ExitFullscreen(): void;
  90945. /**
  90946. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90947. * @param url define the url we are trying
  90948. * @param element define the dom element where to configure the cors policy
  90949. */
  90950. static SetCorsBehavior(url: string | string[], element: {
  90951. crossOrigin: string | null;
  90952. }): void;
  90953. /**
  90954. * Removes unwanted characters from an url
  90955. * @param url defines the url to clean
  90956. * @returns the cleaned url
  90957. */
  90958. static CleanUrl(url: string): string;
  90959. /**
  90960. * Gets or sets a function used to pre-process url before using them to load assets
  90961. */
  90962. static PreprocessUrl: (url: string) => string;
  90963. /**
  90964. * Loads an image as an HTMLImageElement.
  90965. * @param input url string, ArrayBuffer, or Blob to load
  90966. * @param onLoad callback called when the image successfully loads
  90967. * @param onError callback called when the image fails to load
  90968. * @param offlineProvider offline provider for caching
  90969. * @returns the HTMLImageElement of the loaded image
  90970. */
  90971. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90972. /**
  90973. * Loads a file
  90974. * @param url url string, ArrayBuffer, or Blob to load
  90975. * @param onSuccess callback called when the file successfully loads
  90976. * @param onProgress callback called while file is loading (if the server supports this mode)
  90977. * @param offlineProvider defines the offline provider for caching
  90978. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90979. * @param onError callback called when the file fails to load
  90980. * @returns a file request object
  90981. */
  90982. 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;
  90983. /**
  90984. * Load a script (identified by an url). When the url returns, the
  90985. * content of this file is added into a new script element, attached to the DOM (body element)
  90986. * @param scriptUrl defines the url of the script to laod
  90987. * @param onSuccess defines the callback called when the script is loaded
  90988. * @param onError defines the callback to call if an error occurs
  90989. * @param scriptId defines the id of the script element
  90990. */
  90991. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90992. /**
  90993. * Load an asynchronous script (identified by an url). When the url returns, the
  90994. * content of this file is added into a new script element, attached to the DOM (body element)
  90995. * @param scriptUrl defines the url of the script to laod
  90996. * @param scriptId defines the id of the script element
  90997. * @returns a promise request object
  90998. */
  90999. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  91000. /**
  91001. * Loads a file from a blob
  91002. * @param fileToLoad defines the blob to use
  91003. * @param callback defines the callback to call when data is loaded
  91004. * @param progressCallback defines the callback to call during loading process
  91005. * @returns a file request object
  91006. */
  91007. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  91008. /**
  91009. * Loads a file
  91010. * @param fileToLoad defines the file to load
  91011. * @param callback defines the callback to call when data is loaded
  91012. * @param progressCallBack defines the callback to call during loading process
  91013. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  91014. * @returns a file request object
  91015. */
  91016. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  91017. /**
  91018. * Creates a data url from a given string content
  91019. * @param content defines the content to convert
  91020. * @returns the new data url link
  91021. */
  91022. static FileAsURL(content: string): string;
  91023. /**
  91024. * Format the given number to a specific decimal format
  91025. * @param value defines the number to format
  91026. * @param decimals defines the number of decimals to use
  91027. * @returns the formatted string
  91028. */
  91029. static Format(value: number, decimals?: number): string;
  91030. /**
  91031. * Checks if a given vector is inside a specific range
  91032. * @param v defines the vector to test
  91033. * @param min defines the minimum range
  91034. * @param max defines the maximum range
  91035. */
  91036. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  91037. /**
  91038. * Tries to copy an object by duplicating every property
  91039. * @param source defines the source object
  91040. * @param destination defines the target object
  91041. * @param doNotCopyList defines a list of properties to avoid
  91042. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  91043. */
  91044. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  91045. /**
  91046. * Gets a boolean indicating if the given object has no own property
  91047. * @param obj defines the object to test
  91048. * @returns true if object has no own property
  91049. */
  91050. static IsEmpty(obj: any): boolean;
  91051. /**
  91052. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  91053. * @param str Source string
  91054. * @param suffix Suffix to search for in the source string
  91055. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  91056. */
  91057. static EndsWith(str: string, suffix: string): boolean;
  91058. /**
  91059. * Function used to register events at window level
  91060. * @param events defines the events to register
  91061. */
  91062. static RegisterTopRootEvents(events: {
  91063. name: string;
  91064. handler: Nullable<(e: FocusEvent) => any>;
  91065. }[]): void;
  91066. /**
  91067. * Function used to unregister events from window level
  91068. * @param events defines the events to unregister
  91069. */
  91070. static UnregisterTopRootEvents(events: {
  91071. name: string;
  91072. handler: Nullable<(e: FocusEvent) => any>;
  91073. }[]): void;
  91074. /**
  91075. * @ignore
  91076. */
  91077. static _ScreenshotCanvas: HTMLCanvasElement;
  91078. /**
  91079. * Dumps the current bound framebuffer
  91080. * @param width defines the rendering width
  91081. * @param height defines the rendering height
  91082. * @param engine defines the hosting engine
  91083. * @param successCallback defines the callback triggered once the data are available
  91084. * @param mimeType defines the mime type of the result
  91085. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  91086. */
  91087. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91088. /**
  91089. * Converts the canvas data to blob.
  91090. * This acts as a polyfill for browsers not supporting the to blob function.
  91091. * @param canvas Defines the canvas to extract the data from
  91092. * @param successCallback Defines the callback triggered once the data are available
  91093. * @param mimeType Defines the mime type of the result
  91094. */
  91095. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  91096. /**
  91097. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  91098. * @param successCallback defines the callback triggered once the data are available
  91099. * @param mimeType defines the mime type of the result
  91100. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  91101. */
  91102. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91103. /**
  91104. * Downloads a blob in the browser
  91105. * @param blob defines the blob to download
  91106. * @param fileName defines the name of the downloaded file
  91107. */
  91108. static Download(blob: Blob, fileName: string): void;
  91109. /**
  91110. * Captures a screenshot of the current rendering
  91111. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91112. * @param engine defines the rendering engine
  91113. * @param camera defines the source camera
  91114. * @param size This parameter can be set to a single number or to an object with the
  91115. * following (optional) properties: precision, width, height. If a single number is passed,
  91116. * it will be used for both width and height. If an object is passed, the screenshot size
  91117. * will be derived from the parameters. The precision property is a multiplier allowing
  91118. * rendering at a higher or lower resolution
  91119. * @param successCallback defines the callback receives a single parameter which contains the
  91120. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91121. * src parameter of an <img> to display it
  91122. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  91123. * Check your browser for supported MIME types
  91124. */
  91125. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  91126. /**
  91127. * Generates an image screenshot from the specified camera.
  91128. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91129. * @param engine The engine to use for rendering
  91130. * @param camera The camera to use for rendering
  91131. * @param size This parameter can be set to a single number or to an object with the
  91132. * following (optional) properties: precision, width, height. If a single number is passed,
  91133. * it will be used for both width and height. If an object is passed, the screenshot size
  91134. * will be derived from the parameters. The precision property is a multiplier allowing
  91135. * rendering at a higher or lower resolution
  91136. * @param successCallback The callback receives a single parameter which contains the
  91137. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91138. * src parameter of an <img> to display it
  91139. * @param mimeType The MIME type of the screenshot image (default: image/png).
  91140. * Check your browser for supported MIME types
  91141. * @param samples Texture samples (default: 1)
  91142. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  91143. * @param fileName A name for for the downloaded file.
  91144. */
  91145. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  91146. /**
  91147. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91148. * Be aware Math.random() could cause collisions, but:
  91149. * "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"
  91150. * @returns a pseudo random id
  91151. */
  91152. static RandomId(): string;
  91153. /**
  91154. * Test if the given uri is a base64 string
  91155. * @param uri The uri to test
  91156. * @return True if the uri is a base64 string or false otherwise
  91157. */
  91158. static IsBase64(uri: string): boolean;
  91159. /**
  91160. * Decode the given base64 uri.
  91161. * @param uri The uri to decode
  91162. * @return The decoded base64 data.
  91163. */
  91164. static DecodeBase64(uri: string): ArrayBuffer;
  91165. /**
  91166. * Gets the absolute url.
  91167. * @param url the input url
  91168. * @return the absolute url
  91169. */
  91170. static GetAbsoluteUrl(url: string): string;
  91171. /**
  91172. * No log
  91173. */
  91174. static readonly NoneLogLevel: number;
  91175. /**
  91176. * Only message logs
  91177. */
  91178. static readonly MessageLogLevel: number;
  91179. /**
  91180. * Only warning logs
  91181. */
  91182. static readonly WarningLogLevel: number;
  91183. /**
  91184. * Only error logs
  91185. */
  91186. static readonly ErrorLogLevel: number;
  91187. /**
  91188. * All logs
  91189. */
  91190. static readonly AllLogLevel: number;
  91191. /**
  91192. * Gets a value indicating the number of loading errors
  91193. * @ignorenaming
  91194. */
  91195. static readonly errorsCount: number;
  91196. /**
  91197. * Callback called when a new log is added
  91198. */
  91199. static OnNewCacheEntry: (entry: string) => void;
  91200. /**
  91201. * Log a message to the console
  91202. * @param message defines the message to log
  91203. */
  91204. static Log(message: string): void;
  91205. /**
  91206. * Write a warning message to the console
  91207. * @param message defines the message to log
  91208. */
  91209. static Warn(message: string): void;
  91210. /**
  91211. * Write an error message to the console
  91212. * @param message defines the message to log
  91213. */
  91214. static Error(message: string): void;
  91215. /**
  91216. * Gets current log cache (list of logs)
  91217. */
  91218. static readonly LogCache: string;
  91219. /**
  91220. * Clears the log cache
  91221. */
  91222. static ClearLogCache(): void;
  91223. /**
  91224. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  91225. */
  91226. static LogLevels: number;
  91227. /**
  91228. * Checks if the loaded document was accessed via `file:`-Protocol.
  91229. * @returns boolean
  91230. */
  91231. static IsFileURL(): boolean;
  91232. /**
  91233. * Checks if the window object exists
  91234. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  91235. */
  91236. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  91237. /**
  91238. * No performance log
  91239. */
  91240. static readonly PerformanceNoneLogLevel: number;
  91241. /**
  91242. * Use user marks to log performance
  91243. */
  91244. static readonly PerformanceUserMarkLogLevel: number;
  91245. /**
  91246. * Log performance to the console
  91247. */
  91248. static readonly PerformanceConsoleLogLevel: number;
  91249. private static _performance;
  91250. /**
  91251. * Sets the current performance log level
  91252. */
  91253. static PerformanceLogLevel: number;
  91254. private static _StartPerformanceCounterDisabled;
  91255. private static _EndPerformanceCounterDisabled;
  91256. private static _StartUserMark;
  91257. private static _EndUserMark;
  91258. private static _StartPerformanceConsole;
  91259. private static _EndPerformanceConsole;
  91260. /**
  91261. * Starts a performance counter
  91262. */
  91263. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91264. /**
  91265. * Ends a specific performance coutner
  91266. */
  91267. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91268. /**
  91269. * Gets either window.performance.now() if supported or Date.now() else
  91270. */
  91271. static readonly Now: number;
  91272. /**
  91273. * This method will return the name of the class used to create the instance of the given object.
  91274. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91275. * @param object the object to get the class name from
  91276. * @param isType defines if the object is actually a type
  91277. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91278. */
  91279. static GetClassName(object: any, isType?: boolean): string;
  91280. /**
  91281. * Gets the first element of an array satisfying a given predicate
  91282. * @param array defines the array to browse
  91283. * @param predicate defines the predicate to use
  91284. * @returns null if not found or the element
  91285. */
  91286. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91287. /**
  91288. * This method will return the name of the full name of the class, including its owning module (if any).
  91289. * 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).
  91290. * @param object the object to get the class name from
  91291. * @param isType defines if the object is actually a type
  91292. * @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.
  91293. * @ignorenaming
  91294. */
  91295. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91296. /**
  91297. * Returns a promise that resolves after the given amount of time.
  91298. * @param delay Number of milliseconds to delay
  91299. * @returns Promise that resolves after the given amount of time
  91300. */
  91301. static DelayAsync(delay: number): Promise<void>;
  91302. /**
  91303. * Gets the current gradient from an array of IValueGradient
  91304. * @param ratio defines the current ratio to get
  91305. * @param gradients defines the array of IValueGradient
  91306. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91307. */
  91308. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91309. }
  91310. /**
  91311. * This class is used to track a performance counter which is number based.
  91312. * The user has access to many properties which give statistics of different nature.
  91313. *
  91314. * The implementer can track two kinds of Performance Counter: time and count.
  91315. * 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.
  91316. * 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.
  91317. */
  91318. export class PerfCounter {
  91319. /**
  91320. * Gets or sets a global boolean to turn on and off all the counters
  91321. */
  91322. static Enabled: boolean;
  91323. /**
  91324. * Returns the smallest value ever
  91325. */
  91326. readonly min: number;
  91327. /**
  91328. * Returns the biggest value ever
  91329. */
  91330. readonly max: number;
  91331. /**
  91332. * Returns the average value since the performance counter is running
  91333. */
  91334. readonly average: number;
  91335. /**
  91336. * Returns the average value of the last second the counter was monitored
  91337. */
  91338. readonly lastSecAverage: number;
  91339. /**
  91340. * Returns the current value
  91341. */
  91342. readonly current: number;
  91343. /**
  91344. * Gets the accumulated total
  91345. */
  91346. readonly total: number;
  91347. /**
  91348. * Gets the total value count
  91349. */
  91350. readonly count: number;
  91351. /**
  91352. * Creates a new counter
  91353. */
  91354. constructor();
  91355. /**
  91356. * Call this method to start monitoring a new frame.
  91357. * 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.
  91358. */
  91359. fetchNewFrame(): void;
  91360. /**
  91361. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91362. * @param newCount the count value to add to the monitored count
  91363. * @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.
  91364. */
  91365. addCount(newCount: number, fetchResult: boolean): void;
  91366. /**
  91367. * Start monitoring this performance counter
  91368. */
  91369. beginMonitoring(): void;
  91370. /**
  91371. * Compute the time lapsed since the previous beginMonitoring() call.
  91372. * @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
  91373. */
  91374. endMonitoring(newFrame?: boolean): void;
  91375. private _fetchResult;
  91376. private _startMonitoringTime;
  91377. private _min;
  91378. private _max;
  91379. private _average;
  91380. private _current;
  91381. private _totalValueCount;
  91382. private _totalAccumulated;
  91383. private _lastSecAverage;
  91384. private _lastSecAccumulated;
  91385. private _lastSecTime;
  91386. private _lastSecValueCount;
  91387. }
  91388. /**
  91389. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91390. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91391. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91392. * @param name The name of the class, case should be preserved
  91393. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91394. */
  91395. export function className(name: string, module?: string): (target: Object) => void;
  91396. /**
  91397. * An implementation of a loop for asynchronous functions.
  91398. */
  91399. export class AsyncLoop {
  91400. /**
  91401. * Defines the number of iterations for the loop
  91402. */
  91403. iterations: number;
  91404. /**
  91405. * Defines the current index of the loop.
  91406. */
  91407. index: number;
  91408. private _done;
  91409. private _fn;
  91410. private _successCallback;
  91411. /**
  91412. * Constructor.
  91413. * @param iterations the number of iterations.
  91414. * @param func the function to run each iteration
  91415. * @param successCallback the callback that will be called upon succesful execution
  91416. * @param offset starting offset.
  91417. */
  91418. constructor(
  91419. /**
  91420. * Defines the number of iterations for the loop
  91421. */
  91422. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91423. /**
  91424. * Execute the next iteration. Must be called after the last iteration was finished.
  91425. */
  91426. executeNext(): void;
  91427. /**
  91428. * Break the loop and run the success callback.
  91429. */
  91430. breakLoop(): void;
  91431. /**
  91432. * Create and run an async loop.
  91433. * @param iterations the number of iterations.
  91434. * @param fn the function to run each iteration
  91435. * @param successCallback the callback that will be called upon succesful execution
  91436. * @param offset starting offset.
  91437. * @returns the created async loop object
  91438. */
  91439. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91440. /**
  91441. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91442. * @param iterations total number of iterations
  91443. * @param syncedIterations number of synchronous iterations in each async iteration.
  91444. * @param fn the function to call each iteration.
  91445. * @param callback a success call back that will be called when iterating stops.
  91446. * @param breakFunction a break condition (optional)
  91447. * @param timeout timeout settings for the setTimeout function. default - 0.
  91448. * @returns the created async loop object
  91449. */
  91450. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91451. }
  91452. }
  91453. declare module BABYLON {
  91454. /** @hidden */
  91455. export interface ICollisionCoordinator {
  91456. createCollider(): Collider;
  91457. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91458. init(scene: Scene): void;
  91459. }
  91460. /** @hidden */
  91461. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91462. private _scene;
  91463. private _scaledPosition;
  91464. private _scaledVelocity;
  91465. private _finalPosition;
  91466. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91467. createCollider(): Collider;
  91468. init(scene: Scene): void;
  91469. private _collideWithWorld;
  91470. }
  91471. }
  91472. declare module BABYLON {
  91473. /**
  91474. * Class used to manage all inputs for the scene.
  91475. */
  91476. export class InputManager {
  91477. /** The distance in pixel that you have to move to prevent some events */
  91478. static DragMovementThreshold: number;
  91479. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91480. static LongPressDelay: number;
  91481. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91482. static DoubleClickDelay: number;
  91483. /** If you need to check double click without raising a single click at first click, enable this flag */
  91484. static ExclusiveDoubleClickMode: boolean;
  91485. private _wheelEventName;
  91486. private _onPointerMove;
  91487. private _onPointerDown;
  91488. private _onPointerUp;
  91489. private _initClickEvent;
  91490. private _initActionManager;
  91491. private _delayedSimpleClick;
  91492. private _delayedSimpleClickTimeout;
  91493. private _previousDelayedSimpleClickTimeout;
  91494. private _meshPickProceed;
  91495. private _previousButtonPressed;
  91496. private _currentPickResult;
  91497. private _previousPickResult;
  91498. private _totalPointersPressed;
  91499. private _doubleClickOccured;
  91500. private _pointerOverMesh;
  91501. private _pickedDownMesh;
  91502. private _pickedUpMesh;
  91503. private _pointerX;
  91504. private _pointerY;
  91505. private _unTranslatedPointerX;
  91506. private _unTranslatedPointerY;
  91507. private _startingPointerPosition;
  91508. private _previousStartingPointerPosition;
  91509. private _startingPointerTime;
  91510. private _previousStartingPointerTime;
  91511. private _pointerCaptures;
  91512. private _onKeyDown;
  91513. private _onKeyUp;
  91514. private _onCanvasFocusObserver;
  91515. private _onCanvasBlurObserver;
  91516. private _scene;
  91517. /**
  91518. * Creates a new InputManager
  91519. * @param scene defines the hosting scene
  91520. */
  91521. constructor(scene: Scene);
  91522. /**
  91523. * Gets the mesh that is currently under the pointer
  91524. */
  91525. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91526. /**
  91527. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  91528. */
  91529. readonly unTranslatedPointer: Vector2;
  91530. /**
  91531. * Gets or sets the current on-screen X position of the pointer
  91532. */
  91533. pointerX: number;
  91534. /**
  91535. * Gets or sets the current on-screen Y position of the pointer
  91536. */
  91537. pointerY: number;
  91538. private _updatePointerPosition;
  91539. private _processPointerMove;
  91540. private _setRayOnPointerInfo;
  91541. private _checkPrePointerObservable;
  91542. /**
  91543. * Use this method to simulate a pointer move on a mesh
  91544. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91545. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91546. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91547. */
  91548. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91549. /**
  91550. * Use this method to simulate a pointer down on a mesh
  91551. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91552. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91553. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91554. */
  91555. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91556. private _processPointerDown;
  91557. /** @hidden */
  91558. _isPointerSwiping(): boolean;
  91559. /**
  91560. * Use this method to simulate a pointer up on a mesh
  91561. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91562. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91563. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91564. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91565. */
  91566. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  91567. private _processPointerUp;
  91568. /**
  91569. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91570. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91571. * @returns true if the pointer was captured
  91572. */
  91573. isPointerCaptured(pointerId?: number): boolean;
  91574. /**
  91575. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91576. * @param attachUp defines if you want to attach events to pointerup
  91577. * @param attachDown defines if you want to attach events to pointerdown
  91578. * @param attachMove defines if you want to attach events to pointermove
  91579. */
  91580. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91581. /**
  91582. * Detaches all event handlers
  91583. */
  91584. detachControl(): void;
  91585. /**
  91586. * Force the value of meshUnderPointer
  91587. * @param mesh defines the mesh to use
  91588. */
  91589. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91590. /**
  91591. * Gets the mesh under the pointer
  91592. * @returns a Mesh or null if no mesh is under the pointer
  91593. */
  91594. getPointerOverMesh(): Nullable<AbstractMesh>;
  91595. }
  91596. }
  91597. declare module BABYLON {
  91598. /**
  91599. * This class defines the direct association between an animation and a target
  91600. */
  91601. export class TargetedAnimation {
  91602. /**
  91603. * Animation to perform
  91604. */
  91605. animation: Animation;
  91606. /**
  91607. * Target to animate
  91608. */
  91609. target: any;
  91610. }
  91611. /**
  91612. * Use this class to create coordinated animations on multiple targets
  91613. */
  91614. export class AnimationGroup implements IDisposable {
  91615. /** The name of the animation group */
  91616. name: string;
  91617. private _scene;
  91618. private _targetedAnimations;
  91619. private _animatables;
  91620. private _from;
  91621. private _to;
  91622. private _isStarted;
  91623. private _isPaused;
  91624. private _speedRatio;
  91625. /**
  91626. * Gets or sets the unique id of the node
  91627. */
  91628. uniqueId: number;
  91629. /**
  91630. * This observable will notify when one animation have ended
  91631. */
  91632. onAnimationEndObservable: Observable<TargetedAnimation>;
  91633. /**
  91634. * Observer raised when one animation loops
  91635. */
  91636. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91637. /**
  91638. * This observable will notify when all animations have ended.
  91639. */
  91640. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91641. /**
  91642. * This observable will notify when all animations have paused.
  91643. */
  91644. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91645. /**
  91646. * This observable will notify when all animations are playing.
  91647. */
  91648. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91649. /**
  91650. * Gets the first frame
  91651. */
  91652. readonly from: number;
  91653. /**
  91654. * Gets the last frame
  91655. */
  91656. readonly to: number;
  91657. /**
  91658. * Define if the animations are started
  91659. */
  91660. readonly isStarted: boolean;
  91661. /**
  91662. * Gets a value indicating that the current group is playing
  91663. */
  91664. readonly isPlaying: boolean;
  91665. /**
  91666. * Gets or sets the speed ratio to use for all animations
  91667. */
  91668. /**
  91669. * Gets or sets the speed ratio to use for all animations
  91670. */
  91671. speedRatio: number;
  91672. /**
  91673. * Gets the targeted animations for this animation group
  91674. */
  91675. readonly targetedAnimations: Array<TargetedAnimation>;
  91676. /**
  91677. * returning the list of animatables controlled by this animation group.
  91678. */
  91679. readonly animatables: Array<Animatable>;
  91680. /**
  91681. * Instantiates a new Animation Group.
  91682. * This helps managing several animations at once.
  91683. * @see http://doc.babylonjs.com/how_to/group
  91684. * @param name Defines the name of the group
  91685. * @param scene Defines the scene the group belongs to
  91686. */
  91687. constructor(
  91688. /** The name of the animation group */
  91689. name: string, scene?: Nullable<Scene>);
  91690. /**
  91691. * Add an animation (with its target) in the group
  91692. * @param animation defines the animation we want to add
  91693. * @param target defines the target of the animation
  91694. * @returns the TargetedAnimation object
  91695. */
  91696. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91697. /**
  91698. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91699. * It can add constant keys at begin or end
  91700. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91701. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91702. * @returns the animation group
  91703. */
  91704. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91705. /**
  91706. * Start all animations on given targets
  91707. * @param loop defines if animations must loop
  91708. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91709. * @param from defines the from key (optional)
  91710. * @param to defines the to key (optional)
  91711. * @returns the current animation group
  91712. */
  91713. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91714. /**
  91715. * Pause all animations
  91716. * @returns the animation group
  91717. */
  91718. pause(): AnimationGroup;
  91719. /**
  91720. * Play all animations to initial state
  91721. * This function will start() the animations if they were not started or will restart() them if they were paused
  91722. * @param loop defines if animations must loop
  91723. * @returns the animation group
  91724. */
  91725. play(loop?: boolean): AnimationGroup;
  91726. /**
  91727. * Reset all animations to initial state
  91728. * @returns the animation group
  91729. */
  91730. reset(): AnimationGroup;
  91731. /**
  91732. * Restart animations from key 0
  91733. * @returns the animation group
  91734. */
  91735. restart(): AnimationGroup;
  91736. /**
  91737. * Stop all animations
  91738. * @returns the animation group
  91739. */
  91740. stop(): AnimationGroup;
  91741. /**
  91742. * Set animation weight for all animatables
  91743. * @param weight defines the weight to use
  91744. * @return the animationGroup
  91745. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91746. */
  91747. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91748. /**
  91749. * Synchronize and normalize all animatables with a source animatable
  91750. * @param root defines the root animatable to synchronize with
  91751. * @return the animationGroup
  91752. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91753. */
  91754. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91755. /**
  91756. * Goes to a specific frame in this animation group
  91757. * @param frame the frame number to go to
  91758. * @return the animationGroup
  91759. */
  91760. goToFrame(frame: number): AnimationGroup;
  91761. /**
  91762. * Dispose all associated resources
  91763. */
  91764. dispose(): void;
  91765. private _checkAnimationGroupEnded;
  91766. /**
  91767. * Clone the current animation group and returns a copy
  91768. * @param newName defines the name of the new group
  91769. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91770. * @returns the new aniamtion group
  91771. */
  91772. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91773. /**
  91774. * Returns a new AnimationGroup object parsed from the source provided.
  91775. * @param parsedAnimationGroup defines the source
  91776. * @param scene defines the scene that will receive the animationGroup
  91777. * @returns a new AnimationGroup
  91778. */
  91779. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91780. /**
  91781. * Returns the string "AnimationGroup"
  91782. * @returns "AnimationGroup"
  91783. */
  91784. getClassName(): string;
  91785. /**
  91786. * Creates a detailled string about the object
  91787. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91788. * @returns a string representing the object
  91789. */
  91790. toString(fullDetails?: boolean): string;
  91791. }
  91792. }
  91793. declare module BABYLON {
  91794. /**
  91795. * Define an interface for all classes that will hold resources
  91796. */
  91797. export interface IDisposable {
  91798. /**
  91799. * Releases all held resources
  91800. */
  91801. dispose(): void;
  91802. }
  91803. /** Interface defining initialization parameters for Scene class */
  91804. export interface SceneOptions {
  91805. /**
  91806. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91807. * It will improve performance when the number of geometries becomes important.
  91808. */
  91809. useGeometryUniqueIdsMap?: boolean;
  91810. /**
  91811. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91812. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91813. */
  91814. useMaterialMeshMap?: boolean;
  91815. /**
  91816. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91817. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91818. */
  91819. useClonedMeshhMap?: boolean;
  91820. }
  91821. /**
  91822. * Represents a scene to be rendered by the engine.
  91823. * @see http://doc.babylonjs.com/features/scene
  91824. */
  91825. export class Scene extends AbstractScene implements IAnimatable {
  91826. private static _uniqueIdCounter;
  91827. /** The fog is deactivated */
  91828. static readonly FOGMODE_NONE: number;
  91829. /** The fog density is following an exponential function */
  91830. static readonly FOGMODE_EXP: number;
  91831. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91832. static readonly FOGMODE_EXP2: number;
  91833. /** The fog density is following a linear function. */
  91834. static readonly FOGMODE_LINEAR: number;
  91835. /**
  91836. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91837. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91838. */
  91839. static MinDeltaTime: number;
  91840. /**
  91841. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91842. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91843. */
  91844. static MaxDeltaTime: number;
  91845. /**
  91846. * Factory used to create the default material.
  91847. * @param name The name of the material to create
  91848. * @param scene The scene to create the material for
  91849. * @returns The default material
  91850. */
  91851. static DefaultMaterialFactory(scene: Scene): Material;
  91852. /**
  91853. * Factory used to create the a collision coordinator.
  91854. * @returns The collision coordinator
  91855. */
  91856. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91857. /** @hidden */
  91858. _inputManager: InputManager;
  91859. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91860. cameraToUseForPointers: Nullable<Camera>;
  91861. /** @hidden */
  91862. readonly _isScene: boolean;
  91863. /**
  91864. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91865. */
  91866. autoClear: boolean;
  91867. /**
  91868. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91869. */
  91870. autoClearDepthAndStencil: boolean;
  91871. /**
  91872. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91873. */
  91874. clearColor: Color4;
  91875. /**
  91876. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91877. */
  91878. ambientColor: Color3;
  91879. /**
  91880. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91881. * It should only be one of the following (if not the default embedded one):
  91882. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91883. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91884. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91885. * The material properties need to be setup according to the type of texture in use.
  91886. */
  91887. environmentBRDFTexture: BaseTexture;
  91888. /** @hidden */
  91889. protected _environmentTexture: Nullable<BaseTexture>;
  91890. /**
  91891. * Texture used in all pbr material as the reflection texture.
  91892. * As in the majority of the scene they are the same (exception for multi room and so on),
  91893. * this is easier to reference from here than from all the materials.
  91894. */
  91895. /**
  91896. * Texture used in all pbr material as the reflection texture.
  91897. * As in the majority of the scene they are the same (exception for multi room and so on),
  91898. * this is easier to set here than in all the materials.
  91899. */
  91900. environmentTexture: Nullable<BaseTexture>;
  91901. /** @hidden */
  91902. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91903. /**
  91904. * Default image processing configuration used either in the rendering
  91905. * Forward main pass or through the imageProcessingPostProcess if present.
  91906. * As in the majority of the scene they are the same (exception for multi camera),
  91907. * this is easier to reference from here than from all the materials and post process.
  91908. *
  91909. * No setter as we it is a shared configuration, you can set the values instead.
  91910. */
  91911. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91912. private _forceWireframe;
  91913. /**
  91914. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91915. */
  91916. forceWireframe: boolean;
  91917. private _forcePointsCloud;
  91918. /**
  91919. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91920. */
  91921. forcePointsCloud: boolean;
  91922. /**
  91923. * Gets or sets the active clipplane 1
  91924. */
  91925. clipPlane: Nullable<Plane>;
  91926. /**
  91927. * Gets or sets the active clipplane 2
  91928. */
  91929. clipPlane2: Nullable<Plane>;
  91930. /**
  91931. * Gets or sets the active clipplane 3
  91932. */
  91933. clipPlane3: Nullable<Plane>;
  91934. /**
  91935. * Gets or sets the active clipplane 4
  91936. */
  91937. clipPlane4: Nullable<Plane>;
  91938. /**
  91939. * Gets or sets a boolean indicating if animations are enabled
  91940. */
  91941. animationsEnabled: boolean;
  91942. private _animationPropertiesOverride;
  91943. /**
  91944. * Gets or sets the animation properties override
  91945. */
  91946. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91947. /**
  91948. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91949. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91950. */
  91951. useConstantAnimationDeltaTime: boolean;
  91952. /**
  91953. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91954. * Please note that it requires to run a ray cast through the scene on every frame
  91955. */
  91956. constantlyUpdateMeshUnderPointer: boolean;
  91957. /**
  91958. * Defines the HTML cursor to use when hovering over interactive elements
  91959. */
  91960. hoverCursor: string;
  91961. /**
  91962. * Defines the HTML default cursor to use (empty by default)
  91963. */
  91964. defaultCursor: string;
  91965. /**
  91966. * This is used to call preventDefault() on pointer down
  91967. * in order to block unwanted artifacts like system double clicks
  91968. */
  91969. preventDefaultOnPointerDown: boolean;
  91970. /**
  91971. * This is used to call preventDefault() on pointer up
  91972. * in order to block unwanted artifacts like system double clicks
  91973. */
  91974. preventDefaultOnPointerUp: boolean;
  91975. /**
  91976. * Gets or sets user defined metadata
  91977. */
  91978. metadata: any;
  91979. /**
  91980. * For internal use only. Please do not use.
  91981. */
  91982. reservedDataStore: any;
  91983. /**
  91984. * Gets the name of the plugin used to load this scene (null by default)
  91985. */
  91986. loadingPluginName: string;
  91987. /**
  91988. * Use this array to add regular expressions used to disable offline support for specific urls
  91989. */
  91990. disableOfflineSupportExceptionRules: RegExp[];
  91991. /**
  91992. * An event triggered when the scene is disposed.
  91993. */
  91994. onDisposeObservable: Observable<Scene>;
  91995. private _onDisposeObserver;
  91996. /** Sets a function to be executed when this scene is disposed. */
  91997. onDispose: () => void;
  91998. /**
  91999. * An event triggered before rendering the scene (right after animations and physics)
  92000. */
  92001. onBeforeRenderObservable: Observable<Scene>;
  92002. private _onBeforeRenderObserver;
  92003. /** Sets a function to be executed before rendering this scene */
  92004. beforeRender: Nullable<() => void>;
  92005. /**
  92006. * An event triggered after rendering the scene
  92007. */
  92008. onAfterRenderObservable: Observable<Scene>;
  92009. private _onAfterRenderObserver;
  92010. /** Sets a function to be executed after rendering this scene */
  92011. afterRender: Nullable<() => void>;
  92012. /**
  92013. * An event triggered before animating the scene
  92014. */
  92015. onBeforeAnimationsObservable: Observable<Scene>;
  92016. /**
  92017. * An event triggered after animations processing
  92018. */
  92019. onAfterAnimationsObservable: Observable<Scene>;
  92020. /**
  92021. * An event triggered before draw calls are ready to be sent
  92022. */
  92023. onBeforeDrawPhaseObservable: Observable<Scene>;
  92024. /**
  92025. * An event triggered after draw calls have been sent
  92026. */
  92027. onAfterDrawPhaseObservable: Observable<Scene>;
  92028. /**
  92029. * An event triggered when the scene is ready
  92030. */
  92031. onReadyObservable: Observable<Scene>;
  92032. /**
  92033. * An event triggered before rendering a camera
  92034. */
  92035. onBeforeCameraRenderObservable: Observable<Camera>;
  92036. private _onBeforeCameraRenderObserver;
  92037. /** Sets a function to be executed before rendering a camera*/
  92038. beforeCameraRender: () => void;
  92039. /**
  92040. * An event triggered after rendering a camera
  92041. */
  92042. onAfterCameraRenderObservable: Observable<Camera>;
  92043. private _onAfterCameraRenderObserver;
  92044. /** Sets a function to be executed after rendering a camera*/
  92045. afterCameraRender: () => void;
  92046. /**
  92047. * An event triggered when active meshes evaluation is about to start
  92048. */
  92049. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  92050. /**
  92051. * An event triggered when active meshes evaluation is done
  92052. */
  92053. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  92054. /**
  92055. * An event triggered when particles rendering is about to start
  92056. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92057. */
  92058. onBeforeParticlesRenderingObservable: Observable<Scene>;
  92059. /**
  92060. * An event triggered when particles rendering is done
  92061. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92062. */
  92063. onAfterParticlesRenderingObservable: Observable<Scene>;
  92064. /**
  92065. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  92066. */
  92067. onDataLoadedObservable: Observable<Scene>;
  92068. /**
  92069. * An event triggered when a camera is created
  92070. */
  92071. onNewCameraAddedObservable: Observable<Camera>;
  92072. /**
  92073. * An event triggered when a camera is removed
  92074. */
  92075. onCameraRemovedObservable: Observable<Camera>;
  92076. /**
  92077. * An event triggered when a light is created
  92078. */
  92079. onNewLightAddedObservable: Observable<Light>;
  92080. /**
  92081. * An event triggered when a light is removed
  92082. */
  92083. onLightRemovedObservable: Observable<Light>;
  92084. /**
  92085. * An event triggered when a geometry is created
  92086. */
  92087. onNewGeometryAddedObservable: Observable<Geometry>;
  92088. /**
  92089. * An event triggered when a geometry is removed
  92090. */
  92091. onGeometryRemovedObservable: Observable<Geometry>;
  92092. /**
  92093. * An event triggered when a transform node is created
  92094. */
  92095. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  92096. /**
  92097. * An event triggered when a transform node is removed
  92098. */
  92099. onTransformNodeRemovedObservable: Observable<TransformNode>;
  92100. /**
  92101. * An event triggered when a mesh is created
  92102. */
  92103. onNewMeshAddedObservable: Observable<AbstractMesh>;
  92104. /**
  92105. * An event triggered when a mesh is removed
  92106. */
  92107. onMeshRemovedObservable: Observable<AbstractMesh>;
  92108. /**
  92109. * An event triggered when a skeleton is created
  92110. */
  92111. onNewSkeletonAddedObservable: Observable<Skeleton>;
  92112. /**
  92113. * An event triggered when a skeleton is removed
  92114. */
  92115. onSkeletonRemovedObservable: Observable<Skeleton>;
  92116. /**
  92117. * An event triggered when a material is created
  92118. */
  92119. onNewMaterialAddedObservable: Observable<Material>;
  92120. /**
  92121. * An event triggered when a material is removed
  92122. */
  92123. onMaterialRemovedObservable: Observable<Material>;
  92124. /**
  92125. * An event triggered when a texture is created
  92126. */
  92127. onNewTextureAddedObservable: Observable<BaseTexture>;
  92128. /**
  92129. * An event triggered when a texture is removed
  92130. */
  92131. onTextureRemovedObservable: Observable<BaseTexture>;
  92132. /**
  92133. * An event triggered when render targets are about to be rendered
  92134. * Can happen multiple times per frame.
  92135. */
  92136. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  92137. /**
  92138. * An event triggered when render targets were rendered.
  92139. * Can happen multiple times per frame.
  92140. */
  92141. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  92142. /**
  92143. * An event triggered before calculating deterministic simulation step
  92144. */
  92145. onBeforeStepObservable: Observable<Scene>;
  92146. /**
  92147. * An event triggered after calculating deterministic simulation step
  92148. */
  92149. onAfterStepObservable: Observable<Scene>;
  92150. /**
  92151. * An event triggered when the activeCamera property is updated
  92152. */
  92153. onActiveCameraChanged: Observable<Scene>;
  92154. /**
  92155. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  92156. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92157. * 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)
  92158. */
  92159. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92160. /**
  92161. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  92162. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92163. * 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)
  92164. */
  92165. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92166. /**
  92167. * This Observable will when a mesh has been imported into the scene.
  92168. */
  92169. onMeshImportedObservable: Observable<AbstractMesh>;
  92170. /**
  92171. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  92172. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  92173. */
  92174. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  92175. /** @hidden */
  92176. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  92177. /**
  92178. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  92179. */
  92180. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  92181. /**
  92182. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  92183. */
  92184. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  92185. /**
  92186. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  92187. */
  92188. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  92189. /** Callback called when a pointer move is detected */
  92190. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92191. /** Callback called when a pointer down is detected */
  92192. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92193. /** Callback called when a pointer up is detected */
  92194. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  92195. /** Callback called when a pointer pick is detected */
  92196. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  92197. /**
  92198. * 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).
  92199. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  92200. */
  92201. onPrePointerObservable: Observable<PointerInfoPre>;
  92202. /**
  92203. * Observable event triggered each time an input event is received from the rendering canvas
  92204. */
  92205. onPointerObservable: Observable<PointerInfo>;
  92206. /**
  92207. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  92208. */
  92209. readonly unTranslatedPointer: Vector2;
  92210. /**
  92211. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  92212. */
  92213. static DragMovementThreshold: number;
  92214. /**
  92215. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  92216. */
  92217. static LongPressDelay: number;
  92218. /**
  92219. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  92220. */
  92221. static DoubleClickDelay: number;
  92222. /** If you need to check double click without raising a single click at first click, enable this flag */
  92223. static ExclusiveDoubleClickMode: boolean;
  92224. /** @hidden */
  92225. _mirroredCameraPosition: Nullable<Vector3>;
  92226. /**
  92227. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  92228. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  92229. */
  92230. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  92231. /**
  92232. * Observable event triggered each time an keyboard event is received from the hosting window
  92233. */
  92234. onKeyboardObservable: Observable<KeyboardInfo>;
  92235. private _useRightHandedSystem;
  92236. /**
  92237. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  92238. */
  92239. useRightHandedSystem: boolean;
  92240. private _timeAccumulator;
  92241. private _currentStepId;
  92242. private _currentInternalStep;
  92243. /**
  92244. * Sets the step Id used by deterministic lock step
  92245. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92246. * @param newStepId defines the step Id
  92247. */
  92248. setStepId(newStepId: number): void;
  92249. /**
  92250. * Gets the step Id used by deterministic lock step
  92251. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92252. * @returns the step Id
  92253. */
  92254. getStepId(): number;
  92255. /**
  92256. * Gets the internal step used by deterministic lock step
  92257. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92258. * @returns the internal step
  92259. */
  92260. getInternalStep(): number;
  92261. private _fogEnabled;
  92262. /**
  92263. * Gets or sets a boolean indicating if fog is enabled on this scene
  92264. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92265. * (Default is true)
  92266. */
  92267. fogEnabled: boolean;
  92268. private _fogMode;
  92269. /**
  92270. * Gets or sets the fog mode to use
  92271. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92272. * | mode | value |
  92273. * | --- | --- |
  92274. * | FOGMODE_NONE | 0 |
  92275. * | FOGMODE_EXP | 1 |
  92276. * | FOGMODE_EXP2 | 2 |
  92277. * | FOGMODE_LINEAR | 3 |
  92278. */
  92279. fogMode: number;
  92280. /**
  92281. * Gets or sets the fog color to use
  92282. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92283. * (Default is Color3(0.2, 0.2, 0.3))
  92284. */
  92285. fogColor: Color3;
  92286. /**
  92287. * Gets or sets the fog density to use
  92288. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92289. * (Default is 0.1)
  92290. */
  92291. fogDensity: number;
  92292. /**
  92293. * Gets or sets the fog start distance to use
  92294. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92295. * (Default is 0)
  92296. */
  92297. fogStart: number;
  92298. /**
  92299. * Gets or sets the fog end distance to use
  92300. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92301. * (Default is 1000)
  92302. */
  92303. fogEnd: number;
  92304. private _shadowsEnabled;
  92305. /**
  92306. * Gets or sets a boolean indicating if shadows are enabled on this scene
  92307. */
  92308. shadowsEnabled: boolean;
  92309. private _lightsEnabled;
  92310. /**
  92311. * Gets or sets a boolean indicating if lights are enabled on this scene
  92312. */
  92313. lightsEnabled: boolean;
  92314. /** All of the active cameras added to this scene. */
  92315. activeCameras: Camera[];
  92316. /** @hidden */
  92317. _activeCamera: Nullable<Camera>;
  92318. /** Gets or sets the current active camera */
  92319. activeCamera: Nullable<Camera>;
  92320. private _defaultMaterial;
  92321. /** The default material used on meshes when no material is affected */
  92322. /** The default material used on meshes when no material is affected */
  92323. defaultMaterial: Material;
  92324. private _texturesEnabled;
  92325. /**
  92326. * Gets or sets a boolean indicating if textures are enabled on this scene
  92327. */
  92328. texturesEnabled: boolean;
  92329. /**
  92330. * Gets or sets a boolean indicating if particles are enabled on this scene
  92331. */
  92332. particlesEnabled: boolean;
  92333. /**
  92334. * Gets or sets a boolean indicating if sprites are enabled on this scene
  92335. */
  92336. spritesEnabled: boolean;
  92337. private _skeletonsEnabled;
  92338. /**
  92339. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  92340. */
  92341. skeletonsEnabled: boolean;
  92342. /**
  92343. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  92344. */
  92345. lensFlaresEnabled: boolean;
  92346. /**
  92347. * Gets or sets a boolean indicating if collisions are enabled on this scene
  92348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92349. */
  92350. collisionsEnabled: boolean;
  92351. private _collisionCoordinator;
  92352. /** @hidden */
  92353. readonly collisionCoordinator: ICollisionCoordinator;
  92354. /**
  92355. * Defines the gravity applied to this scene (used only for collisions)
  92356. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92357. */
  92358. gravity: Vector3;
  92359. /**
  92360. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  92361. */
  92362. postProcessesEnabled: boolean;
  92363. /**
  92364. * The list of postprocesses added to the scene
  92365. */
  92366. postProcesses: PostProcess[];
  92367. /**
  92368. * Gets the current postprocess manager
  92369. */
  92370. postProcessManager: PostProcessManager;
  92371. /**
  92372. * Gets or sets a boolean indicating if render targets are enabled on this scene
  92373. */
  92374. renderTargetsEnabled: boolean;
  92375. /**
  92376. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92377. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92378. */
  92379. dumpNextRenderTargets: boolean;
  92380. /**
  92381. * The list of user defined render targets added to the scene
  92382. */
  92383. customRenderTargets: RenderTargetTexture[];
  92384. /**
  92385. * Defines if texture loading must be delayed
  92386. * If true, textures will only be loaded when they need to be rendered
  92387. */
  92388. useDelayedTextureLoading: boolean;
  92389. /**
  92390. * Gets the list of meshes imported to the scene through SceneLoader
  92391. */
  92392. importedMeshesFiles: String[];
  92393. /**
  92394. * Gets or sets a boolean indicating if probes are enabled on this scene
  92395. */
  92396. probesEnabled: boolean;
  92397. /**
  92398. * Gets or sets the current offline provider to use to store scene data
  92399. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92400. */
  92401. offlineProvider: IOfflineProvider;
  92402. /**
  92403. * Gets or sets the action manager associated with the scene
  92404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92405. */
  92406. actionManager: AbstractActionManager;
  92407. private _meshesForIntersections;
  92408. /**
  92409. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92410. */
  92411. proceduralTexturesEnabled: boolean;
  92412. private _engine;
  92413. private _totalVertices;
  92414. /** @hidden */
  92415. _activeIndices: PerfCounter;
  92416. /** @hidden */
  92417. _activeParticles: PerfCounter;
  92418. /** @hidden */
  92419. _activeBones: PerfCounter;
  92420. private _animationRatio;
  92421. /** @hidden */
  92422. _animationTimeLast: number;
  92423. /** @hidden */
  92424. _animationTime: number;
  92425. /**
  92426. * Gets or sets a general scale for animation speed
  92427. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92428. */
  92429. animationTimeScale: number;
  92430. /** @hidden */
  92431. _cachedMaterial: Nullable<Material>;
  92432. /** @hidden */
  92433. _cachedEffect: Nullable<Effect>;
  92434. /** @hidden */
  92435. _cachedVisibility: Nullable<number>;
  92436. private _renderId;
  92437. private _frameId;
  92438. private _executeWhenReadyTimeoutId;
  92439. private _intermediateRendering;
  92440. private _viewUpdateFlag;
  92441. private _projectionUpdateFlag;
  92442. /** @hidden */
  92443. _toBeDisposed: Nullable<IDisposable>[];
  92444. private _activeRequests;
  92445. /** @hidden */
  92446. _pendingData: any[];
  92447. private _isDisposed;
  92448. /**
  92449. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92450. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92451. */
  92452. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92453. private _activeMeshes;
  92454. private _processedMaterials;
  92455. private _renderTargets;
  92456. /** @hidden */
  92457. _activeParticleSystems: SmartArray<IParticleSystem>;
  92458. private _activeSkeletons;
  92459. private _softwareSkinnedMeshes;
  92460. private _renderingManager;
  92461. /** @hidden */
  92462. _activeAnimatables: Animatable[];
  92463. private _transformMatrix;
  92464. private _sceneUbo;
  92465. /** @hidden */
  92466. _viewMatrix: Matrix;
  92467. private _projectionMatrix;
  92468. /** @hidden */
  92469. _forcedViewPosition: Nullable<Vector3>;
  92470. /** @hidden */
  92471. _frustumPlanes: Plane[];
  92472. /**
  92473. * Gets the list of frustum planes (built from the active camera)
  92474. */
  92475. readonly frustumPlanes: Plane[];
  92476. /**
  92477. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92478. * This is useful if there are more lights that the maximum simulteanous authorized
  92479. */
  92480. requireLightSorting: boolean;
  92481. /** @hidden */
  92482. readonly useMaterialMeshMap: boolean;
  92483. /** @hidden */
  92484. readonly useClonedMeshhMap: boolean;
  92485. private _externalData;
  92486. private _uid;
  92487. /**
  92488. * @hidden
  92489. * Backing store of defined scene components.
  92490. */
  92491. _components: ISceneComponent[];
  92492. /**
  92493. * @hidden
  92494. * Backing store of defined scene components.
  92495. */
  92496. _serializableComponents: ISceneSerializableComponent[];
  92497. /**
  92498. * List of components to register on the next registration step.
  92499. */
  92500. private _transientComponents;
  92501. /**
  92502. * Registers the transient components if needed.
  92503. */
  92504. private _registerTransientComponents;
  92505. /**
  92506. * @hidden
  92507. * Add a component to the scene.
  92508. * Note that the ccomponent could be registered on th next frame if this is called after
  92509. * the register component stage.
  92510. * @param component Defines the component to add to the scene
  92511. */
  92512. _addComponent(component: ISceneComponent): void;
  92513. /**
  92514. * @hidden
  92515. * Gets a component from the scene.
  92516. * @param name defines the name of the component to retrieve
  92517. * @returns the component or null if not present
  92518. */
  92519. _getComponent(name: string): Nullable<ISceneComponent>;
  92520. /**
  92521. * @hidden
  92522. * Defines the actions happening before camera updates.
  92523. */
  92524. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92525. /**
  92526. * @hidden
  92527. * Defines the actions happening before clear the canvas.
  92528. */
  92529. _beforeClearStage: Stage<SimpleStageAction>;
  92530. /**
  92531. * @hidden
  92532. * Defines the actions when collecting render targets for the frame.
  92533. */
  92534. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92535. /**
  92536. * @hidden
  92537. * Defines the actions happening for one camera in the frame.
  92538. */
  92539. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92540. /**
  92541. * @hidden
  92542. * Defines the actions happening during the per mesh ready checks.
  92543. */
  92544. _isReadyForMeshStage: Stage<MeshStageAction>;
  92545. /**
  92546. * @hidden
  92547. * Defines the actions happening before evaluate active mesh checks.
  92548. */
  92549. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92550. /**
  92551. * @hidden
  92552. * Defines the actions happening during the evaluate sub mesh checks.
  92553. */
  92554. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92555. /**
  92556. * @hidden
  92557. * Defines the actions happening during the active mesh stage.
  92558. */
  92559. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92560. /**
  92561. * @hidden
  92562. * Defines the actions happening during the per camera render target step.
  92563. */
  92564. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92565. /**
  92566. * @hidden
  92567. * Defines the actions happening just before the active camera is drawing.
  92568. */
  92569. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92570. /**
  92571. * @hidden
  92572. * Defines the actions happening just before a render target is drawing.
  92573. */
  92574. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92575. /**
  92576. * @hidden
  92577. * Defines the actions happening just before a rendering group is drawing.
  92578. */
  92579. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92580. /**
  92581. * @hidden
  92582. * Defines the actions happening just before a mesh is drawing.
  92583. */
  92584. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92585. /**
  92586. * @hidden
  92587. * Defines the actions happening just after a mesh has been drawn.
  92588. */
  92589. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92590. /**
  92591. * @hidden
  92592. * Defines the actions happening just after a rendering group has been drawn.
  92593. */
  92594. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92595. /**
  92596. * @hidden
  92597. * Defines the actions happening just after the active camera has been drawn.
  92598. */
  92599. _afterCameraDrawStage: Stage<CameraStageAction>;
  92600. /**
  92601. * @hidden
  92602. * Defines the actions happening just after a render target has been drawn.
  92603. */
  92604. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92605. /**
  92606. * @hidden
  92607. * Defines the actions happening just after rendering all cameras and computing intersections.
  92608. */
  92609. _afterRenderStage: Stage<SimpleStageAction>;
  92610. /**
  92611. * @hidden
  92612. * Defines the actions happening when a pointer move event happens.
  92613. */
  92614. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92615. /**
  92616. * @hidden
  92617. * Defines the actions happening when a pointer down event happens.
  92618. */
  92619. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92620. /**
  92621. * @hidden
  92622. * Defines the actions happening when a pointer up event happens.
  92623. */
  92624. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92625. /**
  92626. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92627. */
  92628. private geometriesByUniqueId;
  92629. /**
  92630. * Creates a new Scene
  92631. * @param engine defines the engine to use to render this scene
  92632. * @param options defines the scene options
  92633. */
  92634. constructor(engine: Engine, options?: SceneOptions);
  92635. /**
  92636. * Gets a string idenfifying the name of the class
  92637. * @returns "Scene" string
  92638. */
  92639. getClassName(): string;
  92640. private _defaultMeshCandidates;
  92641. /**
  92642. * @hidden
  92643. */
  92644. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92645. private _defaultSubMeshCandidates;
  92646. /**
  92647. * @hidden
  92648. */
  92649. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92650. /**
  92651. * Sets the default candidate providers for the scene.
  92652. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92653. * and getCollidingSubMeshCandidates to their default function
  92654. */
  92655. setDefaultCandidateProviders(): void;
  92656. /**
  92657. * Gets the mesh that is currently under the pointer
  92658. */
  92659. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92660. /**
  92661. * Gets or sets the current on-screen X position of the pointer
  92662. */
  92663. pointerX: number;
  92664. /**
  92665. * Gets or sets the current on-screen Y position of the pointer
  92666. */
  92667. pointerY: number;
  92668. /**
  92669. * Gets the cached material (ie. the latest rendered one)
  92670. * @returns the cached material
  92671. */
  92672. getCachedMaterial(): Nullable<Material>;
  92673. /**
  92674. * Gets the cached effect (ie. the latest rendered one)
  92675. * @returns the cached effect
  92676. */
  92677. getCachedEffect(): Nullable<Effect>;
  92678. /**
  92679. * Gets the cached visibility state (ie. the latest rendered one)
  92680. * @returns the cached visibility state
  92681. */
  92682. getCachedVisibility(): Nullable<number>;
  92683. /**
  92684. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92685. * @param material defines the current material
  92686. * @param effect defines the current effect
  92687. * @param visibility defines the current visibility state
  92688. * @returns true if one parameter is not cached
  92689. */
  92690. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92691. /**
  92692. * Gets the engine associated with the scene
  92693. * @returns an Engine
  92694. */
  92695. getEngine(): Engine;
  92696. /**
  92697. * Gets the total number of vertices rendered per frame
  92698. * @returns the total number of vertices rendered per frame
  92699. */
  92700. getTotalVertices(): number;
  92701. /**
  92702. * Gets the performance counter for total vertices
  92703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92704. */
  92705. readonly totalVerticesPerfCounter: PerfCounter;
  92706. /**
  92707. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92708. * @returns the total number of active indices rendered per frame
  92709. */
  92710. getActiveIndices(): number;
  92711. /**
  92712. * Gets the performance counter for active indices
  92713. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92714. */
  92715. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92716. /**
  92717. * Gets the total number of active particles rendered per frame
  92718. * @returns the total number of active particles rendered per frame
  92719. */
  92720. getActiveParticles(): number;
  92721. /**
  92722. * Gets the performance counter for active particles
  92723. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92724. */
  92725. readonly activeParticlesPerfCounter: PerfCounter;
  92726. /**
  92727. * Gets the total number of active bones rendered per frame
  92728. * @returns the total number of active bones rendered per frame
  92729. */
  92730. getActiveBones(): number;
  92731. /**
  92732. * Gets the performance counter for active bones
  92733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92734. */
  92735. readonly activeBonesPerfCounter: PerfCounter;
  92736. /**
  92737. * Gets the array of active meshes
  92738. * @returns an array of AbstractMesh
  92739. */
  92740. getActiveMeshes(): SmartArray<AbstractMesh>;
  92741. /**
  92742. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92743. * @returns a number
  92744. */
  92745. getAnimationRatio(): number;
  92746. /**
  92747. * Gets an unique Id for the current render phase
  92748. * @returns a number
  92749. */
  92750. getRenderId(): number;
  92751. /**
  92752. * Gets an unique Id for the current frame
  92753. * @returns a number
  92754. */
  92755. getFrameId(): number;
  92756. /** Call this function if you want to manually increment the render Id*/
  92757. incrementRenderId(): void;
  92758. private _createUbo;
  92759. /**
  92760. * Use this method to simulate a pointer move on a mesh
  92761. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92762. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92763. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92764. * @returns the current scene
  92765. */
  92766. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92767. /**
  92768. * Use this method to simulate a pointer down on a mesh
  92769. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92770. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92771. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92772. * @returns the current scene
  92773. */
  92774. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92775. /**
  92776. * Use this method to simulate a pointer up on a mesh
  92777. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92778. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92779. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92780. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92781. * @returns the current scene
  92782. */
  92783. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92784. /**
  92785. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92786. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92787. * @returns true if the pointer was captured
  92788. */
  92789. isPointerCaptured(pointerId?: number): boolean;
  92790. /**
  92791. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92792. * @param attachUp defines if you want to attach events to pointerup
  92793. * @param attachDown defines if you want to attach events to pointerdown
  92794. * @param attachMove defines if you want to attach events to pointermove
  92795. */
  92796. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92797. /** Detaches all event handlers*/
  92798. detachControl(): void;
  92799. /**
  92800. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92801. * Delay loaded resources are not taking in account
  92802. * @return true if all required resources are ready
  92803. */
  92804. isReady(): boolean;
  92805. /** Resets all cached information relative to material (including effect and visibility) */
  92806. resetCachedMaterial(): void;
  92807. /**
  92808. * Registers a function to be called before every frame render
  92809. * @param func defines the function to register
  92810. */
  92811. registerBeforeRender(func: () => void): void;
  92812. /**
  92813. * Unregisters a function called before every frame render
  92814. * @param func defines the function to unregister
  92815. */
  92816. unregisterBeforeRender(func: () => void): void;
  92817. /**
  92818. * Registers a function to be called after every frame render
  92819. * @param func defines the function to register
  92820. */
  92821. registerAfterRender(func: () => void): void;
  92822. /**
  92823. * Unregisters a function called after every frame render
  92824. * @param func defines the function to unregister
  92825. */
  92826. unregisterAfterRender(func: () => void): void;
  92827. private _executeOnceBeforeRender;
  92828. /**
  92829. * The provided function will run before render once and will be disposed afterwards.
  92830. * A timeout delay can be provided so that the function will be executed in N ms.
  92831. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92832. * @param func The function to be executed.
  92833. * @param timeout optional delay in ms
  92834. */
  92835. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92836. /** @hidden */
  92837. _addPendingData(data: any): void;
  92838. /** @hidden */
  92839. _removePendingData(data: any): void;
  92840. /**
  92841. * Returns the number of items waiting to be loaded
  92842. * @returns the number of items waiting to be loaded
  92843. */
  92844. getWaitingItemsCount(): number;
  92845. /**
  92846. * Returns a boolean indicating if the scene is still loading data
  92847. */
  92848. readonly isLoading: boolean;
  92849. /**
  92850. * Registers a function to be executed when the scene is ready
  92851. * @param {Function} func - the function to be executed
  92852. */
  92853. executeWhenReady(func: () => void): void;
  92854. /**
  92855. * Returns a promise that resolves when the scene is ready
  92856. * @returns A promise that resolves when the scene is ready
  92857. */
  92858. whenReadyAsync(): Promise<void>;
  92859. /** @hidden */
  92860. _checkIsReady(): void;
  92861. /**
  92862. * Gets all animatable attached to the scene
  92863. */
  92864. readonly animatables: Animatable[];
  92865. /**
  92866. * Resets the last animation time frame.
  92867. * Useful to override when animations start running when loading a scene for the first time.
  92868. */
  92869. resetLastAnimationTimeFrame(): void;
  92870. /**
  92871. * Gets the current view matrix
  92872. * @returns a Matrix
  92873. */
  92874. getViewMatrix(): Matrix;
  92875. /**
  92876. * Gets the current projection matrix
  92877. * @returns a Matrix
  92878. */
  92879. getProjectionMatrix(): Matrix;
  92880. /**
  92881. * Gets the current transform matrix
  92882. * @returns a Matrix made of View * Projection
  92883. */
  92884. getTransformMatrix(): Matrix;
  92885. /**
  92886. * Sets the current transform matrix
  92887. * @param viewL defines the View matrix to use
  92888. * @param projectionL defines the Projection matrix to use
  92889. * @param viewR defines the right View matrix to use (if provided)
  92890. * @param projectionR defines the right Projection matrix to use (if provided)
  92891. */
  92892. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92893. /**
  92894. * Gets the uniform buffer used to store scene data
  92895. * @returns a UniformBuffer
  92896. */
  92897. getSceneUniformBuffer(): UniformBuffer;
  92898. /**
  92899. * Gets an unique (relatively to the current scene) Id
  92900. * @returns an unique number for the scene
  92901. */
  92902. getUniqueId(): number;
  92903. /**
  92904. * Add a mesh to the list of scene's meshes
  92905. * @param newMesh defines the mesh to add
  92906. * @param recursive if all child meshes should also be added to the scene
  92907. */
  92908. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92909. /**
  92910. * Remove a mesh for the list of scene's meshes
  92911. * @param toRemove defines the mesh to remove
  92912. * @param recursive if all child meshes should also be removed from the scene
  92913. * @returns the index where the mesh was in the mesh list
  92914. */
  92915. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92916. /**
  92917. * Add a transform node to the list of scene's transform nodes
  92918. * @param newTransformNode defines the transform node to add
  92919. */
  92920. addTransformNode(newTransformNode: TransformNode): void;
  92921. /**
  92922. * Remove a transform node for the list of scene's transform nodes
  92923. * @param toRemove defines the transform node to remove
  92924. * @returns the index where the transform node was in the transform node list
  92925. */
  92926. removeTransformNode(toRemove: TransformNode): number;
  92927. /**
  92928. * Remove a skeleton for the list of scene's skeletons
  92929. * @param toRemove defines the skeleton to remove
  92930. * @returns the index where the skeleton was in the skeleton list
  92931. */
  92932. removeSkeleton(toRemove: Skeleton): number;
  92933. /**
  92934. * Remove a morph target for the list of scene's morph targets
  92935. * @param toRemove defines the morph target to remove
  92936. * @returns the index where the morph target was in the morph target list
  92937. */
  92938. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92939. /**
  92940. * Remove a light for the list of scene's lights
  92941. * @param toRemove defines the light to remove
  92942. * @returns the index where the light was in the light list
  92943. */
  92944. removeLight(toRemove: Light): number;
  92945. /**
  92946. * Remove a camera for the list of scene's cameras
  92947. * @param toRemove defines the camera to remove
  92948. * @returns the index where the camera was in the camera list
  92949. */
  92950. removeCamera(toRemove: Camera): number;
  92951. /**
  92952. * Remove a particle system for the list of scene's particle systems
  92953. * @param toRemove defines the particle system to remove
  92954. * @returns the index where the particle system was in the particle system list
  92955. */
  92956. removeParticleSystem(toRemove: IParticleSystem): number;
  92957. /**
  92958. * Remove a animation for the list of scene's animations
  92959. * @param toRemove defines the animation to remove
  92960. * @returns the index where the animation was in the animation list
  92961. */
  92962. removeAnimation(toRemove: Animation): number;
  92963. /**
  92964. * Will stop the animation of the given target
  92965. * @param target - the target
  92966. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  92967. * @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)
  92968. */
  92969. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  92970. /**
  92971. * Removes the given animation group from this scene.
  92972. * @param toRemove The animation group to remove
  92973. * @returns The index of the removed animation group
  92974. */
  92975. removeAnimationGroup(toRemove: AnimationGroup): number;
  92976. /**
  92977. * Removes the given multi-material from this scene.
  92978. * @param toRemove The multi-material to remove
  92979. * @returns The index of the removed multi-material
  92980. */
  92981. removeMultiMaterial(toRemove: MultiMaterial): number;
  92982. /**
  92983. * Removes the given material from this scene.
  92984. * @param toRemove The material to remove
  92985. * @returns The index of the removed material
  92986. */
  92987. removeMaterial(toRemove: Material): number;
  92988. /**
  92989. * Removes the given action manager from this scene.
  92990. * @param toRemove The action manager to remove
  92991. * @returns The index of the removed action manager
  92992. */
  92993. removeActionManager(toRemove: AbstractActionManager): number;
  92994. /**
  92995. * Removes the given texture from this scene.
  92996. * @param toRemove The texture to remove
  92997. * @returns The index of the removed texture
  92998. */
  92999. removeTexture(toRemove: BaseTexture): number;
  93000. /**
  93001. * Adds the given light to this scene
  93002. * @param newLight The light to add
  93003. */
  93004. addLight(newLight: Light): void;
  93005. /**
  93006. * Sorts the list list based on light priorities
  93007. */
  93008. sortLightsByPriority(): void;
  93009. /**
  93010. * Adds the given camera to this scene
  93011. * @param newCamera The camera to add
  93012. */
  93013. addCamera(newCamera: Camera): void;
  93014. /**
  93015. * Adds the given skeleton to this scene
  93016. * @param newSkeleton The skeleton to add
  93017. */
  93018. addSkeleton(newSkeleton: Skeleton): void;
  93019. /**
  93020. * Adds the given particle system to this scene
  93021. * @param newParticleSystem The particle system to add
  93022. */
  93023. addParticleSystem(newParticleSystem: IParticleSystem): void;
  93024. /**
  93025. * Adds the given animation to this scene
  93026. * @param newAnimation The animation to add
  93027. */
  93028. addAnimation(newAnimation: Animation): void;
  93029. /**
  93030. * Adds the given animation group to this scene.
  93031. * @param newAnimationGroup The animation group to add
  93032. */
  93033. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  93034. /**
  93035. * Adds the given multi-material to this scene
  93036. * @param newMultiMaterial The multi-material to add
  93037. */
  93038. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  93039. /**
  93040. * Adds the given material to this scene
  93041. * @param newMaterial The material to add
  93042. */
  93043. addMaterial(newMaterial: Material): void;
  93044. /**
  93045. * Adds the given morph target to this scene
  93046. * @param newMorphTargetManager The morph target to add
  93047. */
  93048. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  93049. /**
  93050. * Adds the given geometry to this scene
  93051. * @param newGeometry The geometry to add
  93052. */
  93053. addGeometry(newGeometry: Geometry): void;
  93054. /**
  93055. * Adds the given action manager to this scene
  93056. * @param newActionManager The action manager to add
  93057. */
  93058. addActionManager(newActionManager: AbstractActionManager): void;
  93059. /**
  93060. * Adds the given texture to this scene.
  93061. * @param newTexture The texture to add
  93062. */
  93063. addTexture(newTexture: BaseTexture): void;
  93064. /**
  93065. * Switch active camera
  93066. * @param newCamera defines the new active camera
  93067. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  93068. */
  93069. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  93070. /**
  93071. * sets the active camera of the scene using its ID
  93072. * @param id defines the camera's ID
  93073. * @return the new active camera or null if none found.
  93074. */
  93075. setActiveCameraByID(id: string): Nullable<Camera>;
  93076. /**
  93077. * sets the active camera of the scene using its name
  93078. * @param name defines the camera's name
  93079. * @returns the new active camera or null if none found.
  93080. */
  93081. setActiveCameraByName(name: string): Nullable<Camera>;
  93082. /**
  93083. * get an animation group using its name
  93084. * @param name defines the material's name
  93085. * @return the animation group or null if none found.
  93086. */
  93087. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  93088. /**
  93089. * Get a material using its unique id
  93090. * @param uniqueId defines the material's unique id
  93091. * @return the material or null if none found.
  93092. */
  93093. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  93094. /**
  93095. * get a material using its id
  93096. * @param id defines the material's ID
  93097. * @return the material or null if none found.
  93098. */
  93099. getMaterialByID(id: string): Nullable<Material>;
  93100. /**
  93101. * Gets a material using its name
  93102. * @param name defines the material's name
  93103. * @return the material or null if none found.
  93104. */
  93105. getMaterialByName(name: string): Nullable<Material>;
  93106. /**
  93107. * Gets a camera using its id
  93108. * @param id defines the id to look for
  93109. * @returns the camera or null if not found
  93110. */
  93111. getCameraByID(id: string): Nullable<Camera>;
  93112. /**
  93113. * Gets a camera using its unique id
  93114. * @param uniqueId defines the unique id to look for
  93115. * @returns the camera or null if not found
  93116. */
  93117. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  93118. /**
  93119. * Gets a camera using its name
  93120. * @param name defines the camera's name
  93121. * @return the camera or null if none found.
  93122. */
  93123. getCameraByName(name: string): Nullable<Camera>;
  93124. /**
  93125. * Gets a bone using its id
  93126. * @param id defines the bone's id
  93127. * @return the bone or null if not found
  93128. */
  93129. getBoneByID(id: string): Nullable<Bone>;
  93130. /**
  93131. * Gets a bone using its id
  93132. * @param name defines the bone's name
  93133. * @return the bone or null if not found
  93134. */
  93135. getBoneByName(name: string): Nullable<Bone>;
  93136. /**
  93137. * Gets a light node using its name
  93138. * @param name defines the the light's name
  93139. * @return the light or null if none found.
  93140. */
  93141. getLightByName(name: string): Nullable<Light>;
  93142. /**
  93143. * Gets a light node using its id
  93144. * @param id defines the light's id
  93145. * @return the light or null if none found.
  93146. */
  93147. getLightByID(id: string): Nullable<Light>;
  93148. /**
  93149. * Gets a light node using its scene-generated unique ID
  93150. * @param uniqueId defines the light's unique id
  93151. * @return the light or null if none found.
  93152. */
  93153. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  93154. /**
  93155. * Gets a particle system by id
  93156. * @param id defines the particle system id
  93157. * @return the corresponding system or null if none found
  93158. */
  93159. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  93160. /**
  93161. * Gets a geometry using its ID
  93162. * @param id defines the geometry's id
  93163. * @return the geometry or null if none found.
  93164. */
  93165. getGeometryByID(id: string): Nullable<Geometry>;
  93166. private _getGeometryByUniqueID;
  93167. /**
  93168. * Add a new geometry to this scene
  93169. * @param geometry defines the geometry to be added to the scene.
  93170. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  93171. * @return a boolean defining if the geometry was added or not
  93172. */
  93173. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  93174. /**
  93175. * Removes an existing geometry
  93176. * @param geometry defines the geometry to be removed from the scene
  93177. * @return a boolean defining if the geometry was removed or not
  93178. */
  93179. removeGeometry(geometry: Geometry): boolean;
  93180. /**
  93181. * Gets the list of geometries attached to the scene
  93182. * @returns an array of Geometry
  93183. */
  93184. getGeometries(): Geometry[];
  93185. /**
  93186. * Gets the first added mesh found of a given ID
  93187. * @param id defines the id to search for
  93188. * @return the mesh found or null if not found at all
  93189. */
  93190. getMeshByID(id: string): Nullable<AbstractMesh>;
  93191. /**
  93192. * Gets a list of meshes using their id
  93193. * @param id defines the id to search for
  93194. * @returns a list of meshes
  93195. */
  93196. getMeshesByID(id: string): Array<AbstractMesh>;
  93197. /**
  93198. * Gets the first added transform node found of a given ID
  93199. * @param id defines the id to search for
  93200. * @return the found transform node or null if not found at all.
  93201. */
  93202. getTransformNodeByID(id: string): Nullable<TransformNode>;
  93203. /**
  93204. * Gets a transform node with its auto-generated unique id
  93205. * @param uniqueId efines the unique id to search for
  93206. * @return the found transform node or null if not found at all.
  93207. */
  93208. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  93209. /**
  93210. * Gets a list of transform nodes using their id
  93211. * @param id defines the id to search for
  93212. * @returns a list of transform nodes
  93213. */
  93214. getTransformNodesByID(id: string): Array<TransformNode>;
  93215. /**
  93216. * Gets a mesh with its auto-generated unique id
  93217. * @param uniqueId defines the unique id to search for
  93218. * @return the found mesh or null if not found at all.
  93219. */
  93220. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  93221. /**
  93222. * Gets a the last added mesh using a given id
  93223. * @param id defines the id to search for
  93224. * @return the found mesh or null if not found at all.
  93225. */
  93226. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  93227. /**
  93228. * Gets a the last added node (Mesh, Camera, Light) using a given id
  93229. * @param id defines the id to search for
  93230. * @return the found node or null if not found at all
  93231. */
  93232. getLastEntryByID(id: string): Nullable<Node>;
  93233. /**
  93234. * Gets a node (Mesh, Camera, Light) using a given id
  93235. * @param id defines the id to search for
  93236. * @return the found node or null if not found at all
  93237. */
  93238. getNodeByID(id: string): Nullable<Node>;
  93239. /**
  93240. * Gets a node (Mesh, Camera, Light) using a given name
  93241. * @param name defines the name to search for
  93242. * @return the found node or null if not found at all.
  93243. */
  93244. getNodeByName(name: string): Nullable<Node>;
  93245. /**
  93246. * Gets a mesh using a given name
  93247. * @param name defines the name to search for
  93248. * @return the found mesh or null if not found at all.
  93249. */
  93250. getMeshByName(name: string): Nullable<AbstractMesh>;
  93251. /**
  93252. * Gets a transform node using a given name
  93253. * @param name defines the name to search for
  93254. * @return the found transform node or null if not found at all.
  93255. */
  93256. getTransformNodeByName(name: string): Nullable<TransformNode>;
  93257. /**
  93258. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  93259. * @param id defines the id to search for
  93260. * @return the found skeleton or null if not found at all.
  93261. */
  93262. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  93263. /**
  93264. * Gets a skeleton using a given auto generated unique id
  93265. * @param uniqueId defines the unique id to search for
  93266. * @return the found skeleton or null if not found at all.
  93267. */
  93268. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  93269. /**
  93270. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  93271. * @param id defines the id to search for
  93272. * @return the found skeleton or null if not found at all.
  93273. */
  93274. getSkeletonById(id: string): Nullable<Skeleton>;
  93275. /**
  93276. * Gets a skeleton using a given name
  93277. * @param name defines the name to search for
  93278. * @return the found skeleton or null if not found at all.
  93279. */
  93280. getSkeletonByName(name: string): Nullable<Skeleton>;
  93281. /**
  93282. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  93283. * @param id defines the id to search for
  93284. * @return the found morph target manager or null if not found at all.
  93285. */
  93286. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  93287. /**
  93288. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  93289. * @param id defines the id to search for
  93290. * @return the found morph target or null if not found at all.
  93291. */
  93292. getMorphTargetById(id: string): Nullable<MorphTarget>;
  93293. /**
  93294. * Gets a boolean indicating if the given mesh is active
  93295. * @param mesh defines the mesh to look for
  93296. * @returns true if the mesh is in the active list
  93297. */
  93298. isActiveMesh(mesh: AbstractMesh): boolean;
  93299. /**
  93300. * Return a unique id as a string which can serve as an identifier for the scene
  93301. */
  93302. readonly uid: string;
  93303. /**
  93304. * Add an externaly attached data from its key.
  93305. * This method call will fail and return false, if such key already exists.
  93306. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  93307. * @param key the unique key that identifies the data
  93308. * @param data the data object to associate to the key for this Engine instance
  93309. * @return true if no such key were already present and the data was added successfully, false otherwise
  93310. */
  93311. addExternalData<T>(key: string, data: T): boolean;
  93312. /**
  93313. * Get an externaly attached data from its key
  93314. * @param key the unique key that identifies the data
  93315. * @return the associated data, if present (can be null), or undefined if not present
  93316. */
  93317. getExternalData<T>(key: string): Nullable<T>;
  93318. /**
  93319. * Get an externaly attached data from its key, create it using a factory if it's not already present
  93320. * @param key the unique key that identifies the data
  93321. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  93322. * @return the associated data, can be null if the factory returned null.
  93323. */
  93324. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  93325. /**
  93326. * Remove an externaly attached data from the Engine instance
  93327. * @param key the unique key that identifies the data
  93328. * @return true if the data was successfully removed, false if it doesn't exist
  93329. */
  93330. removeExternalData(key: string): boolean;
  93331. private _evaluateSubMesh;
  93332. /**
  93333. * Clear the processed materials smart array preventing retention point in material dispose.
  93334. */
  93335. freeProcessedMaterials(): void;
  93336. private _preventFreeActiveMeshesAndRenderingGroups;
  93337. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  93338. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  93339. * when disposing several meshes in a row or a hierarchy of meshes.
  93340. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  93341. */
  93342. blockfreeActiveMeshesAndRenderingGroups: boolean;
  93343. /**
  93344. * Clear the active meshes smart array preventing retention point in mesh dispose.
  93345. */
  93346. freeActiveMeshes(): void;
  93347. /**
  93348. * Clear the info related to rendering groups preventing retention points during dispose.
  93349. */
  93350. freeRenderingGroups(): void;
  93351. /** @hidden */
  93352. _isInIntermediateRendering(): boolean;
  93353. /**
  93354. * Lambda returning the list of potentially active meshes.
  93355. */
  93356. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  93357. /**
  93358. * Lambda returning the list of potentially active sub meshes.
  93359. */
  93360. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  93361. /**
  93362. * Lambda returning the list of potentially intersecting sub meshes.
  93363. */
  93364. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  93365. /**
  93366. * Lambda returning the list of potentially colliding sub meshes.
  93367. */
  93368. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  93369. private _activeMeshesFrozen;
  93370. /**
  93371. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93372. * @returns the current scene
  93373. */
  93374. freezeActiveMeshes(): Scene;
  93375. /**
  93376. * Use this function to restart evaluating active meshes on every frame
  93377. * @returns the current scene
  93378. */
  93379. unfreezeActiveMeshes(): Scene;
  93380. private _evaluateActiveMeshes;
  93381. private _activeMesh;
  93382. /**
  93383. * Update the transform matrix to update from the current active camera
  93384. * @param force defines a boolean used to force the update even if cache is up to date
  93385. */
  93386. updateTransformMatrix(force?: boolean): void;
  93387. private _bindFrameBuffer;
  93388. /** @hidden */
  93389. _allowPostProcessClearColor: boolean;
  93390. /** @hidden */
  93391. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93392. private _processSubCameras;
  93393. private _checkIntersections;
  93394. /** @hidden */
  93395. _advancePhysicsEngineStep(step: number): void;
  93396. /**
  93397. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93398. */
  93399. getDeterministicFrameTime: () => number;
  93400. /** @hidden */
  93401. _animate(): void;
  93402. /** Execute all animations (for a frame) */
  93403. animate(): void;
  93404. /**
  93405. * Render the scene
  93406. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93407. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93408. */
  93409. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93410. /**
  93411. * Freeze all materials
  93412. * A frozen material will not be updatable but should be faster to render
  93413. */
  93414. freezeMaterials(): void;
  93415. /**
  93416. * Unfreeze all materials
  93417. * A frozen material will not be updatable but should be faster to render
  93418. */
  93419. unfreezeMaterials(): void;
  93420. /**
  93421. * Releases all held ressources
  93422. */
  93423. dispose(): void;
  93424. /**
  93425. * Gets if the scene is already disposed
  93426. */
  93427. readonly isDisposed: boolean;
  93428. /**
  93429. * Call this function to reduce memory footprint of the scene.
  93430. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93431. */
  93432. clearCachedVertexData(): void;
  93433. /**
  93434. * This function will remove the local cached buffer data from texture.
  93435. * It will save memory but will prevent the texture from being rebuilt
  93436. */
  93437. cleanCachedTextureBuffer(): void;
  93438. /**
  93439. * Get the world extend vectors with an optional filter
  93440. *
  93441. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93442. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93443. */
  93444. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93445. min: Vector3;
  93446. max: Vector3;
  93447. };
  93448. /**
  93449. * Creates a ray that can be used to pick in the scene
  93450. * @param x defines the x coordinate of the origin (on-screen)
  93451. * @param y defines the y coordinate of the origin (on-screen)
  93452. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93453. * @param camera defines the camera to use for the picking
  93454. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93455. * @returns a Ray
  93456. */
  93457. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93458. /**
  93459. * Creates a ray that can be used to pick in the scene
  93460. * @param x defines the x coordinate of the origin (on-screen)
  93461. * @param y defines the y coordinate of the origin (on-screen)
  93462. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93463. * @param result defines the ray where to store the picking ray
  93464. * @param camera defines the camera to use for the picking
  93465. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93466. * @returns the current scene
  93467. */
  93468. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93469. /**
  93470. * Creates a ray that can be used to pick in the scene
  93471. * @param x defines the x coordinate of the origin (on-screen)
  93472. * @param y defines the y coordinate of the origin (on-screen)
  93473. * @param camera defines the camera to use for the picking
  93474. * @returns a Ray
  93475. */
  93476. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93477. /**
  93478. * Creates a ray that can be used to pick in the scene
  93479. * @param x defines the x coordinate of the origin (on-screen)
  93480. * @param y defines the y coordinate of the origin (on-screen)
  93481. * @param result defines the ray where to store the picking ray
  93482. * @param camera defines the camera to use for the picking
  93483. * @returns the current scene
  93484. */
  93485. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93486. /** Launch a ray to try to pick a mesh in the scene
  93487. * @param x position on screen
  93488. * @param y position on screen
  93489. * @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
  93490. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93491. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93492. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93493. * @returns a PickingInfo
  93494. */
  93495. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93496. /** Use the given ray to pick a mesh in the scene
  93497. * @param ray The ray to use to pick meshes
  93498. * @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
  93499. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93500. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93501. * @returns a PickingInfo
  93502. */
  93503. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93504. /**
  93505. * Launch a ray to try to pick a mesh in the scene
  93506. * @param x X position on screen
  93507. * @param y Y position on screen
  93508. * @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
  93509. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93510. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93511. * @returns an array of PickingInfo
  93512. */
  93513. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93514. /**
  93515. * Launch a ray to try to pick a mesh in the scene
  93516. * @param ray Ray to use
  93517. * @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
  93518. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93519. * @returns an array of PickingInfo
  93520. */
  93521. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93522. /**
  93523. * Force the value of meshUnderPointer
  93524. * @param mesh defines the mesh to use
  93525. */
  93526. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93527. /**
  93528. * Gets the mesh under the pointer
  93529. * @returns a Mesh or null if no mesh is under the pointer
  93530. */
  93531. getPointerOverMesh(): Nullable<AbstractMesh>;
  93532. /** @hidden */
  93533. _rebuildGeometries(): void;
  93534. /** @hidden */
  93535. _rebuildTextures(): void;
  93536. private _getByTags;
  93537. /**
  93538. * Get a list of meshes by tags
  93539. * @param tagsQuery defines the tags query to use
  93540. * @param forEach defines a predicate used to filter results
  93541. * @returns an array of Mesh
  93542. */
  93543. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93544. /**
  93545. * Get a list of cameras by tags
  93546. * @param tagsQuery defines the tags query to use
  93547. * @param forEach defines a predicate used to filter results
  93548. * @returns an array of Camera
  93549. */
  93550. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93551. /**
  93552. * Get a list of lights by tags
  93553. * @param tagsQuery defines the tags query to use
  93554. * @param forEach defines a predicate used to filter results
  93555. * @returns an array of Light
  93556. */
  93557. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93558. /**
  93559. * Get a list of materials by tags
  93560. * @param tagsQuery defines the tags query to use
  93561. * @param forEach defines a predicate used to filter results
  93562. * @returns an array of Material
  93563. */
  93564. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93565. /**
  93566. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93567. * This allowed control for front to back rendering or reversly depending of the special needs.
  93568. *
  93569. * @param renderingGroupId The rendering group id corresponding to its index
  93570. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93571. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93572. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93573. */
  93574. 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;
  93575. /**
  93576. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93577. *
  93578. * @param renderingGroupId The rendering group id corresponding to its index
  93579. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93580. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93581. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93582. */
  93583. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93584. /**
  93585. * Gets the current auto clear configuration for one rendering group of the rendering
  93586. * manager.
  93587. * @param index the rendering group index to get the information for
  93588. * @returns The auto clear setup for the requested rendering group
  93589. */
  93590. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93591. private _blockMaterialDirtyMechanism;
  93592. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93593. blockMaterialDirtyMechanism: boolean;
  93594. /**
  93595. * Will flag all materials as dirty to trigger new shader compilation
  93596. * @param flag defines the flag used to specify which material part must be marked as dirty
  93597. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93598. */
  93599. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93600. /** @hidden */
  93601. _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;
  93602. /** @hidden */
  93603. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93604. }
  93605. }
  93606. declare module BABYLON {
  93607. /**
  93608. * Set of assets to keep when moving a scene into an asset container.
  93609. */
  93610. export class KeepAssets extends AbstractScene {
  93611. }
  93612. /**
  93613. * Container with a set of assets that can be added or removed from a scene.
  93614. */
  93615. export class AssetContainer extends AbstractScene {
  93616. /**
  93617. * The scene the AssetContainer belongs to.
  93618. */
  93619. scene: Scene;
  93620. /**
  93621. * Instantiates an AssetContainer.
  93622. * @param scene The scene the AssetContainer belongs to.
  93623. */
  93624. constructor(scene: Scene);
  93625. /**
  93626. * Adds all the assets from the container to the scene.
  93627. */
  93628. addAllToScene(): void;
  93629. /**
  93630. * Removes all the assets in the container from the scene
  93631. */
  93632. removeAllFromScene(): void;
  93633. /**
  93634. * Disposes all the assets in the container
  93635. */
  93636. dispose(): void;
  93637. private _moveAssets;
  93638. /**
  93639. * Removes all the assets contained in the scene and adds them to the container.
  93640. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93641. */
  93642. moveAllFromScene(keepAssets?: KeepAssets): void;
  93643. /**
  93644. * 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.
  93645. * @returns the root mesh
  93646. */
  93647. createRootMesh(): Mesh;
  93648. }
  93649. }
  93650. declare module BABYLON {
  93651. /**
  93652. * Defines how the parser contract is defined.
  93653. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93654. */
  93655. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93656. /**
  93657. * Defines how the individual parser contract is defined.
  93658. * These parser can parse an individual asset
  93659. */
  93660. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93661. /**
  93662. * Base class of the scene acting as a container for the different elements composing a scene.
  93663. * This class is dynamically extended by the different components of the scene increasing
  93664. * flexibility and reducing coupling
  93665. */
  93666. export abstract class AbstractScene {
  93667. /**
  93668. * Stores the list of available parsers in the application.
  93669. */
  93670. private static _BabylonFileParsers;
  93671. /**
  93672. * Stores the list of available individual parsers in the application.
  93673. */
  93674. private static _IndividualBabylonFileParsers;
  93675. /**
  93676. * Adds a parser in the list of available ones
  93677. * @param name Defines the name of the parser
  93678. * @param parser Defines the parser to add
  93679. */
  93680. static AddParser(name: string, parser: BabylonFileParser): void;
  93681. /**
  93682. * Gets a general parser from the list of avaialble ones
  93683. * @param name Defines the name of the parser
  93684. * @returns the requested parser or null
  93685. */
  93686. static GetParser(name: string): Nullable<BabylonFileParser>;
  93687. /**
  93688. * Adds n individual parser in the list of available ones
  93689. * @param name Defines the name of the parser
  93690. * @param parser Defines the parser to add
  93691. */
  93692. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93693. /**
  93694. * Gets an individual parser from the list of avaialble ones
  93695. * @param name Defines the name of the parser
  93696. * @returns the requested parser or null
  93697. */
  93698. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93699. /**
  93700. * Parser json data and populate both a scene and its associated container object
  93701. * @param jsonData Defines the data to parse
  93702. * @param scene Defines the scene to parse the data for
  93703. * @param container Defines the container attached to the parsing sequence
  93704. * @param rootUrl Defines the root url of the data
  93705. */
  93706. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93707. /**
  93708. * Gets the list of root nodes (ie. nodes with no parent)
  93709. */
  93710. rootNodes: Node[];
  93711. /** All of the cameras added to this scene
  93712. * @see http://doc.babylonjs.com/babylon101/cameras
  93713. */
  93714. cameras: Camera[];
  93715. /**
  93716. * All of the lights added to this scene
  93717. * @see http://doc.babylonjs.com/babylon101/lights
  93718. */
  93719. lights: Light[];
  93720. /**
  93721. * All of the (abstract) meshes added to this scene
  93722. */
  93723. meshes: AbstractMesh[];
  93724. /**
  93725. * The list of skeletons added to the scene
  93726. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93727. */
  93728. skeletons: Skeleton[];
  93729. /**
  93730. * All of the particle systems added to this scene
  93731. * @see http://doc.babylonjs.com/babylon101/particles
  93732. */
  93733. particleSystems: IParticleSystem[];
  93734. /**
  93735. * Gets a list of Animations associated with the scene
  93736. */
  93737. animations: Animation[];
  93738. /**
  93739. * All of the animation groups added to this scene
  93740. * @see http://doc.babylonjs.com/how_to/group
  93741. */
  93742. animationGroups: AnimationGroup[];
  93743. /**
  93744. * All of the multi-materials added to this scene
  93745. * @see http://doc.babylonjs.com/how_to/multi_materials
  93746. */
  93747. multiMaterials: MultiMaterial[];
  93748. /**
  93749. * All of the materials added to this scene
  93750. * In the context of a Scene, it is not supposed to be modified manually.
  93751. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93752. * Note also that the order of the Material wihin the array is not significant and might change.
  93753. * @see http://doc.babylonjs.com/babylon101/materials
  93754. */
  93755. materials: Material[];
  93756. /**
  93757. * The list of morph target managers added to the scene
  93758. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93759. */
  93760. morphTargetManagers: MorphTargetManager[];
  93761. /**
  93762. * The list of geometries used in the scene.
  93763. */
  93764. geometries: Geometry[];
  93765. /**
  93766. * All of the tranform nodes added to this scene
  93767. * In the context of a Scene, it is not supposed to be modified manually.
  93768. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93769. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93770. * @see http://doc.babylonjs.com/how_to/transformnode
  93771. */
  93772. transformNodes: TransformNode[];
  93773. /**
  93774. * ActionManagers available on the scene.
  93775. */
  93776. actionManagers: AbstractActionManager[];
  93777. /**
  93778. * Textures to keep.
  93779. */
  93780. textures: BaseTexture[];
  93781. /**
  93782. * Environment texture for the scene
  93783. */
  93784. environmentTexture: Nullable<BaseTexture>;
  93785. }
  93786. }
  93787. declare module BABYLON {
  93788. /**
  93789. * Defines a sound that can be played in the application.
  93790. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93792. */
  93793. export class Sound {
  93794. /**
  93795. * The name of the sound in the scene.
  93796. */
  93797. name: string;
  93798. /**
  93799. * Does the sound autoplay once loaded.
  93800. */
  93801. autoplay: boolean;
  93802. /**
  93803. * Does the sound loop after it finishes playing once.
  93804. */
  93805. loop: boolean;
  93806. /**
  93807. * Does the sound use a custom attenuation curve to simulate the falloff
  93808. * happening when the source gets further away from the camera.
  93809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93810. */
  93811. useCustomAttenuation: boolean;
  93812. /**
  93813. * The sound track id this sound belongs to.
  93814. */
  93815. soundTrackId: number;
  93816. /**
  93817. * Is this sound currently played.
  93818. */
  93819. isPlaying: boolean;
  93820. /**
  93821. * Is this sound currently paused.
  93822. */
  93823. isPaused: boolean;
  93824. /**
  93825. * Does this sound enables spatial sound.
  93826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93827. */
  93828. spatialSound: boolean;
  93829. /**
  93830. * Define the reference distance the sound should be heard perfectly.
  93831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93832. */
  93833. refDistance: number;
  93834. /**
  93835. * Define the roll off factor of spatial sounds.
  93836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93837. */
  93838. rolloffFactor: number;
  93839. /**
  93840. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93842. */
  93843. maxDistance: number;
  93844. /**
  93845. * Define the distance attenuation model the sound will follow.
  93846. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93847. */
  93848. distanceModel: string;
  93849. /**
  93850. * @hidden
  93851. * Back Compat
  93852. **/
  93853. onended: () => any;
  93854. /**
  93855. * Observable event when the current playing sound finishes.
  93856. */
  93857. onEndedObservable: Observable<Sound>;
  93858. private _panningModel;
  93859. private _playbackRate;
  93860. private _streaming;
  93861. private _startTime;
  93862. private _startOffset;
  93863. private _position;
  93864. /** @hidden */
  93865. _positionInEmitterSpace: boolean;
  93866. private _localDirection;
  93867. private _volume;
  93868. private _isReadyToPlay;
  93869. private _isDirectional;
  93870. private _readyToPlayCallback;
  93871. private _audioBuffer;
  93872. private _soundSource;
  93873. private _streamingSource;
  93874. private _soundPanner;
  93875. private _soundGain;
  93876. private _inputAudioNode;
  93877. private _outputAudioNode;
  93878. private _coneInnerAngle;
  93879. private _coneOuterAngle;
  93880. private _coneOuterGain;
  93881. private _scene;
  93882. private _connectedTransformNode;
  93883. private _customAttenuationFunction;
  93884. private _registerFunc;
  93885. private _isOutputConnected;
  93886. private _htmlAudioElement;
  93887. private _urlType;
  93888. /** @hidden */
  93889. static _SceneComponentInitialization: (scene: Scene) => void;
  93890. /**
  93891. * Create a sound and attach it to a scene
  93892. * @param name Name of your sound
  93893. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93894. * @param scene defines the scene the sound belongs to
  93895. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93896. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93897. */
  93898. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93899. /**
  93900. * Release the sound and its associated resources
  93901. */
  93902. dispose(): void;
  93903. /**
  93904. * Gets if the sounds is ready to be played or not.
  93905. * @returns true if ready, otherwise false
  93906. */
  93907. isReady(): boolean;
  93908. private _soundLoaded;
  93909. /**
  93910. * Sets the data of the sound from an audiobuffer
  93911. * @param audioBuffer The audioBuffer containing the data
  93912. */
  93913. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93914. /**
  93915. * Updates the current sounds options such as maxdistance, loop...
  93916. * @param options A JSON object containing values named as the object properties
  93917. */
  93918. updateOptions(options: any): void;
  93919. private _createSpatialParameters;
  93920. private _updateSpatialParameters;
  93921. /**
  93922. * Switch the panning model to HRTF:
  93923. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93925. */
  93926. switchPanningModelToHRTF(): void;
  93927. /**
  93928. * Switch the panning model to Equal Power:
  93929. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93931. */
  93932. switchPanningModelToEqualPower(): void;
  93933. private _switchPanningModel;
  93934. /**
  93935. * Connect this sound to a sound track audio node like gain...
  93936. * @param soundTrackAudioNode the sound track audio node to connect to
  93937. */
  93938. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93939. /**
  93940. * Transform this sound into a directional source
  93941. * @param coneInnerAngle Size of the inner cone in degree
  93942. * @param coneOuterAngle Size of the outer cone in degree
  93943. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93944. */
  93945. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93946. /**
  93947. * Gets or sets the inner angle for the directional cone.
  93948. */
  93949. /**
  93950. * Gets or sets the inner angle for the directional cone.
  93951. */
  93952. directionalConeInnerAngle: number;
  93953. /**
  93954. * Gets or sets the outer angle for the directional cone.
  93955. */
  93956. /**
  93957. * Gets or sets the outer angle for the directional cone.
  93958. */
  93959. directionalConeOuterAngle: number;
  93960. /**
  93961. * Sets the position of the emitter if spatial sound is enabled
  93962. * @param newPosition Defines the new posisiton
  93963. */
  93964. setPosition(newPosition: Vector3): void;
  93965. /**
  93966. * Sets the local direction of the emitter if spatial sound is enabled
  93967. * @param newLocalDirection Defines the new local direction
  93968. */
  93969. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93970. private _updateDirection;
  93971. /** @hidden */
  93972. updateDistanceFromListener(): void;
  93973. /**
  93974. * Sets a new custom attenuation function for the sound.
  93975. * @param callback Defines the function used for the attenuation
  93976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93977. */
  93978. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93979. /**
  93980. * Play the sound
  93981. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93982. * @param offset (optional) Start the sound setting it at a specific time
  93983. */
  93984. play(time?: number, offset?: number): void;
  93985. private _onended;
  93986. /**
  93987. * Stop the sound
  93988. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93989. */
  93990. stop(time?: number): void;
  93991. /**
  93992. * Put the sound in pause
  93993. */
  93994. pause(): void;
  93995. /**
  93996. * Sets a dedicated volume for this sounds
  93997. * @param newVolume Define the new volume of the sound
  93998. * @param time Define in how long the sound should be at this value
  93999. */
  94000. setVolume(newVolume: number, time?: number): void;
  94001. /**
  94002. * Set the sound play back rate
  94003. * @param newPlaybackRate Define the playback rate the sound should be played at
  94004. */
  94005. setPlaybackRate(newPlaybackRate: number): void;
  94006. /**
  94007. * Gets the volume of the sound.
  94008. * @returns the volume of the sound
  94009. */
  94010. getVolume(): number;
  94011. /**
  94012. * Attach the sound to a dedicated mesh
  94013. * @param transformNode The transform node to connect the sound with
  94014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94015. */
  94016. attachToMesh(transformNode: TransformNode): void;
  94017. /**
  94018. * Detach the sound from the previously attached mesh
  94019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94020. */
  94021. detachFromMesh(): void;
  94022. private _onRegisterAfterWorldMatrixUpdate;
  94023. /**
  94024. * Clone the current sound in the scene.
  94025. * @returns the new sound clone
  94026. */
  94027. clone(): Nullable<Sound>;
  94028. /**
  94029. * Gets the current underlying audio buffer containing the data
  94030. * @returns the audio buffer
  94031. */
  94032. getAudioBuffer(): Nullable<AudioBuffer>;
  94033. /**
  94034. * Serializes the Sound in a JSON representation
  94035. * @returns the JSON representation of the sound
  94036. */
  94037. serialize(): any;
  94038. /**
  94039. * Parse a JSON representation of a sound to innstantiate in a given scene
  94040. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  94041. * @param scene Define the scene the new parsed sound should be created in
  94042. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  94043. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  94044. * @returns the newly parsed sound
  94045. */
  94046. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  94047. }
  94048. }
  94049. declare module BABYLON {
  94050. /**
  94051. * This defines an action helpful to play a defined sound on a triggered action.
  94052. */
  94053. export class PlaySoundAction extends Action {
  94054. private _sound;
  94055. /**
  94056. * Instantiate the action
  94057. * @param triggerOptions defines the trigger options
  94058. * @param sound defines the sound to play
  94059. * @param condition defines the trigger related conditions
  94060. */
  94061. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94062. /** @hidden */
  94063. _prepare(): void;
  94064. /**
  94065. * Execute the action and play the sound.
  94066. */
  94067. execute(): void;
  94068. /**
  94069. * Serializes the actions and its related information.
  94070. * @param parent defines the object to serialize in
  94071. * @returns the serialized object
  94072. */
  94073. serialize(parent: any): any;
  94074. }
  94075. /**
  94076. * This defines an action helpful to stop a defined sound on a triggered action.
  94077. */
  94078. export class StopSoundAction extends Action {
  94079. private _sound;
  94080. /**
  94081. * Instantiate the action
  94082. * @param triggerOptions defines the trigger options
  94083. * @param sound defines the sound to stop
  94084. * @param condition defines the trigger related conditions
  94085. */
  94086. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94087. /** @hidden */
  94088. _prepare(): void;
  94089. /**
  94090. * Execute the action and stop the sound.
  94091. */
  94092. execute(): void;
  94093. /**
  94094. * Serializes the actions and its related information.
  94095. * @param parent defines the object to serialize in
  94096. * @returns the serialized object
  94097. */
  94098. serialize(parent: any): any;
  94099. }
  94100. }
  94101. declare module BABYLON {
  94102. /**
  94103. * This defines an action responsible to change the value of a property
  94104. * by interpolating between its current value and the newly set one once triggered.
  94105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94106. */
  94107. export class InterpolateValueAction extends Action {
  94108. /**
  94109. * Defines the path of the property where the value should be interpolated
  94110. */
  94111. propertyPath: string;
  94112. /**
  94113. * Defines the target value at the end of the interpolation.
  94114. */
  94115. value: any;
  94116. /**
  94117. * Defines the time it will take for the property to interpolate to the value.
  94118. */
  94119. duration: number;
  94120. /**
  94121. * Defines if the other scene animations should be stopped when the action has been triggered
  94122. */
  94123. stopOtherAnimations?: boolean;
  94124. /**
  94125. * Defines a callback raised once the interpolation animation has been done.
  94126. */
  94127. onInterpolationDone?: () => void;
  94128. /**
  94129. * Observable triggered once the interpolation animation has been done.
  94130. */
  94131. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  94132. private _target;
  94133. private _effectiveTarget;
  94134. private _property;
  94135. /**
  94136. * Instantiate the action
  94137. * @param triggerOptions defines the trigger options
  94138. * @param target defines the object containing the value to interpolate
  94139. * @param propertyPath defines the path to the property in the target object
  94140. * @param value defines the target value at the end of the interpolation
  94141. * @param duration deines the time it will take for the property to interpolate to the value.
  94142. * @param condition defines the trigger related conditions
  94143. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  94144. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  94145. */
  94146. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  94147. /** @hidden */
  94148. _prepare(): void;
  94149. /**
  94150. * Execute the action starts the value interpolation.
  94151. */
  94152. execute(): void;
  94153. /**
  94154. * Serializes the actions and its related information.
  94155. * @param parent defines the object to serialize in
  94156. * @returns the serialized object
  94157. */
  94158. serialize(parent: any): any;
  94159. }
  94160. }
  94161. declare module BABYLON {
  94162. /**
  94163. * Options allowed during the creation of a sound track.
  94164. */
  94165. export interface ISoundTrackOptions {
  94166. /**
  94167. * The volume the sound track should take during creation
  94168. */
  94169. volume?: number;
  94170. /**
  94171. * Define if the sound track is the main sound track of the scene
  94172. */
  94173. mainTrack?: boolean;
  94174. }
  94175. /**
  94176. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  94177. * It will be also used in a future release to apply effects on a specific track.
  94178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94179. */
  94180. export class SoundTrack {
  94181. /**
  94182. * The unique identifier of the sound track in the scene.
  94183. */
  94184. id: number;
  94185. /**
  94186. * The list of sounds included in the sound track.
  94187. */
  94188. soundCollection: Array<Sound>;
  94189. private _outputAudioNode;
  94190. private _scene;
  94191. private _isMainTrack;
  94192. private _connectedAnalyser;
  94193. private _options;
  94194. private _isInitialized;
  94195. /**
  94196. * Creates a new sound track.
  94197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94198. * @param scene Define the scene the sound track belongs to
  94199. * @param options
  94200. */
  94201. constructor(scene: Scene, options?: ISoundTrackOptions);
  94202. private _initializeSoundTrackAudioGraph;
  94203. /**
  94204. * Release the sound track and its associated resources
  94205. */
  94206. dispose(): void;
  94207. /**
  94208. * Adds a sound to this sound track
  94209. * @param sound define the cound to add
  94210. * @ignoreNaming
  94211. */
  94212. AddSound(sound: Sound): void;
  94213. /**
  94214. * Removes a sound to this sound track
  94215. * @param sound define the cound to remove
  94216. * @ignoreNaming
  94217. */
  94218. RemoveSound(sound: Sound): void;
  94219. /**
  94220. * Set a global volume for the full sound track.
  94221. * @param newVolume Define the new volume of the sound track
  94222. */
  94223. setVolume(newVolume: number): void;
  94224. /**
  94225. * Switch the panning model to HRTF:
  94226. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94228. */
  94229. switchPanningModelToHRTF(): void;
  94230. /**
  94231. * Switch the panning model to Equal Power:
  94232. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94234. */
  94235. switchPanningModelToEqualPower(): void;
  94236. /**
  94237. * Connect the sound track to an audio analyser allowing some amazing
  94238. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94240. * @param analyser The analyser to connect to the engine
  94241. */
  94242. connectToAnalyser(analyser: Analyser): void;
  94243. }
  94244. }
  94245. declare module BABYLON {
  94246. interface AbstractScene {
  94247. /**
  94248. * The list of sounds used in the scene.
  94249. */
  94250. sounds: Nullable<Array<Sound>>;
  94251. }
  94252. interface Scene {
  94253. /**
  94254. * @hidden
  94255. * Backing field
  94256. */
  94257. _mainSoundTrack: SoundTrack;
  94258. /**
  94259. * The main sound track played by the scene.
  94260. * It cotains your primary collection of sounds.
  94261. */
  94262. mainSoundTrack: SoundTrack;
  94263. /**
  94264. * The list of sound tracks added to the scene
  94265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94266. */
  94267. soundTracks: Nullable<Array<SoundTrack>>;
  94268. /**
  94269. * Gets a sound using a given name
  94270. * @param name defines the name to search for
  94271. * @return the found sound or null if not found at all.
  94272. */
  94273. getSoundByName(name: string): Nullable<Sound>;
  94274. /**
  94275. * Gets or sets if audio support is enabled
  94276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94277. */
  94278. audioEnabled: boolean;
  94279. /**
  94280. * Gets or sets if audio will be output to headphones
  94281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94282. */
  94283. headphone: boolean;
  94284. }
  94285. /**
  94286. * Defines the sound scene component responsible to manage any sounds
  94287. * in a given scene.
  94288. */
  94289. export class AudioSceneComponent implements ISceneSerializableComponent {
  94290. /**
  94291. * The component name helpfull to identify the component in the list of scene components.
  94292. */
  94293. readonly name: string;
  94294. /**
  94295. * The scene the component belongs to.
  94296. */
  94297. scene: Scene;
  94298. private _audioEnabled;
  94299. /**
  94300. * Gets whether audio is enabled or not.
  94301. * Please use related enable/disable method to switch state.
  94302. */
  94303. readonly audioEnabled: boolean;
  94304. private _headphone;
  94305. /**
  94306. * Gets whether audio is outputing to headphone or not.
  94307. * Please use the according Switch methods to change output.
  94308. */
  94309. readonly headphone: boolean;
  94310. /**
  94311. * Creates a new instance of the component for the given scene
  94312. * @param scene Defines the scene to register the component in
  94313. */
  94314. constructor(scene: Scene);
  94315. /**
  94316. * Registers the component in a given scene
  94317. */
  94318. register(): void;
  94319. /**
  94320. * Rebuilds the elements related to this component in case of
  94321. * context lost for instance.
  94322. */
  94323. rebuild(): void;
  94324. /**
  94325. * Serializes the component data to the specified json object
  94326. * @param serializationObject The object to serialize to
  94327. */
  94328. serialize(serializationObject: any): void;
  94329. /**
  94330. * Adds all the element from the container to the scene
  94331. * @param container the container holding the elements
  94332. */
  94333. addFromContainer(container: AbstractScene): void;
  94334. /**
  94335. * Removes all the elements in the container from the scene
  94336. * @param container contains the elements to remove
  94337. * @param dispose if the removed element should be disposed (default: false)
  94338. */
  94339. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  94340. /**
  94341. * Disposes the component and the associated ressources.
  94342. */
  94343. dispose(): void;
  94344. /**
  94345. * Disables audio in the associated scene.
  94346. */
  94347. disableAudio(): void;
  94348. /**
  94349. * Enables audio in the associated scene.
  94350. */
  94351. enableAudio(): void;
  94352. /**
  94353. * Switch audio to headphone output.
  94354. */
  94355. switchAudioModeForHeadphones(): void;
  94356. /**
  94357. * Switch audio to normal speakers.
  94358. */
  94359. switchAudioModeForNormalSpeakers(): void;
  94360. private _afterRender;
  94361. }
  94362. }
  94363. declare module BABYLON {
  94364. /**
  94365. * Wraps one or more Sound objects and selects one with random weight for playback.
  94366. */
  94367. export class WeightedSound {
  94368. /** When true a Sound will be selected and played when the current playing Sound completes. */
  94369. loop: boolean;
  94370. private _coneInnerAngle;
  94371. private _coneOuterAngle;
  94372. private _volume;
  94373. /** A Sound is currently playing. */
  94374. isPlaying: boolean;
  94375. /** A Sound is currently paused. */
  94376. isPaused: boolean;
  94377. private _sounds;
  94378. private _weights;
  94379. private _currentIndex?;
  94380. /**
  94381. * Creates a new WeightedSound from the list of sounds given.
  94382. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94383. * @param sounds Array of Sounds that will be selected from.
  94384. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94385. */
  94386. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94387. /**
  94388. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94389. */
  94390. /**
  94391. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94392. */
  94393. directionalConeInnerAngle: number;
  94394. /**
  94395. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94396. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94397. */
  94398. /**
  94399. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94400. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94401. */
  94402. directionalConeOuterAngle: number;
  94403. /**
  94404. * Playback volume.
  94405. */
  94406. /**
  94407. * Playback volume.
  94408. */
  94409. volume: number;
  94410. private _onended;
  94411. /**
  94412. * Suspend playback
  94413. */
  94414. pause(): void;
  94415. /**
  94416. * Stop playback
  94417. */
  94418. stop(): void;
  94419. /**
  94420. * Start playback.
  94421. * @param startOffset Position the clip head at a specific time in seconds.
  94422. */
  94423. play(startOffset?: number): void;
  94424. }
  94425. }
  94426. declare module BABYLON {
  94427. /**
  94428. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94429. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94430. */
  94431. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94432. /**
  94433. * Gets the name of the behavior.
  94434. */
  94435. readonly name: string;
  94436. /**
  94437. * The easing function used by animations
  94438. */
  94439. static EasingFunction: BackEase;
  94440. /**
  94441. * The easing mode used by animations
  94442. */
  94443. static EasingMode: number;
  94444. /**
  94445. * The duration of the animation, in milliseconds
  94446. */
  94447. transitionDuration: number;
  94448. /**
  94449. * Length of the distance animated by the transition when lower radius is reached
  94450. */
  94451. lowerRadiusTransitionRange: number;
  94452. /**
  94453. * Length of the distance animated by the transition when upper radius is reached
  94454. */
  94455. upperRadiusTransitionRange: number;
  94456. private _autoTransitionRange;
  94457. /**
  94458. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94459. */
  94460. /**
  94461. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94462. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94463. */
  94464. autoTransitionRange: boolean;
  94465. private _attachedCamera;
  94466. private _onAfterCheckInputsObserver;
  94467. private _onMeshTargetChangedObserver;
  94468. /**
  94469. * Initializes the behavior.
  94470. */
  94471. init(): void;
  94472. /**
  94473. * Attaches the behavior to its arc rotate camera.
  94474. * @param camera Defines the camera to attach the behavior to
  94475. */
  94476. attach(camera: ArcRotateCamera): void;
  94477. /**
  94478. * Detaches the behavior from its current arc rotate camera.
  94479. */
  94480. detach(): void;
  94481. private _radiusIsAnimating;
  94482. private _radiusBounceTransition;
  94483. private _animatables;
  94484. private _cachedWheelPrecision;
  94485. /**
  94486. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94487. * @param radiusLimit The limit to check against.
  94488. * @return Bool to indicate if at limit.
  94489. */
  94490. private _isRadiusAtLimit;
  94491. /**
  94492. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94493. * @param radiusDelta The delta by which to animate to. Can be negative.
  94494. */
  94495. private _applyBoundRadiusAnimation;
  94496. /**
  94497. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94498. */
  94499. protected _clearAnimationLocks(): void;
  94500. /**
  94501. * Stops and removes all animations that have been applied to the camera
  94502. */
  94503. stopAllAnimations(): void;
  94504. }
  94505. }
  94506. declare module BABYLON {
  94507. /**
  94508. * 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.
  94509. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94510. */
  94511. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94512. /**
  94513. * Gets the name of the behavior.
  94514. */
  94515. readonly name: string;
  94516. private _mode;
  94517. private _radiusScale;
  94518. private _positionScale;
  94519. private _defaultElevation;
  94520. private _elevationReturnTime;
  94521. private _elevationReturnWaitTime;
  94522. private _zoomStopsAnimation;
  94523. private _framingTime;
  94524. /**
  94525. * The easing function used by animations
  94526. */
  94527. static EasingFunction: ExponentialEase;
  94528. /**
  94529. * The easing mode used by animations
  94530. */
  94531. static EasingMode: number;
  94532. /**
  94533. * Sets the current mode used by the behavior
  94534. */
  94535. /**
  94536. * Gets current mode used by the behavior.
  94537. */
  94538. mode: number;
  94539. /**
  94540. * Sets the scale applied to the radius (1 by default)
  94541. */
  94542. /**
  94543. * Gets the scale applied to the radius
  94544. */
  94545. radiusScale: number;
  94546. /**
  94547. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94548. */
  94549. /**
  94550. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94551. */
  94552. positionScale: number;
  94553. /**
  94554. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94555. * behaviour is triggered, in radians.
  94556. */
  94557. /**
  94558. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94559. * behaviour is triggered, in radians.
  94560. */
  94561. defaultElevation: number;
  94562. /**
  94563. * Sets the time (in milliseconds) taken to return to the default beta position.
  94564. * Negative value indicates camera should not return to default.
  94565. */
  94566. /**
  94567. * Gets the time (in milliseconds) taken to return to the default beta position.
  94568. * Negative value indicates camera should not return to default.
  94569. */
  94570. elevationReturnTime: number;
  94571. /**
  94572. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94573. */
  94574. /**
  94575. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94576. */
  94577. elevationReturnWaitTime: number;
  94578. /**
  94579. * Sets the flag that indicates if user zooming should stop animation.
  94580. */
  94581. /**
  94582. * Gets the flag that indicates if user zooming should stop animation.
  94583. */
  94584. zoomStopsAnimation: boolean;
  94585. /**
  94586. * Sets the transition time when framing the mesh, in milliseconds
  94587. */
  94588. /**
  94589. * Gets the transition time when framing the mesh, in milliseconds
  94590. */
  94591. framingTime: number;
  94592. /**
  94593. * Define if the behavior should automatically change the configured
  94594. * camera limits and sensibilities.
  94595. */
  94596. autoCorrectCameraLimitsAndSensibility: boolean;
  94597. private _onPrePointerObservableObserver;
  94598. private _onAfterCheckInputsObserver;
  94599. private _onMeshTargetChangedObserver;
  94600. private _attachedCamera;
  94601. private _isPointerDown;
  94602. private _lastInteractionTime;
  94603. /**
  94604. * Initializes the behavior.
  94605. */
  94606. init(): void;
  94607. /**
  94608. * Attaches the behavior to its arc rotate camera.
  94609. * @param camera Defines the camera to attach the behavior to
  94610. */
  94611. attach(camera: ArcRotateCamera): void;
  94612. /**
  94613. * Detaches the behavior from its current arc rotate camera.
  94614. */
  94615. detach(): void;
  94616. private _animatables;
  94617. private _betaIsAnimating;
  94618. private _betaTransition;
  94619. private _radiusTransition;
  94620. private _vectorTransition;
  94621. /**
  94622. * Targets the given mesh and updates zoom level accordingly.
  94623. * @param mesh The mesh to target.
  94624. * @param radius Optional. If a cached radius position already exists, overrides default.
  94625. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94626. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94627. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94628. */
  94629. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94630. /**
  94631. * Targets the given mesh with its children and updates zoom level accordingly.
  94632. * @param mesh The mesh to target.
  94633. * @param radius Optional. If a cached radius position already exists, overrides default.
  94634. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94635. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94636. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94637. */
  94638. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94639. /**
  94640. * Targets the given meshes with their children and updates zoom level accordingly.
  94641. * @param meshes The mesh to target.
  94642. * @param radius Optional. If a cached radius position already exists, overrides default.
  94643. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94644. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94645. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94646. */
  94647. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94648. /**
  94649. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94650. * @param minimumWorld Determines the smaller position of the bounding box extend
  94651. * @param maximumWorld Determines the bigger position of the bounding box extend
  94652. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94653. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94654. */
  94655. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94656. /**
  94657. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94658. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94659. * frustum width.
  94660. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94661. * to fully enclose the mesh in the viewing frustum.
  94662. */
  94663. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94664. /**
  94665. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94666. * is automatically returned to its default position (expected to be above ground plane).
  94667. */
  94668. private _maintainCameraAboveGround;
  94669. /**
  94670. * Returns the frustum slope based on the canvas ratio and camera FOV
  94671. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94672. */
  94673. private _getFrustumSlope;
  94674. /**
  94675. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94676. */
  94677. private _clearAnimationLocks;
  94678. /**
  94679. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94680. */
  94681. private _applyUserInteraction;
  94682. /**
  94683. * Stops and removes all animations that have been applied to the camera
  94684. */
  94685. stopAllAnimations(): void;
  94686. /**
  94687. * Gets a value indicating if the user is moving the camera
  94688. */
  94689. readonly isUserIsMoving: boolean;
  94690. /**
  94691. * The camera can move all the way towards the mesh.
  94692. */
  94693. static IgnoreBoundsSizeMode: number;
  94694. /**
  94695. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94696. */
  94697. static FitFrustumSidesMode: number;
  94698. }
  94699. }
  94700. declare module BABYLON {
  94701. /**
  94702. * Base class for Camera Pointer Inputs.
  94703. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94704. * for example usage.
  94705. */
  94706. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94707. /**
  94708. * Defines the camera the input is attached to.
  94709. */
  94710. abstract camera: Camera;
  94711. /**
  94712. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94713. */
  94714. protected _altKey: boolean;
  94715. protected _ctrlKey: boolean;
  94716. protected _metaKey: boolean;
  94717. protected _shiftKey: boolean;
  94718. /**
  94719. * Which mouse buttons were pressed at time of last mouse event.
  94720. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94721. */
  94722. protected _buttonsPressed: number;
  94723. /**
  94724. * Defines the buttons associated with the input to handle camera move.
  94725. */
  94726. buttons: number[];
  94727. /**
  94728. * Attach the input controls to a specific dom element to get the input from.
  94729. * @param element Defines the element the controls should be listened from
  94730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94731. */
  94732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94733. /**
  94734. * Detach the current controls from the specified dom element.
  94735. * @param element Defines the element to stop listening the inputs from
  94736. */
  94737. detachControl(element: Nullable<HTMLElement>): void;
  94738. /**
  94739. * Gets the class name of the current input.
  94740. * @returns the class name
  94741. */
  94742. getClassName(): string;
  94743. /**
  94744. * Get the friendly name associated with the input class.
  94745. * @returns the input friendly name
  94746. */
  94747. getSimpleName(): string;
  94748. /**
  94749. * Called on pointer POINTERDOUBLETAP event.
  94750. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94751. */
  94752. protected onDoubleTap(type: string): void;
  94753. /**
  94754. * Called on pointer POINTERMOVE event if only a single touch is active.
  94755. * Override this method to provide functionality.
  94756. */
  94757. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94758. /**
  94759. * Called on pointer POINTERMOVE event if multiple touches are active.
  94760. * Override this method to provide functionality.
  94761. */
  94762. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94763. /**
  94764. * Called on JS contextmenu event.
  94765. * Override this method to provide functionality.
  94766. */
  94767. protected onContextMenu(evt: PointerEvent): void;
  94768. /**
  94769. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94770. * press.
  94771. * Override this method to provide functionality.
  94772. */
  94773. protected onButtonDown(evt: PointerEvent): void;
  94774. /**
  94775. * Called each time a new POINTERUP event occurs. Ie, for each button
  94776. * release.
  94777. * Override this method to provide functionality.
  94778. */
  94779. protected onButtonUp(evt: PointerEvent): void;
  94780. /**
  94781. * Called when window becomes inactive.
  94782. * Override this method to provide functionality.
  94783. */
  94784. protected onLostFocus(): void;
  94785. private _pointerInput;
  94786. private _observer;
  94787. private _onLostFocus;
  94788. private pointA;
  94789. private pointB;
  94790. }
  94791. }
  94792. declare module BABYLON {
  94793. /**
  94794. * Manage the pointers inputs to control an arc rotate camera.
  94795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94796. */
  94797. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94798. /**
  94799. * Defines the camera the input is attached to.
  94800. */
  94801. camera: ArcRotateCamera;
  94802. /**
  94803. * Gets the class name of the current input.
  94804. * @returns the class name
  94805. */
  94806. getClassName(): string;
  94807. /**
  94808. * Defines the buttons associated with the input to handle camera move.
  94809. */
  94810. buttons: number[];
  94811. /**
  94812. * Defines the pointer angular sensibility along the X axis or how fast is
  94813. * the camera rotating.
  94814. */
  94815. angularSensibilityX: number;
  94816. /**
  94817. * Defines the pointer angular sensibility along the Y axis or how fast is
  94818. * the camera rotating.
  94819. */
  94820. angularSensibilityY: number;
  94821. /**
  94822. * Defines the pointer pinch precision or how fast is the camera zooming.
  94823. */
  94824. pinchPrecision: number;
  94825. /**
  94826. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94827. * from 0.
  94828. * It defines the percentage of current camera.radius to use as delta when
  94829. * pinch zoom is used.
  94830. */
  94831. pinchDeltaPercentage: number;
  94832. /**
  94833. * Defines the pointer panning sensibility or how fast is the camera moving.
  94834. */
  94835. panningSensibility: number;
  94836. /**
  94837. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94838. */
  94839. multiTouchPanning: boolean;
  94840. /**
  94841. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94842. * zoom (pinch) through multitouch.
  94843. */
  94844. multiTouchPanAndZoom: boolean;
  94845. /**
  94846. * Revers pinch action direction.
  94847. */
  94848. pinchInwards: boolean;
  94849. private _isPanClick;
  94850. private _twoFingerActivityCount;
  94851. private _isPinching;
  94852. /**
  94853. * Called on pointer POINTERMOVE event if only a single touch is active.
  94854. */
  94855. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94856. /**
  94857. * Called on pointer POINTERDOUBLETAP event.
  94858. */
  94859. protected onDoubleTap(type: string): void;
  94860. /**
  94861. * Called on pointer POINTERMOVE event if multiple touches are active.
  94862. */
  94863. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94864. /**
  94865. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94866. * press.
  94867. */
  94868. protected onButtonDown(evt: PointerEvent): void;
  94869. /**
  94870. * Called each time a new POINTERUP event occurs. Ie, for each button
  94871. * release.
  94872. */
  94873. protected onButtonUp(evt: PointerEvent): void;
  94874. /**
  94875. * Called when window becomes inactive.
  94876. */
  94877. protected onLostFocus(): void;
  94878. }
  94879. }
  94880. declare module BABYLON {
  94881. /**
  94882. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94884. */
  94885. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94886. /**
  94887. * Defines the camera the input is attached to.
  94888. */
  94889. camera: ArcRotateCamera;
  94890. /**
  94891. * Defines the list of key codes associated with the up action (increase alpha)
  94892. */
  94893. keysUp: number[];
  94894. /**
  94895. * Defines the list of key codes associated with the down action (decrease alpha)
  94896. */
  94897. keysDown: number[];
  94898. /**
  94899. * Defines the list of key codes associated with the left action (increase beta)
  94900. */
  94901. keysLeft: number[];
  94902. /**
  94903. * Defines the list of key codes associated with the right action (decrease beta)
  94904. */
  94905. keysRight: number[];
  94906. /**
  94907. * Defines the list of key codes associated with the reset action.
  94908. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94909. */
  94910. keysReset: number[];
  94911. /**
  94912. * Defines the panning sensibility of the inputs.
  94913. * (How fast is the camera paning)
  94914. */
  94915. panningSensibility: number;
  94916. /**
  94917. * Defines the zooming sensibility of the inputs.
  94918. * (How fast is the camera zooming)
  94919. */
  94920. zoomingSensibility: number;
  94921. /**
  94922. * Defines wether maintaining the alt key down switch the movement mode from
  94923. * orientation to zoom.
  94924. */
  94925. useAltToZoom: boolean;
  94926. /**
  94927. * Rotation speed of the camera
  94928. */
  94929. angularSpeed: number;
  94930. private _keys;
  94931. private _ctrlPressed;
  94932. private _altPressed;
  94933. private _onCanvasBlurObserver;
  94934. private _onKeyboardObserver;
  94935. private _engine;
  94936. private _scene;
  94937. /**
  94938. * Attach the input controls to a specific dom element to get the input from.
  94939. * @param element Defines the element the controls should be listened from
  94940. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94941. */
  94942. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94943. /**
  94944. * Detach the current controls from the specified dom element.
  94945. * @param element Defines the element to stop listening the inputs from
  94946. */
  94947. detachControl(element: Nullable<HTMLElement>): void;
  94948. /**
  94949. * Update the current camera state depending on the inputs that have been used this frame.
  94950. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94951. */
  94952. checkInputs(): void;
  94953. /**
  94954. * Gets the class name of the current intput.
  94955. * @returns the class name
  94956. */
  94957. getClassName(): string;
  94958. /**
  94959. * Get the friendly name associated with the input class.
  94960. * @returns the input friendly name
  94961. */
  94962. getSimpleName(): string;
  94963. }
  94964. }
  94965. declare module BABYLON {
  94966. /**
  94967. * Manage the mouse wheel inputs to control an arc rotate camera.
  94968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94969. */
  94970. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94971. /**
  94972. * Defines the camera the input is attached to.
  94973. */
  94974. camera: ArcRotateCamera;
  94975. /**
  94976. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94977. */
  94978. wheelPrecision: number;
  94979. /**
  94980. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94981. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94982. */
  94983. wheelDeltaPercentage: number;
  94984. private _wheel;
  94985. private _observer;
  94986. private computeDeltaFromMouseWheelLegacyEvent;
  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. * Gets the class name of the current intput.
  95000. * @returns the class name
  95001. */
  95002. getClassName(): string;
  95003. /**
  95004. * Get the friendly name associated with the input class.
  95005. * @returns the input friendly name
  95006. */
  95007. getSimpleName(): string;
  95008. }
  95009. }
  95010. declare module BABYLON {
  95011. /**
  95012. * Default Inputs manager for the ArcRotateCamera.
  95013. * It groups all the default supported inputs for ease of use.
  95014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95015. */
  95016. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  95017. /**
  95018. * Instantiates a new ArcRotateCameraInputsManager.
  95019. * @param camera Defines the camera the inputs belong to
  95020. */
  95021. constructor(camera: ArcRotateCamera);
  95022. /**
  95023. * Add mouse wheel input support to the input manager.
  95024. * @returns the current input manager
  95025. */
  95026. addMouseWheel(): ArcRotateCameraInputsManager;
  95027. /**
  95028. * Add pointers input support to the input manager.
  95029. * @returns the current input manager
  95030. */
  95031. addPointers(): ArcRotateCameraInputsManager;
  95032. /**
  95033. * Add keyboard input support to the input manager.
  95034. * @returns the current input manager
  95035. */
  95036. addKeyboard(): ArcRotateCameraInputsManager;
  95037. }
  95038. }
  95039. declare module BABYLON {
  95040. /**
  95041. * This represents an orbital type of camera.
  95042. *
  95043. * 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.
  95044. * 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.
  95045. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  95046. */
  95047. export class ArcRotateCamera extends TargetCamera {
  95048. /**
  95049. * Defines the rotation angle of the camera along the longitudinal axis.
  95050. */
  95051. alpha: number;
  95052. /**
  95053. * Defines the rotation angle of the camera along the latitudinal axis.
  95054. */
  95055. beta: number;
  95056. /**
  95057. * Defines the radius of the camera from it s target point.
  95058. */
  95059. radius: number;
  95060. protected _target: Vector3;
  95061. protected _targetHost: Nullable<AbstractMesh>;
  95062. /**
  95063. * Defines the target point of the camera.
  95064. * The camera looks towards it form the radius distance.
  95065. */
  95066. target: Vector3;
  95067. /**
  95068. * Define the current local position of the camera in the scene
  95069. */
  95070. position: Vector3;
  95071. protected _upVector: Vector3;
  95072. protected _upToYMatrix: Matrix;
  95073. protected _YToUpMatrix: Matrix;
  95074. /**
  95075. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  95076. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  95077. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  95078. */
  95079. upVector: Vector3;
  95080. /**
  95081. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  95082. */
  95083. setMatUp(): void;
  95084. /**
  95085. * Current inertia value on the longitudinal axis.
  95086. * The bigger this number the longer it will take for the camera to stop.
  95087. */
  95088. inertialAlphaOffset: number;
  95089. /**
  95090. * Current inertia value on the latitudinal axis.
  95091. * The bigger this number the longer it will take for the camera to stop.
  95092. */
  95093. inertialBetaOffset: number;
  95094. /**
  95095. * Current inertia value on the radius axis.
  95096. * The bigger this number the longer it will take for the camera to stop.
  95097. */
  95098. inertialRadiusOffset: number;
  95099. /**
  95100. * Minimum allowed angle on the longitudinal axis.
  95101. * This can help limiting how the Camera is able to move in the scene.
  95102. */
  95103. lowerAlphaLimit: Nullable<number>;
  95104. /**
  95105. * Maximum allowed angle on the longitudinal axis.
  95106. * This can help limiting how the Camera is able to move in the scene.
  95107. */
  95108. upperAlphaLimit: Nullable<number>;
  95109. /**
  95110. * Minimum allowed angle on the latitudinal axis.
  95111. * This can help limiting how the Camera is able to move in the scene.
  95112. */
  95113. lowerBetaLimit: number;
  95114. /**
  95115. * Maximum allowed angle on the latitudinal axis.
  95116. * This can help limiting how the Camera is able to move in the scene.
  95117. */
  95118. upperBetaLimit: number;
  95119. /**
  95120. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  95121. * This can help limiting how the Camera is able to move in the scene.
  95122. */
  95123. lowerRadiusLimit: Nullable<number>;
  95124. /**
  95125. * Maximum allowed distance of the camera to the target (The camera can not get further).
  95126. * This can help limiting how the Camera is able to move in the scene.
  95127. */
  95128. upperRadiusLimit: Nullable<number>;
  95129. /**
  95130. * Defines the current inertia value used during panning of the camera along the X axis.
  95131. */
  95132. inertialPanningX: number;
  95133. /**
  95134. * Defines the current inertia value used during panning of the camera along the Y axis.
  95135. */
  95136. inertialPanningY: number;
  95137. /**
  95138. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  95139. * Basically if your fingers moves away from more than this distance you will be considered
  95140. * in pinch mode.
  95141. */
  95142. pinchToPanMaxDistance: number;
  95143. /**
  95144. * Defines the maximum distance the camera can pan.
  95145. * This could help keeping the cammera always in your scene.
  95146. */
  95147. panningDistanceLimit: Nullable<number>;
  95148. /**
  95149. * Defines the target of the camera before paning.
  95150. */
  95151. panningOriginTarget: Vector3;
  95152. /**
  95153. * Defines the value of the inertia used during panning.
  95154. * 0 would mean stop inertia and one would mean no decelleration at all.
  95155. */
  95156. panningInertia: number;
  95157. /**
  95158. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  95159. */
  95160. angularSensibilityX: number;
  95161. /**
  95162. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  95163. */
  95164. angularSensibilityY: number;
  95165. /**
  95166. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  95167. */
  95168. pinchPrecision: number;
  95169. /**
  95170. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  95171. * It will be used instead of pinchDeltaPrecision if different from 0.
  95172. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95173. */
  95174. pinchDeltaPercentage: number;
  95175. /**
  95176. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  95177. */
  95178. panningSensibility: number;
  95179. /**
  95180. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  95181. */
  95182. keysUp: number[];
  95183. /**
  95184. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  95185. */
  95186. keysDown: number[];
  95187. /**
  95188. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  95189. */
  95190. keysLeft: number[];
  95191. /**
  95192. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  95193. */
  95194. keysRight: number[];
  95195. /**
  95196. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95197. */
  95198. wheelPrecision: number;
  95199. /**
  95200. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  95201. * It will be used instead of pinchDeltaPrecision if different from 0.
  95202. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95203. */
  95204. wheelDeltaPercentage: number;
  95205. /**
  95206. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  95207. */
  95208. zoomOnFactor: number;
  95209. /**
  95210. * Defines a screen offset for the camera position.
  95211. */
  95212. targetScreenOffset: Vector2;
  95213. /**
  95214. * Allows the camera to be completely reversed.
  95215. * If false the camera can not arrive upside down.
  95216. */
  95217. allowUpsideDown: boolean;
  95218. /**
  95219. * Define if double tap/click is used to restore the previously saved state of the camera.
  95220. */
  95221. useInputToRestoreState: boolean;
  95222. /** @hidden */
  95223. _viewMatrix: Matrix;
  95224. /** @hidden */
  95225. _useCtrlForPanning: boolean;
  95226. /** @hidden */
  95227. _panningMouseButton: number;
  95228. /**
  95229. * Defines the input associated to the camera.
  95230. */
  95231. inputs: ArcRotateCameraInputsManager;
  95232. /** @hidden */
  95233. _reset: () => void;
  95234. /**
  95235. * Defines the allowed panning axis.
  95236. */
  95237. panningAxis: Vector3;
  95238. protected _localDirection: Vector3;
  95239. protected _transformedDirection: Vector3;
  95240. private _bouncingBehavior;
  95241. /**
  95242. * Gets the bouncing behavior of the camera if it has been enabled.
  95243. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95244. */
  95245. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  95246. /**
  95247. * Defines if the bouncing behavior of the camera is enabled on the camera.
  95248. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95249. */
  95250. useBouncingBehavior: boolean;
  95251. private _framingBehavior;
  95252. /**
  95253. * Gets the framing behavior of the camera if it has been enabled.
  95254. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95255. */
  95256. readonly framingBehavior: Nullable<FramingBehavior>;
  95257. /**
  95258. * Defines if the framing behavior of the camera is enabled on the camera.
  95259. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95260. */
  95261. useFramingBehavior: boolean;
  95262. private _autoRotationBehavior;
  95263. /**
  95264. * Gets the auto rotation behavior of the camera if it has been enabled.
  95265. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95266. */
  95267. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  95268. /**
  95269. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  95270. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95271. */
  95272. useAutoRotationBehavior: boolean;
  95273. /**
  95274. * Observable triggered when the mesh target has been changed on the camera.
  95275. */
  95276. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  95277. /**
  95278. * Event raised when the camera is colliding with a mesh.
  95279. */
  95280. onCollide: (collidedMesh: AbstractMesh) => void;
  95281. /**
  95282. * Defines whether the camera should check collision with the objects oh the scene.
  95283. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  95284. */
  95285. checkCollisions: boolean;
  95286. /**
  95287. * Defines the collision radius of the camera.
  95288. * This simulates a sphere around the camera.
  95289. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95290. */
  95291. collisionRadius: Vector3;
  95292. protected _collider: Collider;
  95293. protected _previousPosition: Vector3;
  95294. protected _collisionVelocity: Vector3;
  95295. protected _newPosition: Vector3;
  95296. protected _previousAlpha: number;
  95297. protected _previousBeta: number;
  95298. protected _previousRadius: number;
  95299. protected _collisionTriggered: boolean;
  95300. protected _targetBoundingCenter: Nullable<Vector3>;
  95301. private _computationVector;
  95302. /**
  95303. * Instantiates a new ArcRotateCamera in a given scene
  95304. * @param name Defines the name of the camera
  95305. * @param alpha Defines the camera rotation along the logitudinal axis
  95306. * @param beta Defines the camera rotation along the latitudinal axis
  95307. * @param radius Defines the camera distance from its target
  95308. * @param target Defines the camera target
  95309. * @param scene Defines the scene the camera belongs to
  95310. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95311. */
  95312. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95313. /** @hidden */
  95314. _initCache(): void;
  95315. /** @hidden */
  95316. _updateCache(ignoreParentClass?: boolean): void;
  95317. protected _getTargetPosition(): Vector3;
  95318. private _storedAlpha;
  95319. private _storedBeta;
  95320. private _storedRadius;
  95321. private _storedTarget;
  95322. /**
  95323. * Stores the current state of the camera (alpha, beta, radius and target)
  95324. * @returns the camera itself
  95325. */
  95326. storeState(): Camera;
  95327. /**
  95328. * @hidden
  95329. * Restored camera state. You must call storeState() first
  95330. */
  95331. _restoreStateValues(): boolean;
  95332. /** @hidden */
  95333. _isSynchronizedViewMatrix(): boolean;
  95334. /**
  95335. * Attached controls to the current camera.
  95336. * @param element Defines the element the controls should be listened from
  95337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95338. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  95339. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  95340. */
  95341. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  95342. /**
  95343. * Detach the current controls from the camera.
  95344. * The camera will stop reacting to inputs.
  95345. * @param element Defines the element to stop listening the inputs from
  95346. */
  95347. detachControl(element: HTMLElement): void;
  95348. /** @hidden */
  95349. _checkInputs(): void;
  95350. protected _checkLimits(): void;
  95351. /**
  95352. * Rebuilds angles (alpha, beta) and radius from the give position and target
  95353. */
  95354. rebuildAnglesAndRadius(): void;
  95355. /**
  95356. * Use a position to define the current camera related information like aplha, beta and radius
  95357. * @param position Defines the position to set the camera at
  95358. */
  95359. setPosition(position: Vector3): void;
  95360. /**
  95361. * Defines the target the camera should look at.
  95362. * This will automatically adapt alpha beta and radius to fit within the new target.
  95363. * @param target Defines the new target as a Vector or a mesh
  95364. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  95365. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  95366. */
  95367. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  95368. /** @hidden */
  95369. _getViewMatrix(): Matrix;
  95370. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  95371. /**
  95372. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95373. * @param meshes Defines the mesh to zoom on
  95374. * @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)
  95375. */
  95376. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95377. /**
  95378. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95379. * The target will be changed but the radius
  95380. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95381. * @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)
  95382. */
  95383. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95384. min: Vector3;
  95385. max: Vector3;
  95386. distance: number;
  95387. }, doNotUpdateMaxZ?: boolean): void;
  95388. /**
  95389. * @override
  95390. * Override Camera.createRigCamera
  95391. */
  95392. createRigCamera(name: string, cameraIndex: number): Camera;
  95393. /**
  95394. * @hidden
  95395. * @override
  95396. * Override Camera._updateRigCameras
  95397. */
  95398. _updateRigCameras(): void;
  95399. /**
  95400. * Destroy the camera and release the current resources hold by it.
  95401. */
  95402. dispose(): void;
  95403. /**
  95404. * Gets the current object class name.
  95405. * @return the class name
  95406. */
  95407. getClassName(): string;
  95408. }
  95409. }
  95410. declare module BABYLON {
  95411. /**
  95412. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95414. */
  95415. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95416. /**
  95417. * Gets the name of the behavior.
  95418. */
  95419. readonly name: string;
  95420. private _zoomStopsAnimation;
  95421. private _idleRotationSpeed;
  95422. private _idleRotationWaitTime;
  95423. private _idleRotationSpinupTime;
  95424. /**
  95425. * Sets the flag that indicates if user zooming should stop animation.
  95426. */
  95427. /**
  95428. * Gets the flag that indicates if user zooming should stop animation.
  95429. */
  95430. zoomStopsAnimation: boolean;
  95431. /**
  95432. * Sets the default speed at which the camera rotates around the model.
  95433. */
  95434. /**
  95435. * Gets the default speed at which the camera rotates around the model.
  95436. */
  95437. idleRotationSpeed: number;
  95438. /**
  95439. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95440. */
  95441. /**
  95442. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95443. */
  95444. idleRotationWaitTime: number;
  95445. /**
  95446. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95447. */
  95448. /**
  95449. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95450. */
  95451. idleRotationSpinupTime: number;
  95452. /**
  95453. * Gets a value indicating if the camera is currently rotating because of this behavior
  95454. */
  95455. readonly rotationInProgress: boolean;
  95456. private _onPrePointerObservableObserver;
  95457. private _onAfterCheckInputsObserver;
  95458. private _attachedCamera;
  95459. private _isPointerDown;
  95460. private _lastFrameTime;
  95461. private _lastInteractionTime;
  95462. private _cameraRotationSpeed;
  95463. /**
  95464. * Initializes the behavior.
  95465. */
  95466. init(): void;
  95467. /**
  95468. * Attaches the behavior to its arc rotate camera.
  95469. * @param camera Defines the camera to attach the behavior to
  95470. */
  95471. attach(camera: ArcRotateCamera): void;
  95472. /**
  95473. * Detaches the behavior from its current arc rotate camera.
  95474. */
  95475. detach(): void;
  95476. /**
  95477. * Returns true if user is scrolling.
  95478. * @return true if user is scrolling.
  95479. */
  95480. private _userIsZooming;
  95481. private _lastFrameRadius;
  95482. private _shouldAnimationStopForInteraction;
  95483. /**
  95484. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95485. */
  95486. private _applyUserInteraction;
  95487. private _userIsMoving;
  95488. }
  95489. }
  95490. declare module BABYLON {
  95491. /**
  95492. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95493. */
  95494. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95495. private ui;
  95496. /**
  95497. * The name of the behavior
  95498. */
  95499. name: string;
  95500. /**
  95501. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95502. */
  95503. distanceAwayFromFace: number;
  95504. /**
  95505. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95506. */
  95507. distanceAwayFromBottomOfFace: number;
  95508. private _faceVectors;
  95509. private _target;
  95510. private _scene;
  95511. private _onRenderObserver;
  95512. private _tmpMatrix;
  95513. private _tmpVector;
  95514. /**
  95515. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95516. * @param ui The transform node that should be attched to the mesh
  95517. */
  95518. constructor(ui: TransformNode);
  95519. /**
  95520. * Initializes the behavior
  95521. */
  95522. init(): void;
  95523. private _closestFace;
  95524. private _zeroVector;
  95525. private _lookAtTmpMatrix;
  95526. private _lookAtToRef;
  95527. /**
  95528. * Attaches the AttachToBoxBehavior to the passed in mesh
  95529. * @param target The mesh that the specified node will be attached to
  95530. */
  95531. attach(target: Mesh): void;
  95532. /**
  95533. * Detaches the behavior from the mesh
  95534. */
  95535. detach(): void;
  95536. }
  95537. }
  95538. declare module BABYLON {
  95539. /**
  95540. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95541. */
  95542. export class FadeInOutBehavior implements Behavior<Mesh> {
  95543. /**
  95544. * Time in milliseconds to delay before fading in (Default: 0)
  95545. */
  95546. delay: number;
  95547. /**
  95548. * Time in milliseconds for the mesh to fade in (Default: 300)
  95549. */
  95550. fadeInTime: number;
  95551. private _millisecondsPerFrame;
  95552. private _hovered;
  95553. private _hoverValue;
  95554. private _ownerNode;
  95555. /**
  95556. * Instatiates the FadeInOutBehavior
  95557. */
  95558. constructor();
  95559. /**
  95560. * The name of the behavior
  95561. */
  95562. readonly name: string;
  95563. /**
  95564. * Initializes the behavior
  95565. */
  95566. init(): void;
  95567. /**
  95568. * Attaches the fade behavior on the passed in mesh
  95569. * @param ownerNode The mesh that will be faded in/out once attached
  95570. */
  95571. attach(ownerNode: Mesh): void;
  95572. /**
  95573. * Detaches the behavior from the mesh
  95574. */
  95575. detach(): void;
  95576. /**
  95577. * Triggers the mesh to begin fading in or out
  95578. * @param value if the object should fade in or out (true to fade in)
  95579. */
  95580. fadeIn(value: boolean): void;
  95581. private _update;
  95582. private _setAllVisibility;
  95583. }
  95584. }
  95585. declare module BABYLON {
  95586. /**
  95587. * Class containing a set of static utilities functions for managing Pivots
  95588. * @hidden
  95589. */
  95590. export class PivotTools {
  95591. private static _PivotCached;
  95592. private static _OldPivotPoint;
  95593. private static _PivotTranslation;
  95594. private static _PivotTmpVector;
  95595. /** @hidden */
  95596. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95597. /** @hidden */
  95598. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95599. }
  95600. }
  95601. declare module BABYLON {
  95602. /**
  95603. * Class containing static functions to help procedurally build meshes
  95604. */
  95605. export class PlaneBuilder {
  95606. /**
  95607. * Creates a plane mesh
  95608. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95609. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95610. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95614. * @param name defines the name of the mesh
  95615. * @param options defines the options used to create the mesh
  95616. * @param scene defines the hosting scene
  95617. * @returns the plane mesh
  95618. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95619. */
  95620. static CreatePlane(name: string, options: {
  95621. size?: number;
  95622. width?: number;
  95623. height?: number;
  95624. sideOrientation?: number;
  95625. frontUVs?: Vector4;
  95626. backUVs?: Vector4;
  95627. updatable?: boolean;
  95628. sourcePlane?: Plane;
  95629. }, scene?: Nullable<Scene>): Mesh;
  95630. }
  95631. }
  95632. declare module BABYLON {
  95633. /**
  95634. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95635. */
  95636. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95637. private static _AnyMouseID;
  95638. private _attachedNode;
  95639. private _dragPlane;
  95640. private _scene;
  95641. private _pointerObserver;
  95642. private _beforeRenderObserver;
  95643. private static _planeScene;
  95644. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95645. /**
  95646. * 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)
  95647. */
  95648. maxDragAngle: number;
  95649. /**
  95650. * @hidden
  95651. */
  95652. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95653. /**
  95654. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95655. */
  95656. currentDraggingPointerID: number;
  95657. /**
  95658. * The last position where the pointer hit the drag plane in world space
  95659. */
  95660. lastDragPosition: Vector3;
  95661. /**
  95662. * If the behavior is currently in a dragging state
  95663. */
  95664. dragging: boolean;
  95665. /**
  95666. * 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)
  95667. */
  95668. dragDeltaRatio: number;
  95669. /**
  95670. * If the drag plane orientation should be updated during the dragging (Default: true)
  95671. */
  95672. updateDragPlane: boolean;
  95673. private _debugMode;
  95674. private _moving;
  95675. /**
  95676. * Fires each time the attached mesh is dragged with the pointer
  95677. * * delta between last drag position and current drag position in world space
  95678. * * dragDistance along the drag axis
  95679. * * dragPlaneNormal normal of the current drag plane used during the drag
  95680. * * dragPlanePoint in world space where the drag intersects the drag plane
  95681. */
  95682. onDragObservable: Observable<{
  95683. delta: Vector3;
  95684. dragPlanePoint: Vector3;
  95685. dragPlaneNormal: Vector3;
  95686. dragDistance: number;
  95687. pointerId: number;
  95688. }>;
  95689. /**
  95690. * Fires each time a drag begins (eg. mouse down on mesh)
  95691. */
  95692. onDragStartObservable: Observable<{
  95693. dragPlanePoint: Vector3;
  95694. pointerId: number;
  95695. }>;
  95696. /**
  95697. * Fires each time a drag ends (eg. mouse release after drag)
  95698. */
  95699. onDragEndObservable: Observable<{
  95700. dragPlanePoint: Vector3;
  95701. pointerId: number;
  95702. }>;
  95703. /**
  95704. * If the attached mesh should be moved when dragged
  95705. */
  95706. moveAttached: boolean;
  95707. /**
  95708. * If the drag behavior will react to drag events (Default: true)
  95709. */
  95710. enabled: boolean;
  95711. /**
  95712. * If camera controls should be detached during the drag
  95713. */
  95714. detachCameraControls: boolean;
  95715. /**
  95716. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95717. */
  95718. useObjectOrienationForDragging: boolean;
  95719. private _options;
  95720. /**
  95721. * Creates a pointer drag behavior that can be attached to a mesh
  95722. * @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)
  95723. */
  95724. constructor(options?: {
  95725. dragAxis?: Vector3;
  95726. dragPlaneNormal?: Vector3;
  95727. });
  95728. /**
  95729. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95730. */
  95731. validateDrag: (targetPosition: Vector3) => boolean;
  95732. /**
  95733. * The name of the behavior
  95734. */
  95735. readonly name: string;
  95736. /**
  95737. * Initializes the behavior
  95738. */
  95739. init(): void;
  95740. private _tmpVector;
  95741. private _alternatePickedPoint;
  95742. private _worldDragAxis;
  95743. private _targetPosition;
  95744. private _attachedElement;
  95745. /**
  95746. * Attaches the drag behavior the passed in mesh
  95747. * @param ownerNode The mesh that will be dragged around once attached
  95748. */
  95749. attach(ownerNode: AbstractMesh): void;
  95750. /**
  95751. * Force relase the drag action by code.
  95752. */
  95753. releaseDrag(): void;
  95754. private _startDragRay;
  95755. private _lastPointerRay;
  95756. /**
  95757. * Simulates the start of a pointer drag event on the behavior
  95758. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95759. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95760. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95761. */
  95762. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95763. private _startDrag;
  95764. private _dragDelta;
  95765. private _moveDrag;
  95766. private _pickWithRayOnDragPlane;
  95767. private _pointA;
  95768. private _pointB;
  95769. private _pointC;
  95770. private _lineA;
  95771. private _lineB;
  95772. private _localAxis;
  95773. private _lookAt;
  95774. private _updateDragPlanePosition;
  95775. /**
  95776. * Detaches the behavior from the mesh
  95777. */
  95778. detach(): void;
  95779. }
  95780. }
  95781. declare module BABYLON {
  95782. /**
  95783. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95784. */
  95785. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95786. private _dragBehaviorA;
  95787. private _dragBehaviorB;
  95788. private _startDistance;
  95789. private _initialScale;
  95790. private _targetScale;
  95791. private _ownerNode;
  95792. private _sceneRenderObserver;
  95793. /**
  95794. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95795. */
  95796. constructor();
  95797. /**
  95798. * The name of the behavior
  95799. */
  95800. readonly name: string;
  95801. /**
  95802. * Initializes the behavior
  95803. */
  95804. init(): void;
  95805. private _getCurrentDistance;
  95806. /**
  95807. * Attaches the scale behavior the passed in mesh
  95808. * @param ownerNode The mesh that will be scaled around once attached
  95809. */
  95810. attach(ownerNode: Mesh): void;
  95811. /**
  95812. * Detaches the behavior from the mesh
  95813. */
  95814. detach(): void;
  95815. }
  95816. }
  95817. declare module BABYLON {
  95818. /**
  95819. * 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
  95820. */
  95821. export class SixDofDragBehavior implements Behavior<Mesh> {
  95822. private static _virtualScene;
  95823. private _ownerNode;
  95824. private _sceneRenderObserver;
  95825. private _scene;
  95826. private _targetPosition;
  95827. private _virtualOriginMesh;
  95828. private _virtualDragMesh;
  95829. private _pointerObserver;
  95830. private _moving;
  95831. private _startingOrientation;
  95832. /**
  95833. * 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)
  95834. */
  95835. private zDragFactor;
  95836. /**
  95837. * If the object should rotate to face the drag origin
  95838. */
  95839. rotateDraggedObject: boolean;
  95840. /**
  95841. * If the behavior is currently in a dragging state
  95842. */
  95843. dragging: boolean;
  95844. /**
  95845. * 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)
  95846. */
  95847. dragDeltaRatio: number;
  95848. /**
  95849. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95850. */
  95851. currentDraggingPointerID: number;
  95852. /**
  95853. * If camera controls should be detached during the drag
  95854. */
  95855. detachCameraControls: boolean;
  95856. /**
  95857. * Fires each time a drag starts
  95858. */
  95859. onDragStartObservable: Observable<{}>;
  95860. /**
  95861. * Fires each time a drag ends (eg. mouse release after drag)
  95862. */
  95863. onDragEndObservable: Observable<{}>;
  95864. /**
  95865. * 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
  95866. */
  95867. constructor();
  95868. /**
  95869. * The name of the behavior
  95870. */
  95871. readonly name: string;
  95872. /**
  95873. * Initializes the behavior
  95874. */
  95875. init(): void;
  95876. /**
  95877. * Attaches the scale behavior the passed in mesh
  95878. * @param ownerNode The mesh that will be scaled around once attached
  95879. */
  95880. attach(ownerNode: Mesh): void;
  95881. /**
  95882. * Detaches the behavior from the mesh
  95883. */
  95884. detach(): void;
  95885. }
  95886. }
  95887. declare module BABYLON {
  95888. /**
  95889. * Class used to apply inverse kinematics to bones
  95890. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95891. */
  95892. export class BoneIKController {
  95893. private static _tmpVecs;
  95894. private static _tmpQuat;
  95895. private static _tmpMats;
  95896. /**
  95897. * Gets or sets the target mesh
  95898. */
  95899. targetMesh: AbstractMesh;
  95900. /** Gets or sets the mesh used as pole */
  95901. poleTargetMesh: AbstractMesh;
  95902. /**
  95903. * Gets or sets the bone used as pole
  95904. */
  95905. poleTargetBone: Nullable<Bone>;
  95906. /**
  95907. * Gets or sets the target position
  95908. */
  95909. targetPosition: Vector3;
  95910. /**
  95911. * Gets or sets the pole target position
  95912. */
  95913. poleTargetPosition: Vector3;
  95914. /**
  95915. * Gets or sets the pole target local offset
  95916. */
  95917. poleTargetLocalOffset: Vector3;
  95918. /**
  95919. * Gets or sets the pole angle
  95920. */
  95921. poleAngle: number;
  95922. /**
  95923. * Gets or sets the mesh associated with the controller
  95924. */
  95925. mesh: AbstractMesh;
  95926. /**
  95927. * 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)
  95928. */
  95929. slerpAmount: number;
  95930. private _bone1Quat;
  95931. private _bone1Mat;
  95932. private _bone2Ang;
  95933. private _bone1;
  95934. private _bone2;
  95935. private _bone1Length;
  95936. private _bone2Length;
  95937. private _maxAngle;
  95938. private _maxReach;
  95939. private _rightHandedSystem;
  95940. private _bendAxis;
  95941. private _slerping;
  95942. private _adjustRoll;
  95943. /**
  95944. * Gets or sets maximum allowed angle
  95945. */
  95946. maxAngle: number;
  95947. /**
  95948. * Creates a new BoneIKController
  95949. * @param mesh defines the mesh to control
  95950. * @param bone defines the bone to control
  95951. * @param options defines options to set up the controller
  95952. */
  95953. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95954. targetMesh?: AbstractMesh;
  95955. poleTargetMesh?: AbstractMesh;
  95956. poleTargetBone?: Bone;
  95957. poleTargetLocalOffset?: Vector3;
  95958. poleAngle?: number;
  95959. bendAxis?: Vector3;
  95960. maxAngle?: number;
  95961. slerpAmount?: number;
  95962. });
  95963. private _setMaxAngle;
  95964. /**
  95965. * Force the controller to update the bones
  95966. */
  95967. update(): void;
  95968. }
  95969. }
  95970. declare module BABYLON {
  95971. /**
  95972. * Class used to make a bone look toward a point in space
  95973. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95974. */
  95975. export class BoneLookController {
  95976. private static _tmpVecs;
  95977. private static _tmpQuat;
  95978. private static _tmpMats;
  95979. /**
  95980. * The target Vector3 that the bone will look at
  95981. */
  95982. target: Vector3;
  95983. /**
  95984. * The mesh that the bone is attached to
  95985. */
  95986. mesh: AbstractMesh;
  95987. /**
  95988. * The bone that will be looking to the target
  95989. */
  95990. bone: Bone;
  95991. /**
  95992. * The up axis of the coordinate system that is used when the bone is rotated
  95993. */
  95994. upAxis: Vector3;
  95995. /**
  95996. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95997. */
  95998. upAxisSpace: Space;
  95999. /**
  96000. * Used to make an adjustment to the yaw of the bone
  96001. */
  96002. adjustYaw: number;
  96003. /**
  96004. * Used to make an adjustment to the pitch of the bone
  96005. */
  96006. adjustPitch: number;
  96007. /**
  96008. * Used to make an adjustment to the roll of the bone
  96009. */
  96010. adjustRoll: number;
  96011. /**
  96012. * 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)
  96013. */
  96014. slerpAmount: number;
  96015. private _minYaw;
  96016. private _maxYaw;
  96017. private _minPitch;
  96018. private _maxPitch;
  96019. private _minYawSin;
  96020. private _minYawCos;
  96021. private _maxYawSin;
  96022. private _maxYawCos;
  96023. private _midYawConstraint;
  96024. private _minPitchTan;
  96025. private _maxPitchTan;
  96026. private _boneQuat;
  96027. private _slerping;
  96028. private _transformYawPitch;
  96029. private _transformYawPitchInv;
  96030. private _firstFrameSkipped;
  96031. private _yawRange;
  96032. private _fowardAxis;
  96033. /**
  96034. * Gets or sets the minimum yaw angle that the bone can look to
  96035. */
  96036. minYaw: number;
  96037. /**
  96038. * Gets or sets the maximum yaw angle that the bone can look to
  96039. */
  96040. maxYaw: number;
  96041. /**
  96042. * Gets or sets the minimum pitch angle that the bone can look to
  96043. */
  96044. minPitch: number;
  96045. /**
  96046. * Gets or sets the maximum pitch angle that the bone can look to
  96047. */
  96048. maxPitch: number;
  96049. /**
  96050. * Create a BoneLookController
  96051. * @param mesh the mesh that the bone belongs to
  96052. * @param bone the bone that will be looking to the target
  96053. * @param target the target Vector3 to look at
  96054. * @param options optional settings:
  96055. * * maxYaw: the maximum angle the bone will yaw to
  96056. * * minYaw: the minimum angle the bone will yaw to
  96057. * * maxPitch: the maximum angle the bone will pitch to
  96058. * * minPitch: the minimum angle the bone will yaw to
  96059. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  96060. * * upAxis: the up axis of the coordinate system
  96061. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  96062. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  96063. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  96064. * * adjustYaw: used to make an adjustment to the yaw of the bone
  96065. * * adjustPitch: used to make an adjustment to the pitch of the bone
  96066. * * adjustRoll: used to make an adjustment to the roll of the bone
  96067. **/
  96068. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  96069. maxYaw?: number;
  96070. minYaw?: number;
  96071. maxPitch?: number;
  96072. minPitch?: number;
  96073. slerpAmount?: number;
  96074. upAxis?: Vector3;
  96075. upAxisSpace?: Space;
  96076. yawAxis?: Vector3;
  96077. pitchAxis?: Vector3;
  96078. adjustYaw?: number;
  96079. adjustPitch?: number;
  96080. adjustRoll?: number;
  96081. });
  96082. /**
  96083. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  96084. */
  96085. update(): void;
  96086. private _getAngleDiff;
  96087. private _getAngleBetween;
  96088. private _isAngleBetween;
  96089. }
  96090. }
  96091. declare module BABYLON {
  96092. /**
  96093. * Manage the gamepad inputs to control an arc rotate camera.
  96094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96095. */
  96096. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  96097. /**
  96098. * Defines the camera the input is attached to.
  96099. */
  96100. camera: ArcRotateCamera;
  96101. /**
  96102. * Defines the gamepad the input is gathering event from.
  96103. */
  96104. gamepad: Nullable<Gamepad>;
  96105. /**
  96106. * Defines the gamepad rotation sensiblity.
  96107. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96108. */
  96109. gamepadRotationSensibility: number;
  96110. /**
  96111. * Defines the gamepad move sensiblity.
  96112. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96113. */
  96114. gamepadMoveSensibility: number;
  96115. private _onGamepadConnectedObserver;
  96116. private _onGamepadDisconnectedObserver;
  96117. /**
  96118. * Attach the input controls to a specific dom element to get the input from.
  96119. * @param element Defines the element the controls should be listened from
  96120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96121. */
  96122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96123. /**
  96124. * Detach the current controls from the specified dom element.
  96125. * @param element Defines the element to stop listening the inputs from
  96126. */
  96127. detachControl(element: Nullable<HTMLElement>): void;
  96128. /**
  96129. * Update the current camera state depending on the inputs that have been used this frame.
  96130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96131. */
  96132. checkInputs(): void;
  96133. /**
  96134. * Gets the class name of the current intput.
  96135. * @returns the class name
  96136. */
  96137. getClassName(): string;
  96138. /**
  96139. * Get the friendly name associated with the input class.
  96140. * @returns the input friendly name
  96141. */
  96142. getSimpleName(): string;
  96143. }
  96144. }
  96145. declare module BABYLON {
  96146. interface ArcRotateCameraInputsManager {
  96147. /**
  96148. * Add orientation input support to the input manager.
  96149. * @returns the current input manager
  96150. */
  96151. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  96152. }
  96153. /**
  96154. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  96155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96156. */
  96157. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  96158. /**
  96159. * Defines the camera the input is attached to.
  96160. */
  96161. camera: ArcRotateCamera;
  96162. /**
  96163. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  96164. */
  96165. alphaCorrection: number;
  96166. /**
  96167. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  96168. */
  96169. gammaCorrection: number;
  96170. private _alpha;
  96171. private _gamma;
  96172. private _dirty;
  96173. private _deviceOrientationHandler;
  96174. /**
  96175. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  96176. */
  96177. constructor();
  96178. /**
  96179. * Attach the input controls to a specific dom element to get the input from.
  96180. * @param element Defines the element the controls should be listened from
  96181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96182. */
  96183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96184. /** @hidden */
  96185. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  96186. /**
  96187. * Update the current camera state depending on the inputs that have been used this frame.
  96188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96189. */
  96190. checkInputs(): void;
  96191. /**
  96192. * Detach the current controls from the specified dom element.
  96193. * @param element Defines the element to stop listening the inputs from
  96194. */
  96195. detachControl(element: Nullable<HTMLElement>): void;
  96196. /**
  96197. * Gets the class name of the current intput.
  96198. * @returns the class name
  96199. */
  96200. getClassName(): string;
  96201. /**
  96202. * Get the friendly name associated with the input class.
  96203. * @returns the input friendly name
  96204. */
  96205. getSimpleName(): string;
  96206. }
  96207. }
  96208. declare module BABYLON {
  96209. /**
  96210. * Listen to mouse events to control the camera.
  96211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96212. */
  96213. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  96214. /**
  96215. * Defines the camera the input is attached to.
  96216. */
  96217. camera: FlyCamera;
  96218. /**
  96219. * Defines if touch is enabled. (Default is true.)
  96220. */
  96221. touchEnabled: boolean;
  96222. /**
  96223. * Defines the buttons associated with the input to handle camera rotation.
  96224. */
  96225. buttons: number[];
  96226. /**
  96227. * Assign buttons for Yaw control.
  96228. */
  96229. buttonsYaw: number[];
  96230. /**
  96231. * Assign buttons for Pitch control.
  96232. */
  96233. buttonsPitch: number[];
  96234. /**
  96235. * Assign buttons for Roll control.
  96236. */
  96237. buttonsRoll: number[];
  96238. /**
  96239. * Detect if any button is being pressed while mouse is moved.
  96240. * -1 = Mouse locked.
  96241. * 0 = Left button.
  96242. * 1 = Middle Button.
  96243. * 2 = Right Button.
  96244. */
  96245. activeButton: number;
  96246. /**
  96247. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  96248. * Higher values reduce its sensitivity.
  96249. */
  96250. angularSensibility: number;
  96251. private _mousemoveCallback;
  96252. private _observer;
  96253. private _rollObserver;
  96254. private previousPosition;
  96255. private noPreventDefault;
  96256. private element;
  96257. /**
  96258. * Listen to mouse events to control the camera.
  96259. * @param touchEnabled Define if touch is enabled. (Default is true.)
  96260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96261. */
  96262. constructor(touchEnabled?: boolean);
  96263. /**
  96264. * Attach the mouse control to the HTML DOM element.
  96265. * @param element Defines the element that listens to the input events.
  96266. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  96267. */
  96268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96269. /**
  96270. * Detach the current controls from the specified dom element.
  96271. * @param element Defines the element to stop listening the inputs from
  96272. */
  96273. detachControl(element: Nullable<HTMLElement>): void;
  96274. /**
  96275. * Gets the class name of the current input.
  96276. * @returns the class name.
  96277. */
  96278. getClassName(): string;
  96279. /**
  96280. * Get the friendly name associated with the input class.
  96281. * @returns the input's friendly name.
  96282. */
  96283. getSimpleName(): string;
  96284. private _pointerInput;
  96285. private _onMouseMove;
  96286. /**
  96287. * Rotate camera by mouse offset.
  96288. */
  96289. private rotateCamera;
  96290. }
  96291. }
  96292. declare module BABYLON {
  96293. /**
  96294. * Default Inputs manager for the FlyCamera.
  96295. * It groups all the default supported inputs for ease of use.
  96296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96297. */
  96298. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  96299. /**
  96300. * Instantiates a new FlyCameraInputsManager.
  96301. * @param camera Defines the camera the inputs belong to.
  96302. */
  96303. constructor(camera: FlyCamera);
  96304. /**
  96305. * Add keyboard input support to the input manager.
  96306. * @returns the new FlyCameraKeyboardMoveInput().
  96307. */
  96308. addKeyboard(): FlyCameraInputsManager;
  96309. /**
  96310. * Add mouse input support to the input manager.
  96311. * @param touchEnabled Enable touch screen support.
  96312. * @returns the new FlyCameraMouseInput().
  96313. */
  96314. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  96315. }
  96316. }
  96317. declare module BABYLON {
  96318. /**
  96319. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96320. * such as in a 3D Space Shooter or a Flight Simulator.
  96321. */
  96322. export class FlyCamera extends TargetCamera {
  96323. /**
  96324. * Define the collision ellipsoid of the camera.
  96325. * This is helpful for simulating a camera body, like a player's body.
  96326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96327. */
  96328. ellipsoid: Vector3;
  96329. /**
  96330. * Define an offset for the position of the ellipsoid around the camera.
  96331. * This can be helpful if the camera is attached away from the player's body center,
  96332. * such as at its head.
  96333. */
  96334. ellipsoidOffset: Vector3;
  96335. /**
  96336. * Enable or disable collisions of the camera with the rest of the scene objects.
  96337. */
  96338. checkCollisions: boolean;
  96339. /**
  96340. * Enable or disable gravity on the camera.
  96341. */
  96342. applyGravity: boolean;
  96343. /**
  96344. * Define the current direction the camera is moving to.
  96345. */
  96346. cameraDirection: Vector3;
  96347. /**
  96348. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  96349. * This overrides and empties cameraRotation.
  96350. */
  96351. rotationQuaternion: Quaternion;
  96352. /**
  96353. * Track Roll to maintain the wanted Rolling when looking around.
  96354. */
  96355. _trackRoll: number;
  96356. /**
  96357. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  96358. */
  96359. rollCorrect: number;
  96360. /**
  96361. * Mimic a banked turn, Rolling the camera when Yawing.
  96362. * It's recommended to use rollCorrect = 10 for faster banking correction.
  96363. */
  96364. bankedTurn: boolean;
  96365. /**
  96366. * Limit in radians for how much Roll banking will add. (Default: 90°)
  96367. */
  96368. bankedTurnLimit: number;
  96369. /**
  96370. * Value of 0 disables the banked Roll.
  96371. * Value of 1 is equal to the Yaw angle in radians.
  96372. */
  96373. bankedTurnMultiplier: number;
  96374. /**
  96375. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96376. */
  96377. inputs: FlyCameraInputsManager;
  96378. /**
  96379. * Gets the input sensibility for mouse input.
  96380. * Higher values reduce sensitivity.
  96381. */
  96382. /**
  96383. * Sets the input sensibility for a mouse input.
  96384. * Higher values reduce sensitivity.
  96385. */
  96386. angularSensibility: number;
  96387. /**
  96388. * Get the keys for camera movement forward.
  96389. */
  96390. /**
  96391. * Set the keys for camera movement forward.
  96392. */
  96393. keysForward: number[];
  96394. /**
  96395. * Get the keys for camera movement backward.
  96396. */
  96397. keysBackward: number[];
  96398. /**
  96399. * Get the keys for camera movement up.
  96400. */
  96401. /**
  96402. * Set the keys for camera movement up.
  96403. */
  96404. keysUp: number[];
  96405. /**
  96406. * Get the keys for camera movement down.
  96407. */
  96408. /**
  96409. * Set the keys for camera movement down.
  96410. */
  96411. keysDown: number[];
  96412. /**
  96413. * Get the keys for camera movement left.
  96414. */
  96415. /**
  96416. * Set the keys for camera movement left.
  96417. */
  96418. keysLeft: number[];
  96419. /**
  96420. * Set the keys for camera movement right.
  96421. */
  96422. /**
  96423. * Set the keys for camera movement right.
  96424. */
  96425. keysRight: number[];
  96426. /**
  96427. * Event raised when the camera collides with a mesh in the scene.
  96428. */
  96429. onCollide: (collidedMesh: AbstractMesh) => void;
  96430. private _collider;
  96431. private _needMoveForGravity;
  96432. private _oldPosition;
  96433. private _diffPosition;
  96434. private _newPosition;
  96435. /** @hidden */
  96436. _localDirection: Vector3;
  96437. /** @hidden */
  96438. _transformedDirection: Vector3;
  96439. /**
  96440. * Instantiates a FlyCamera.
  96441. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96442. * such as in a 3D Space Shooter or a Flight Simulator.
  96443. * @param name Define the name of the camera in the scene.
  96444. * @param position Define the starting position of the camera in the scene.
  96445. * @param scene Define the scene the camera belongs to.
  96446. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96447. */
  96448. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96449. /**
  96450. * Attach a control to the HTML DOM element.
  96451. * @param element Defines the element that listens to the input events.
  96452. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96453. */
  96454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96455. /**
  96456. * Detach a control from the HTML DOM element.
  96457. * The camera will stop reacting to that input.
  96458. * @param element Defines the element that listens to the input events.
  96459. */
  96460. detachControl(element: HTMLElement): void;
  96461. private _collisionMask;
  96462. /**
  96463. * Get the mask that the camera ignores in collision events.
  96464. */
  96465. /**
  96466. * Set the mask that the camera ignores in collision events.
  96467. */
  96468. collisionMask: number;
  96469. /** @hidden */
  96470. _collideWithWorld(displacement: Vector3): void;
  96471. /** @hidden */
  96472. private _onCollisionPositionChange;
  96473. /** @hidden */
  96474. _checkInputs(): void;
  96475. /** @hidden */
  96476. _decideIfNeedsToMove(): boolean;
  96477. /** @hidden */
  96478. _updatePosition(): void;
  96479. /**
  96480. * Restore the Roll to its target value at the rate specified.
  96481. * @param rate - Higher means slower restoring.
  96482. * @hidden
  96483. */
  96484. restoreRoll(rate: number): void;
  96485. /**
  96486. * Destroy the camera and release the current resources held by it.
  96487. */
  96488. dispose(): void;
  96489. /**
  96490. * Get the current object class name.
  96491. * @returns the class name.
  96492. */
  96493. getClassName(): string;
  96494. }
  96495. }
  96496. declare module BABYLON {
  96497. /**
  96498. * Listen to keyboard events to control the camera.
  96499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96500. */
  96501. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96502. /**
  96503. * Defines the camera the input is attached to.
  96504. */
  96505. camera: FlyCamera;
  96506. /**
  96507. * The list of keyboard keys used to control the forward move of the camera.
  96508. */
  96509. keysForward: number[];
  96510. /**
  96511. * The list of keyboard keys used to control the backward move of the camera.
  96512. */
  96513. keysBackward: number[];
  96514. /**
  96515. * The list of keyboard keys used to control the forward move of the camera.
  96516. */
  96517. keysUp: number[];
  96518. /**
  96519. * The list of keyboard keys used to control the backward move of the camera.
  96520. */
  96521. keysDown: number[];
  96522. /**
  96523. * The list of keyboard keys used to control the right strafe move of the camera.
  96524. */
  96525. keysRight: number[];
  96526. /**
  96527. * The list of keyboard keys used to control the left strafe move of the camera.
  96528. */
  96529. keysLeft: number[];
  96530. private _keys;
  96531. private _onCanvasBlurObserver;
  96532. private _onKeyboardObserver;
  96533. private _engine;
  96534. private _scene;
  96535. /**
  96536. * Attach the input controls to a specific dom element to get the input from.
  96537. * @param element Defines the element the controls should be listened from
  96538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96539. */
  96540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96541. /**
  96542. * Detach the current controls from the specified dom element.
  96543. * @param element Defines the element to stop listening the inputs from
  96544. */
  96545. detachControl(element: Nullable<HTMLElement>): void;
  96546. /**
  96547. * Gets the class name of the current intput.
  96548. * @returns the class name
  96549. */
  96550. getClassName(): string;
  96551. /** @hidden */
  96552. _onLostFocus(e: FocusEvent): void;
  96553. /**
  96554. * Get the friendly name associated with the input class.
  96555. * @returns the input friendly name
  96556. */
  96557. getSimpleName(): string;
  96558. /**
  96559. * Update the current camera state depending on the inputs that have been used this frame.
  96560. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96561. */
  96562. checkInputs(): void;
  96563. }
  96564. }
  96565. declare module BABYLON {
  96566. /**
  96567. * Manage the mouse wheel inputs to control a follow camera.
  96568. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96569. */
  96570. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96571. /**
  96572. * Defines the camera the input is attached to.
  96573. */
  96574. camera: FollowCamera;
  96575. /**
  96576. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96577. */
  96578. axisControlRadius: boolean;
  96579. /**
  96580. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96581. */
  96582. axisControlHeight: boolean;
  96583. /**
  96584. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96585. */
  96586. axisControlRotation: boolean;
  96587. /**
  96588. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96589. * relation to mouseWheel events.
  96590. */
  96591. wheelPrecision: number;
  96592. /**
  96593. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96594. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96595. */
  96596. wheelDeltaPercentage: number;
  96597. private _wheel;
  96598. private _observer;
  96599. /**
  96600. * Attach the input controls to a specific dom element to get the input from.
  96601. * @param element Defines the element the controls should be listened from
  96602. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96603. */
  96604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96605. /**
  96606. * Detach the current controls from the specified dom element.
  96607. * @param element Defines the element to stop listening the inputs from
  96608. */
  96609. detachControl(element: Nullable<HTMLElement>): void;
  96610. /**
  96611. * Gets the class name of the current intput.
  96612. * @returns the class name
  96613. */
  96614. getClassName(): string;
  96615. /**
  96616. * Get the friendly name associated with the input class.
  96617. * @returns the input friendly name
  96618. */
  96619. getSimpleName(): string;
  96620. }
  96621. }
  96622. declare module BABYLON {
  96623. /**
  96624. * Manage the pointers inputs to control an follow camera.
  96625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96626. */
  96627. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96628. /**
  96629. * Defines the camera the input is attached to.
  96630. */
  96631. camera: FollowCamera;
  96632. /**
  96633. * Gets the class name of the current input.
  96634. * @returns the class name
  96635. */
  96636. getClassName(): string;
  96637. /**
  96638. * Defines the pointer angular sensibility along the X axis or how fast is
  96639. * the camera rotating.
  96640. * A negative number will reverse the axis direction.
  96641. */
  96642. angularSensibilityX: number;
  96643. /**
  96644. * Defines the pointer angular sensibility along the Y axis or how fast is
  96645. * the camera rotating.
  96646. * A negative number will reverse the axis direction.
  96647. */
  96648. angularSensibilityY: number;
  96649. /**
  96650. * Defines the pointer pinch precision or how fast is the camera zooming.
  96651. * A negative number will reverse the axis direction.
  96652. */
  96653. pinchPrecision: number;
  96654. /**
  96655. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96656. * from 0.
  96657. * It defines the percentage of current camera.radius to use as delta when
  96658. * pinch zoom is used.
  96659. */
  96660. pinchDeltaPercentage: number;
  96661. /**
  96662. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96663. */
  96664. axisXControlRadius: boolean;
  96665. /**
  96666. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96667. */
  96668. axisXControlHeight: boolean;
  96669. /**
  96670. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96671. */
  96672. axisXControlRotation: boolean;
  96673. /**
  96674. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96675. */
  96676. axisYControlRadius: boolean;
  96677. /**
  96678. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96679. */
  96680. axisYControlHeight: boolean;
  96681. /**
  96682. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96683. */
  96684. axisYControlRotation: boolean;
  96685. /**
  96686. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96687. */
  96688. axisPinchControlRadius: boolean;
  96689. /**
  96690. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96691. */
  96692. axisPinchControlHeight: boolean;
  96693. /**
  96694. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96695. */
  96696. axisPinchControlRotation: boolean;
  96697. /**
  96698. * Log error messages if basic misconfiguration has occurred.
  96699. */
  96700. warningEnable: boolean;
  96701. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96702. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96703. private _warningCounter;
  96704. private _warning;
  96705. }
  96706. }
  96707. declare module BABYLON {
  96708. /**
  96709. * Default Inputs manager for the FollowCamera.
  96710. * It groups all the default supported inputs for ease of use.
  96711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96712. */
  96713. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96714. /**
  96715. * Instantiates a new FollowCameraInputsManager.
  96716. * @param camera Defines the camera the inputs belong to
  96717. */
  96718. constructor(camera: FollowCamera);
  96719. /**
  96720. * Add keyboard input support to the input manager.
  96721. * @returns the current input manager
  96722. */
  96723. addKeyboard(): FollowCameraInputsManager;
  96724. /**
  96725. * Add mouse wheel input support to the input manager.
  96726. * @returns the current input manager
  96727. */
  96728. addMouseWheel(): FollowCameraInputsManager;
  96729. /**
  96730. * Add pointers input support to the input manager.
  96731. * @returns the current input manager
  96732. */
  96733. addPointers(): FollowCameraInputsManager;
  96734. /**
  96735. * Add orientation input support to the input manager.
  96736. * @returns the current input manager
  96737. */
  96738. addVRDeviceOrientation(): FollowCameraInputsManager;
  96739. }
  96740. }
  96741. declare module BABYLON {
  96742. /**
  96743. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96744. * an arc rotate version arcFollowCamera are available.
  96745. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96746. */
  96747. export class FollowCamera extends TargetCamera {
  96748. /**
  96749. * Distance the follow camera should follow an object at
  96750. */
  96751. radius: number;
  96752. /**
  96753. * Minimum allowed distance of the camera to the axis of rotation
  96754. * (The camera can not get closer).
  96755. * This can help limiting how the Camera is able to move in the scene.
  96756. */
  96757. lowerRadiusLimit: Nullable<number>;
  96758. /**
  96759. * Maximum allowed distance of the camera to the axis of rotation
  96760. * (The camera can not get further).
  96761. * This can help limiting how the Camera is able to move in the scene.
  96762. */
  96763. upperRadiusLimit: Nullable<number>;
  96764. /**
  96765. * Define a rotation offset between the camera and the object it follows
  96766. */
  96767. rotationOffset: number;
  96768. /**
  96769. * Minimum allowed angle to camera position relative to target object.
  96770. * This can help limiting how the Camera is able to move in the scene.
  96771. */
  96772. lowerRotationOffsetLimit: Nullable<number>;
  96773. /**
  96774. * Maximum allowed angle to camera position relative to target object.
  96775. * This can help limiting how the Camera is able to move in the scene.
  96776. */
  96777. upperRotationOffsetLimit: Nullable<number>;
  96778. /**
  96779. * Define a height offset between the camera and the object it follows.
  96780. * It can help following an object from the top (like a car chaing a plane)
  96781. */
  96782. heightOffset: number;
  96783. /**
  96784. * Minimum allowed height of camera position relative to target object.
  96785. * This can help limiting how the Camera is able to move in the scene.
  96786. */
  96787. lowerHeightOffsetLimit: Nullable<number>;
  96788. /**
  96789. * Maximum allowed height of camera position relative to target object.
  96790. * This can help limiting how the Camera is able to move in the scene.
  96791. */
  96792. upperHeightOffsetLimit: Nullable<number>;
  96793. /**
  96794. * Define how fast the camera can accelerate to follow it s target.
  96795. */
  96796. cameraAcceleration: number;
  96797. /**
  96798. * Define the speed limit of the camera following an object.
  96799. */
  96800. maxCameraSpeed: number;
  96801. /**
  96802. * Define the target of the camera.
  96803. */
  96804. lockedTarget: Nullable<AbstractMesh>;
  96805. /**
  96806. * Defines the input associated with the camera.
  96807. */
  96808. inputs: FollowCameraInputsManager;
  96809. /**
  96810. * Instantiates the follow camera.
  96811. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96812. * @param name Define the name of the camera in the scene
  96813. * @param position Define the position of the camera
  96814. * @param scene Define the scene the camera belong to
  96815. * @param lockedTarget Define the target of the camera
  96816. */
  96817. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96818. private _follow;
  96819. /**
  96820. * Attached controls to the current camera.
  96821. * @param element Defines the element the controls should be listened from
  96822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96823. */
  96824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96825. /**
  96826. * Detach the current controls from the camera.
  96827. * The camera will stop reacting to inputs.
  96828. * @param element Defines the element to stop listening the inputs from
  96829. */
  96830. detachControl(element: HTMLElement): void;
  96831. /** @hidden */
  96832. _checkInputs(): void;
  96833. private _checkLimits;
  96834. /**
  96835. * Gets the camera class name.
  96836. * @returns the class name
  96837. */
  96838. getClassName(): string;
  96839. }
  96840. /**
  96841. * Arc Rotate version of the follow camera.
  96842. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96843. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96844. */
  96845. export class ArcFollowCamera extends TargetCamera {
  96846. /** The longitudinal angle of the camera */
  96847. alpha: number;
  96848. /** The latitudinal angle of the camera */
  96849. beta: number;
  96850. /** The radius of the camera from its target */
  96851. radius: number;
  96852. /** Define the camera target (the messh it should follow) */
  96853. target: Nullable<AbstractMesh>;
  96854. private _cartesianCoordinates;
  96855. /**
  96856. * Instantiates a new ArcFollowCamera
  96857. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96858. * @param name Define the name of the camera
  96859. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96860. * @param beta Define the rotation angle of the camera around the elevation axis
  96861. * @param radius Define the radius of the camera from its target point
  96862. * @param target Define the target of the camera
  96863. * @param scene Define the scene the camera belongs to
  96864. */
  96865. constructor(name: string,
  96866. /** The longitudinal angle of the camera */
  96867. alpha: number,
  96868. /** The latitudinal angle of the camera */
  96869. beta: number,
  96870. /** The radius of the camera from its target */
  96871. radius: number,
  96872. /** Define the camera target (the messh it should follow) */
  96873. target: Nullable<AbstractMesh>, scene: Scene);
  96874. private _follow;
  96875. /** @hidden */
  96876. _checkInputs(): void;
  96877. /**
  96878. * Returns the class name of the object.
  96879. * It is mostly used internally for serialization purposes.
  96880. */
  96881. getClassName(): string;
  96882. }
  96883. }
  96884. declare module BABYLON {
  96885. /**
  96886. * Manage the keyboard inputs to control the movement of a follow camera.
  96887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96888. */
  96889. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96890. /**
  96891. * Defines the camera the input is attached to.
  96892. */
  96893. camera: FollowCamera;
  96894. /**
  96895. * Defines the list of key codes associated with the up action (increase heightOffset)
  96896. */
  96897. keysHeightOffsetIncr: number[];
  96898. /**
  96899. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96900. */
  96901. keysHeightOffsetDecr: number[];
  96902. /**
  96903. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96904. */
  96905. keysHeightOffsetModifierAlt: boolean;
  96906. /**
  96907. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96908. */
  96909. keysHeightOffsetModifierCtrl: boolean;
  96910. /**
  96911. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96912. */
  96913. keysHeightOffsetModifierShift: boolean;
  96914. /**
  96915. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96916. */
  96917. keysRotationOffsetIncr: number[];
  96918. /**
  96919. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96920. */
  96921. keysRotationOffsetDecr: number[];
  96922. /**
  96923. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96924. */
  96925. keysRotationOffsetModifierAlt: boolean;
  96926. /**
  96927. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96928. */
  96929. keysRotationOffsetModifierCtrl: boolean;
  96930. /**
  96931. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96932. */
  96933. keysRotationOffsetModifierShift: boolean;
  96934. /**
  96935. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96936. */
  96937. keysRadiusIncr: number[];
  96938. /**
  96939. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96940. */
  96941. keysRadiusDecr: number[];
  96942. /**
  96943. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96944. */
  96945. keysRadiusModifierAlt: boolean;
  96946. /**
  96947. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96948. */
  96949. keysRadiusModifierCtrl: boolean;
  96950. /**
  96951. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96952. */
  96953. keysRadiusModifierShift: boolean;
  96954. /**
  96955. * Defines the rate of change of heightOffset.
  96956. */
  96957. heightSensibility: number;
  96958. /**
  96959. * Defines the rate of change of rotationOffset.
  96960. */
  96961. rotationSensibility: number;
  96962. /**
  96963. * Defines the rate of change of radius.
  96964. */
  96965. radiusSensibility: number;
  96966. private _keys;
  96967. private _ctrlPressed;
  96968. private _altPressed;
  96969. private _shiftPressed;
  96970. private _onCanvasBlurObserver;
  96971. private _onKeyboardObserver;
  96972. private _engine;
  96973. private _scene;
  96974. /**
  96975. * Attach the input controls to a specific dom element to get the input from.
  96976. * @param element Defines the element the controls should be listened from
  96977. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96978. */
  96979. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96980. /**
  96981. * Detach the current controls from the specified dom element.
  96982. * @param element Defines the element to stop listening the inputs from
  96983. */
  96984. detachControl(element: Nullable<HTMLElement>): void;
  96985. /**
  96986. * Update the current camera state depending on the inputs that have been used this frame.
  96987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96988. */
  96989. checkInputs(): void;
  96990. /**
  96991. * Gets the class name of the current input.
  96992. * @returns the class name
  96993. */
  96994. getClassName(): string;
  96995. /**
  96996. * Get the friendly name associated with the input class.
  96997. * @returns the input friendly name
  96998. */
  96999. getSimpleName(): string;
  97000. /**
  97001. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97002. * allow modification of the heightOffset value.
  97003. */
  97004. private _modifierHeightOffset;
  97005. /**
  97006. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97007. * allow modification of the rotationOffset value.
  97008. */
  97009. private _modifierRotationOffset;
  97010. /**
  97011. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97012. * allow modification of the radius value.
  97013. */
  97014. private _modifierRadius;
  97015. }
  97016. }
  97017. declare module BABYLON {
  97018. interface FreeCameraInputsManager {
  97019. /**
  97020. * @hidden
  97021. */
  97022. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  97023. /**
  97024. * Add orientation input support to the input manager.
  97025. * @returns the current input manager
  97026. */
  97027. addDeviceOrientation(): FreeCameraInputsManager;
  97028. }
  97029. /**
  97030. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  97031. * Screen rotation is taken into account.
  97032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97033. */
  97034. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  97035. private _camera;
  97036. private _screenOrientationAngle;
  97037. private _constantTranform;
  97038. private _screenQuaternion;
  97039. private _alpha;
  97040. private _beta;
  97041. private _gamma;
  97042. /**
  97043. * @hidden
  97044. */
  97045. _onDeviceOrientationChangedObservable: Observable<void>;
  97046. /**
  97047. * Instantiates a new input
  97048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97049. */
  97050. constructor();
  97051. /**
  97052. * Define the camera controlled by the input.
  97053. */
  97054. camera: FreeCamera;
  97055. /**
  97056. * Attach the input controls to a specific dom element to get the input from.
  97057. * @param element Defines the element the controls should be listened from
  97058. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97059. */
  97060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97061. private _orientationChanged;
  97062. private _deviceOrientation;
  97063. /**
  97064. * Detach the current controls from the specified dom element.
  97065. * @param element Defines the element to stop listening the inputs from
  97066. */
  97067. detachControl(element: Nullable<HTMLElement>): void;
  97068. /**
  97069. * Update the current camera state depending on the inputs that have been used this frame.
  97070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97071. */
  97072. checkInputs(): void;
  97073. /**
  97074. * Gets the class name of the current intput.
  97075. * @returns the class name
  97076. */
  97077. getClassName(): string;
  97078. /**
  97079. * Get the friendly name associated with the input class.
  97080. * @returns the input friendly name
  97081. */
  97082. getSimpleName(): string;
  97083. }
  97084. }
  97085. declare module BABYLON {
  97086. /**
  97087. * Manage the gamepad inputs to control a free camera.
  97088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97089. */
  97090. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  97091. /**
  97092. * Define the camera the input is attached to.
  97093. */
  97094. camera: FreeCamera;
  97095. /**
  97096. * Define the Gamepad controlling the input
  97097. */
  97098. gamepad: Nullable<Gamepad>;
  97099. /**
  97100. * Defines the gamepad rotation sensiblity.
  97101. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97102. */
  97103. gamepadAngularSensibility: number;
  97104. /**
  97105. * Defines the gamepad move sensiblity.
  97106. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97107. */
  97108. gamepadMoveSensibility: number;
  97109. private _onGamepadConnectedObserver;
  97110. private _onGamepadDisconnectedObserver;
  97111. private _cameraTransform;
  97112. private _deltaTransform;
  97113. private _vector3;
  97114. private _vector2;
  97115. /**
  97116. * Attach the input controls to a specific dom element to get the input from.
  97117. * @param element Defines the element the controls should be listened from
  97118. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97119. */
  97120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97121. /**
  97122. * Detach the current controls from the specified dom element.
  97123. * @param element Defines the element to stop listening the inputs from
  97124. */
  97125. detachControl(element: Nullable<HTMLElement>): void;
  97126. /**
  97127. * Update the current camera state depending on the inputs that have been used this frame.
  97128. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97129. */
  97130. checkInputs(): void;
  97131. /**
  97132. * Gets the class name of the current intput.
  97133. * @returns the class name
  97134. */
  97135. getClassName(): string;
  97136. /**
  97137. * Get the friendly name associated with the input class.
  97138. * @returns the input friendly name
  97139. */
  97140. getSimpleName(): string;
  97141. }
  97142. }
  97143. declare module BABYLON {
  97144. /**
  97145. * Defines the potential axis of a Joystick
  97146. */
  97147. export enum JoystickAxis {
  97148. /** X axis */
  97149. X = 0,
  97150. /** Y axis */
  97151. Y = 1,
  97152. /** Z axis */
  97153. Z = 2
  97154. }
  97155. /**
  97156. * Class used to define virtual joystick (used in touch mode)
  97157. */
  97158. export class VirtualJoystick {
  97159. /**
  97160. * Gets or sets a boolean indicating that left and right values must be inverted
  97161. */
  97162. reverseLeftRight: boolean;
  97163. /**
  97164. * Gets or sets a boolean indicating that up and down values must be inverted
  97165. */
  97166. reverseUpDown: boolean;
  97167. /**
  97168. * Gets the offset value for the position (ie. the change of the position value)
  97169. */
  97170. deltaPosition: Vector3;
  97171. /**
  97172. * Gets a boolean indicating if the virtual joystick was pressed
  97173. */
  97174. pressed: boolean;
  97175. /**
  97176. * Canvas the virtual joystick will render onto, default z-index of this is 5
  97177. */
  97178. static Canvas: Nullable<HTMLCanvasElement>;
  97179. private static _globalJoystickIndex;
  97180. private static vjCanvasContext;
  97181. private static vjCanvasWidth;
  97182. private static vjCanvasHeight;
  97183. private static halfWidth;
  97184. private _action;
  97185. private _axisTargetedByLeftAndRight;
  97186. private _axisTargetedByUpAndDown;
  97187. private _joystickSensibility;
  97188. private _inversedSensibility;
  97189. private _joystickPointerID;
  97190. private _joystickColor;
  97191. private _joystickPointerPos;
  97192. private _joystickPreviousPointerPos;
  97193. private _joystickPointerStartPos;
  97194. private _deltaJoystickVector;
  97195. private _leftJoystick;
  97196. private _touches;
  97197. private _onPointerDownHandlerRef;
  97198. private _onPointerMoveHandlerRef;
  97199. private _onPointerUpHandlerRef;
  97200. private _onResize;
  97201. /**
  97202. * Creates a new virtual joystick
  97203. * @param leftJoystick defines that the joystick is for left hand (false by default)
  97204. */
  97205. constructor(leftJoystick?: boolean);
  97206. /**
  97207. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  97208. * @param newJoystickSensibility defines the new sensibility
  97209. */
  97210. setJoystickSensibility(newJoystickSensibility: number): void;
  97211. private _onPointerDown;
  97212. private _onPointerMove;
  97213. private _onPointerUp;
  97214. /**
  97215. * Change the color of the virtual joystick
  97216. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  97217. */
  97218. setJoystickColor(newColor: string): void;
  97219. /**
  97220. * Defines a callback to call when the joystick is touched
  97221. * @param action defines the callback
  97222. */
  97223. setActionOnTouch(action: () => any): void;
  97224. /**
  97225. * Defines which axis you'd like to control for left & right
  97226. * @param axis defines the axis to use
  97227. */
  97228. setAxisForLeftRight(axis: JoystickAxis): void;
  97229. /**
  97230. * Defines which axis you'd like to control for up & down
  97231. * @param axis defines the axis to use
  97232. */
  97233. setAxisForUpDown(axis: JoystickAxis): void;
  97234. private _drawVirtualJoystick;
  97235. /**
  97236. * Release internal HTML canvas
  97237. */
  97238. releaseCanvas(): void;
  97239. }
  97240. }
  97241. declare module BABYLON {
  97242. interface FreeCameraInputsManager {
  97243. /**
  97244. * Add virtual joystick input support to the input manager.
  97245. * @returns the current input manager
  97246. */
  97247. addVirtualJoystick(): FreeCameraInputsManager;
  97248. }
  97249. /**
  97250. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  97251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97252. */
  97253. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  97254. /**
  97255. * Defines the camera the input is attached to.
  97256. */
  97257. camera: FreeCamera;
  97258. private _leftjoystick;
  97259. private _rightjoystick;
  97260. /**
  97261. * Gets the left stick of the virtual joystick.
  97262. * @returns The virtual Joystick
  97263. */
  97264. getLeftJoystick(): VirtualJoystick;
  97265. /**
  97266. * Gets the right stick of the virtual joystick.
  97267. * @returns The virtual Joystick
  97268. */
  97269. getRightJoystick(): VirtualJoystick;
  97270. /**
  97271. * Update the current camera state depending on the inputs that have been used this frame.
  97272. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97273. */
  97274. checkInputs(): void;
  97275. /**
  97276. * Attach the input controls to a specific dom element to get the input from.
  97277. * @param element Defines the element the controls should be listened from
  97278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97279. */
  97280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97281. /**
  97282. * Detach the current controls from the specified dom element.
  97283. * @param element Defines the element to stop listening the inputs from
  97284. */
  97285. detachControl(element: Nullable<HTMLElement>): void;
  97286. /**
  97287. * Gets the class name of the current intput.
  97288. * @returns the class name
  97289. */
  97290. getClassName(): string;
  97291. /**
  97292. * Get the friendly name associated with the input class.
  97293. * @returns the input friendly name
  97294. */
  97295. getSimpleName(): string;
  97296. }
  97297. }
  97298. declare module BABYLON {
  97299. /**
  97300. * This represents a FPS type of camera controlled by touch.
  97301. * This is like a universal camera minus the Gamepad controls.
  97302. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97303. */
  97304. export class TouchCamera extends FreeCamera {
  97305. /**
  97306. * Defines the touch sensibility for rotation.
  97307. * The higher the faster.
  97308. */
  97309. touchAngularSensibility: number;
  97310. /**
  97311. * Defines the touch sensibility for move.
  97312. * The higher the faster.
  97313. */
  97314. touchMoveSensibility: number;
  97315. /**
  97316. * Instantiates a new touch camera.
  97317. * This represents a FPS type of camera controlled by touch.
  97318. * This is like a universal camera minus the Gamepad controls.
  97319. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97320. * @param name Define the name of the camera in the scene
  97321. * @param position Define the start position of the camera in the scene
  97322. * @param scene Define the scene the camera belongs to
  97323. */
  97324. constructor(name: string, position: Vector3, scene: Scene);
  97325. /**
  97326. * Gets the current object class name.
  97327. * @return the class name
  97328. */
  97329. getClassName(): string;
  97330. /** @hidden */
  97331. _setupInputs(): void;
  97332. }
  97333. }
  97334. declare module BABYLON {
  97335. /**
  97336. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  97337. * being tilted forward or back and left or right.
  97338. */
  97339. export class DeviceOrientationCamera extends FreeCamera {
  97340. private _initialQuaternion;
  97341. private _quaternionCache;
  97342. private _tmpDragQuaternion;
  97343. /**
  97344. * Creates a new device orientation camera
  97345. * @param name The name of the camera
  97346. * @param position The start position camera
  97347. * @param scene The scene the camera belongs to
  97348. */
  97349. constructor(name: string, position: Vector3, scene: Scene);
  97350. /**
  97351. * @hidden
  97352. * Disabled pointer input on first orientation sensor update (Default: true)
  97353. */
  97354. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  97355. private _dragFactor;
  97356. /**
  97357. * Enabled turning on the y axis when the orientation sensor is active
  97358. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  97359. */
  97360. enableHorizontalDragging(dragFactor?: number): void;
  97361. /**
  97362. * Gets the current instance class name ("DeviceOrientationCamera").
  97363. * This helps avoiding instanceof at run time.
  97364. * @returns the class name
  97365. */
  97366. getClassName(): string;
  97367. /**
  97368. * @hidden
  97369. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  97370. */
  97371. _checkInputs(): void;
  97372. /**
  97373. * Reset the camera to its default orientation on the specified axis only.
  97374. * @param axis The axis to reset
  97375. */
  97376. resetToCurrentRotation(axis?: Axis): void;
  97377. }
  97378. }
  97379. declare module BABYLON {
  97380. /**
  97381. * 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,
  97382. * which still works and will still be found in many Playgrounds.
  97383. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97384. */
  97385. export class UniversalCamera extends TouchCamera {
  97386. /**
  97387. * Defines the gamepad rotation sensiblity.
  97388. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97389. */
  97390. gamepadAngularSensibility: number;
  97391. /**
  97392. * Defines the gamepad move sensiblity.
  97393. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97394. */
  97395. gamepadMoveSensibility: number;
  97396. /**
  97397. * 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,
  97398. * which still works and will still be found in many Playgrounds.
  97399. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97400. * @param name Define the name of the camera in the scene
  97401. * @param position Define the start position of the camera in the scene
  97402. * @param scene Define the scene the camera belongs to
  97403. */
  97404. constructor(name: string, position: Vector3, scene: Scene);
  97405. /**
  97406. * Gets the current object class name.
  97407. * @return the class name
  97408. */
  97409. getClassName(): string;
  97410. }
  97411. }
  97412. declare module BABYLON {
  97413. /**
  97414. * This represents a FPS type of camera. This is only here for back compat purpose.
  97415. * Please use the UniversalCamera instead as both are identical.
  97416. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97417. */
  97418. export class GamepadCamera extends UniversalCamera {
  97419. /**
  97420. * Instantiates a new Gamepad Camera
  97421. * This represents a FPS type of camera. This is only here for back compat purpose.
  97422. * Please use the UniversalCamera instead as both are identical.
  97423. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97424. * @param name Define the name of the camera in the scene
  97425. * @param position Define the start position of the camera in the scene
  97426. * @param scene Define the scene the camera belongs to
  97427. */
  97428. constructor(name: string, position: Vector3, scene: Scene);
  97429. /**
  97430. * Gets the current object class name.
  97431. * @return the class name
  97432. */
  97433. getClassName(): string;
  97434. }
  97435. }
  97436. declare module BABYLON {
  97437. /** @hidden */
  97438. export var passPixelShader: {
  97439. name: string;
  97440. shader: string;
  97441. };
  97442. }
  97443. declare module BABYLON {
  97444. /** @hidden */
  97445. export var passCubePixelShader: {
  97446. name: string;
  97447. shader: string;
  97448. };
  97449. }
  97450. declare module BABYLON {
  97451. /**
  97452. * PassPostProcess which produces an output the same as it's input
  97453. */
  97454. export class PassPostProcess extends PostProcess {
  97455. /**
  97456. * Creates the PassPostProcess
  97457. * @param name The name of the effect.
  97458. * @param options The required width/height ratio to downsize to before computing the render pass.
  97459. * @param camera The camera to apply the render pass to.
  97460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97461. * @param engine The engine which the post process will be applied. (default: current engine)
  97462. * @param reusable If the post process can be reused on the same frame. (default: false)
  97463. * @param textureType The type of texture to be used when performing the post processing.
  97464. * @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)
  97465. */
  97466. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97467. }
  97468. /**
  97469. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97470. */
  97471. export class PassCubePostProcess extends PostProcess {
  97472. private _face;
  97473. /**
  97474. * Gets or sets the cube face to display.
  97475. * * 0 is +X
  97476. * * 1 is -X
  97477. * * 2 is +Y
  97478. * * 3 is -Y
  97479. * * 4 is +Z
  97480. * * 5 is -Z
  97481. */
  97482. face: number;
  97483. /**
  97484. * Creates the PassCubePostProcess
  97485. * @param name The name of the effect.
  97486. * @param options The required width/height ratio to downsize to before computing the render pass.
  97487. * @param camera The camera to apply the render pass to.
  97488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97489. * @param engine The engine which the post process will be applied. (default: current engine)
  97490. * @param reusable If the post process can be reused on the same frame. (default: false)
  97491. * @param textureType The type of texture to be used when performing the post processing.
  97492. * @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)
  97493. */
  97494. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97495. }
  97496. }
  97497. declare module BABYLON {
  97498. /** @hidden */
  97499. export var anaglyphPixelShader: {
  97500. name: string;
  97501. shader: string;
  97502. };
  97503. }
  97504. declare module BABYLON {
  97505. /**
  97506. * Postprocess used to generate anaglyphic rendering
  97507. */
  97508. export class AnaglyphPostProcess extends PostProcess {
  97509. private _passedProcess;
  97510. /**
  97511. * Creates a new AnaglyphPostProcess
  97512. * @param name defines postprocess name
  97513. * @param options defines creation options or target ratio scale
  97514. * @param rigCameras defines cameras using this postprocess
  97515. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  97516. * @param engine defines hosting engine
  97517. * @param reusable defines if the postprocess will be reused multiple times per frame
  97518. */
  97519. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  97520. }
  97521. }
  97522. declare module BABYLON {
  97523. /**
  97524. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97525. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97526. */
  97527. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97528. /**
  97529. * Creates a new AnaglyphArcRotateCamera
  97530. * @param name defines camera name
  97531. * @param alpha defines alpha angle (in radians)
  97532. * @param beta defines beta angle (in radians)
  97533. * @param radius defines radius
  97534. * @param target defines camera target
  97535. * @param interaxialDistance defines distance between each color axis
  97536. * @param scene defines the hosting scene
  97537. */
  97538. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97539. /**
  97540. * Gets camera class name
  97541. * @returns AnaglyphArcRotateCamera
  97542. */
  97543. getClassName(): string;
  97544. }
  97545. }
  97546. declare module BABYLON {
  97547. /**
  97548. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97549. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97550. */
  97551. export class AnaglyphFreeCamera extends FreeCamera {
  97552. /**
  97553. * Creates a new AnaglyphFreeCamera
  97554. * @param name defines camera name
  97555. * @param position defines initial position
  97556. * @param interaxialDistance defines distance between each color axis
  97557. * @param scene defines the hosting scene
  97558. */
  97559. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97560. /**
  97561. * Gets camera class name
  97562. * @returns AnaglyphFreeCamera
  97563. */
  97564. getClassName(): string;
  97565. }
  97566. }
  97567. declare module BABYLON {
  97568. /**
  97569. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97570. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97571. */
  97572. export class AnaglyphGamepadCamera extends GamepadCamera {
  97573. /**
  97574. * Creates a new AnaglyphGamepadCamera
  97575. * @param name defines camera name
  97576. * @param position defines initial position
  97577. * @param interaxialDistance defines distance between each color axis
  97578. * @param scene defines the hosting scene
  97579. */
  97580. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97581. /**
  97582. * Gets camera class name
  97583. * @returns AnaglyphGamepadCamera
  97584. */
  97585. getClassName(): string;
  97586. }
  97587. }
  97588. declare module BABYLON {
  97589. /**
  97590. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97591. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97592. */
  97593. export class AnaglyphUniversalCamera extends UniversalCamera {
  97594. /**
  97595. * Creates a new AnaglyphUniversalCamera
  97596. * @param name defines camera name
  97597. * @param position defines initial position
  97598. * @param interaxialDistance defines distance between each color axis
  97599. * @param scene defines the hosting scene
  97600. */
  97601. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97602. /**
  97603. * Gets camera class name
  97604. * @returns AnaglyphUniversalCamera
  97605. */
  97606. getClassName(): string;
  97607. }
  97608. }
  97609. declare module BABYLON {
  97610. /** @hidden */
  97611. export var stereoscopicInterlacePixelShader: {
  97612. name: string;
  97613. shader: string;
  97614. };
  97615. }
  97616. declare module BABYLON {
  97617. /**
  97618. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  97619. */
  97620. export class StereoscopicInterlacePostProcess extends PostProcess {
  97621. private _stepSize;
  97622. private _passedProcess;
  97623. /**
  97624. * Initializes a StereoscopicInterlacePostProcess
  97625. * @param name The name of the effect.
  97626. * @param rigCameras The rig cameras to be appled to the post process
  97627. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  97628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97629. * @param engine The engine which the post process will be applied. (default: current engine)
  97630. * @param reusable If the post process can be reused on the same frame. (default: false)
  97631. */
  97632. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  97633. }
  97634. }
  97635. declare module BABYLON {
  97636. /**
  97637. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  97638. * @see http://doc.babylonjs.com/features/cameras
  97639. */
  97640. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  97641. /**
  97642. * Creates a new StereoscopicArcRotateCamera
  97643. * @param name defines camera name
  97644. * @param alpha defines alpha angle (in radians)
  97645. * @param beta defines beta angle (in radians)
  97646. * @param radius defines radius
  97647. * @param target defines camera target
  97648. * @param interaxialDistance defines distance between each color axis
  97649. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97650. * @param scene defines the hosting scene
  97651. */
  97652. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97653. /**
  97654. * Gets camera class name
  97655. * @returns StereoscopicArcRotateCamera
  97656. */
  97657. getClassName(): string;
  97658. }
  97659. }
  97660. declare module BABYLON {
  97661. /**
  97662. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  97663. * @see http://doc.babylonjs.com/features/cameras
  97664. */
  97665. export class StereoscopicFreeCamera extends FreeCamera {
  97666. /**
  97667. * Creates a new StereoscopicFreeCamera
  97668. * @param name defines camera name
  97669. * @param position defines initial position
  97670. * @param interaxialDistance defines distance between each color axis
  97671. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97672. * @param scene defines the hosting scene
  97673. */
  97674. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97675. /**
  97676. * Gets camera class name
  97677. * @returns StereoscopicFreeCamera
  97678. */
  97679. getClassName(): string;
  97680. }
  97681. }
  97682. declare module BABYLON {
  97683. /**
  97684. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  97685. * @see http://doc.babylonjs.com/features/cameras
  97686. */
  97687. export class StereoscopicGamepadCamera extends GamepadCamera {
  97688. /**
  97689. * Creates a new StereoscopicGamepadCamera
  97690. * @param name defines camera name
  97691. * @param position defines initial position
  97692. * @param interaxialDistance defines distance between each color axis
  97693. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97694. * @param scene defines the hosting scene
  97695. */
  97696. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97697. /**
  97698. * Gets camera class name
  97699. * @returns StereoscopicGamepadCamera
  97700. */
  97701. getClassName(): string;
  97702. }
  97703. }
  97704. declare module BABYLON {
  97705. /**
  97706. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  97707. * @see http://doc.babylonjs.com/features/cameras
  97708. */
  97709. export class StereoscopicUniversalCamera extends UniversalCamera {
  97710. /**
  97711. * Creates a new StereoscopicUniversalCamera
  97712. * @param name defines camera name
  97713. * @param position defines initial position
  97714. * @param interaxialDistance defines distance between each color axis
  97715. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97716. * @param scene defines the hosting scene
  97717. */
  97718. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97719. /**
  97720. * Gets camera class name
  97721. * @returns StereoscopicUniversalCamera
  97722. */
  97723. getClassName(): string;
  97724. }
  97725. }
  97726. declare module BABYLON {
  97727. /**
  97728. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97729. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97730. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97731. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97732. */
  97733. export class VirtualJoysticksCamera extends FreeCamera {
  97734. /**
  97735. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97736. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97737. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97738. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97739. * @param name Define the name of the camera in the scene
  97740. * @param position Define the start position of the camera in the scene
  97741. * @param scene Define the scene the camera belongs to
  97742. */
  97743. constructor(name: string, position: Vector3, scene: Scene);
  97744. /**
  97745. * Gets the current object class name.
  97746. * @return the class name
  97747. */
  97748. getClassName(): string;
  97749. }
  97750. }
  97751. declare module BABYLON {
  97752. /**
  97753. * This represents all the required metrics to create a VR camera.
  97754. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97755. */
  97756. export class VRCameraMetrics {
  97757. /**
  97758. * Define the horizontal resolution off the screen.
  97759. */
  97760. hResolution: number;
  97761. /**
  97762. * Define the vertical resolution off the screen.
  97763. */
  97764. vResolution: number;
  97765. /**
  97766. * Define the horizontal screen size.
  97767. */
  97768. hScreenSize: number;
  97769. /**
  97770. * Define the vertical screen size.
  97771. */
  97772. vScreenSize: number;
  97773. /**
  97774. * Define the vertical screen center position.
  97775. */
  97776. vScreenCenter: number;
  97777. /**
  97778. * Define the distance of the eyes to the screen.
  97779. */
  97780. eyeToScreenDistance: number;
  97781. /**
  97782. * Define the distance between both lenses
  97783. */
  97784. lensSeparationDistance: number;
  97785. /**
  97786. * Define the distance between both viewer's eyes.
  97787. */
  97788. interpupillaryDistance: number;
  97789. /**
  97790. * Define the distortion factor of the VR postprocess.
  97791. * Please, touch with care.
  97792. */
  97793. distortionK: number[];
  97794. /**
  97795. * Define the chromatic aberration correction factors for the VR post process.
  97796. */
  97797. chromaAbCorrection: number[];
  97798. /**
  97799. * Define the scale factor of the post process.
  97800. * The smaller the better but the slower.
  97801. */
  97802. postProcessScaleFactor: number;
  97803. /**
  97804. * Define an offset for the lens center.
  97805. */
  97806. lensCenterOffset: number;
  97807. /**
  97808. * Define if the current vr camera should compensate the distortion of the lense or not.
  97809. */
  97810. compensateDistortion: boolean;
  97811. /**
  97812. * Defines if multiview should be enabled when rendering (Default: false)
  97813. */
  97814. multiviewEnabled: boolean;
  97815. /**
  97816. * Gets the rendering aspect ratio based on the provided resolutions.
  97817. */
  97818. readonly aspectRatio: number;
  97819. /**
  97820. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97821. */
  97822. readonly aspectRatioFov: number;
  97823. /**
  97824. * @hidden
  97825. */
  97826. readonly leftHMatrix: Matrix;
  97827. /**
  97828. * @hidden
  97829. */
  97830. readonly rightHMatrix: Matrix;
  97831. /**
  97832. * @hidden
  97833. */
  97834. readonly leftPreViewMatrix: Matrix;
  97835. /**
  97836. * @hidden
  97837. */
  97838. readonly rightPreViewMatrix: Matrix;
  97839. /**
  97840. * Get the default VRMetrics based on the most generic setup.
  97841. * @returns the default vr metrics
  97842. */
  97843. static GetDefault(): VRCameraMetrics;
  97844. }
  97845. }
  97846. declare module BABYLON {
  97847. /** @hidden */
  97848. export var vrDistortionCorrectionPixelShader: {
  97849. name: string;
  97850. shader: string;
  97851. };
  97852. }
  97853. declare module BABYLON {
  97854. /**
  97855. * VRDistortionCorrectionPostProcess used for mobile VR
  97856. */
  97857. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97858. private _isRightEye;
  97859. private _distortionFactors;
  97860. private _postProcessScaleFactor;
  97861. private _lensCenterOffset;
  97862. private _scaleIn;
  97863. private _scaleFactor;
  97864. private _lensCenter;
  97865. /**
  97866. * Initializes the VRDistortionCorrectionPostProcess
  97867. * @param name The name of the effect.
  97868. * @param camera The camera to apply the render pass to.
  97869. * @param isRightEye If this is for the right eye distortion
  97870. * @param vrMetrics All the required metrics for the VR camera
  97871. */
  97872. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97873. }
  97874. }
  97875. declare module BABYLON {
  97876. /**
  97877. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97878. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97879. */
  97880. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97881. /**
  97882. * Creates a new VRDeviceOrientationArcRotateCamera
  97883. * @param name defines camera name
  97884. * @param alpha defines the camera rotation along the logitudinal axis
  97885. * @param beta defines the camera rotation along the latitudinal axis
  97886. * @param radius defines the camera distance from its target
  97887. * @param target defines the camera target
  97888. * @param scene defines the scene the camera belongs to
  97889. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97890. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97891. */
  97892. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97893. /**
  97894. * Gets camera class name
  97895. * @returns VRDeviceOrientationArcRotateCamera
  97896. */
  97897. getClassName(): string;
  97898. }
  97899. }
  97900. declare module BABYLON {
  97901. /**
  97902. * Camera used to simulate VR rendering (based on FreeCamera)
  97903. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97904. */
  97905. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97906. /**
  97907. * Creates a new VRDeviceOrientationFreeCamera
  97908. * @param name defines camera name
  97909. * @param position defines the start position of the camera
  97910. * @param scene defines the scene the camera belongs to
  97911. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97912. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97913. */
  97914. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97915. /**
  97916. * Gets camera class name
  97917. * @returns VRDeviceOrientationFreeCamera
  97918. */
  97919. getClassName(): string;
  97920. }
  97921. }
  97922. declare module BABYLON {
  97923. /**
  97924. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97925. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97926. */
  97927. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97928. /**
  97929. * Creates a new VRDeviceOrientationGamepadCamera
  97930. * @param name defines camera name
  97931. * @param position defines the start position of the camera
  97932. * @param scene defines the scene the camera belongs to
  97933. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97934. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97935. */
  97936. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97937. /**
  97938. * Gets camera class name
  97939. * @returns VRDeviceOrientationGamepadCamera
  97940. */
  97941. getClassName(): string;
  97942. }
  97943. }
  97944. declare module BABYLON {
  97945. /**
  97946. * Defines supported buttons for XBox360 compatible gamepads
  97947. */
  97948. export enum Xbox360Button {
  97949. /** A */
  97950. A = 0,
  97951. /** B */
  97952. B = 1,
  97953. /** X */
  97954. X = 2,
  97955. /** Y */
  97956. Y = 3,
  97957. /** Start */
  97958. Start = 4,
  97959. /** Back */
  97960. Back = 5,
  97961. /** Left button */
  97962. LB = 6,
  97963. /** Right button */
  97964. RB = 7,
  97965. /** Left stick */
  97966. LeftStick = 8,
  97967. /** Right stick */
  97968. RightStick = 9
  97969. }
  97970. /** Defines values for XBox360 DPad */
  97971. export enum Xbox360Dpad {
  97972. /** Up */
  97973. Up = 0,
  97974. /** Down */
  97975. Down = 1,
  97976. /** Left */
  97977. Left = 2,
  97978. /** Right */
  97979. Right = 3
  97980. }
  97981. /**
  97982. * Defines a XBox360 gamepad
  97983. */
  97984. export class Xbox360Pad extends Gamepad {
  97985. private _leftTrigger;
  97986. private _rightTrigger;
  97987. private _onlefttriggerchanged;
  97988. private _onrighttriggerchanged;
  97989. private _onbuttondown;
  97990. private _onbuttonup;
  97991. private _ondpaddown;
  97992. private _ondpadup;
  97993. /** Observable raised when a button is pressed */
  97994. onButtonDownObservable: Observable<Xbox360Button>;
  97995. /** Observable raised when a button is released */
  97996. onButtonUpObservable: Observable<Xbox360Button>;
  97997. /** Observable raised when a pad is pressed */
  97998. onPadDownObservable: Observable<Xbox360Dpad>;
  97999. /** Observable raised when a pad is released */
  98000. onPadUpObservable: Observable<Xbox360Dpad>;
  98001. private _buttonA;
  98002. private _buttonB;
  98003. private _buttonX;
  98004. private _buttonY;
  98005. private _buttonBack;
  98006. private _buttonStart;
  98007. private _buttonLB;
  98008. private _buttonRB;
  98009. private _buttonLeftStick;
  98010. private _buttonRightStick;
  98011. private _dPadUp;
  98012. private _dPadDown;
  98013. private _dPadLeft;
  98014. private _dPadRight;
  98015. private _isXboxOnePad;
  98016. /**
  98017. * Creates a new XBox360 gamepad object
  98018. * @param id defines the id of this gamepad
  98019. * @param index defines its index
  98020. * @param gamepad defines the internal HTML gamepad object
  98021. * @param xboxOne defines if it is a XBox One gamepad
  98022. */
  98023. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  98024. /**
  98025. * Defines the callback to call when left trigger is pressed
  98026. * @param callback defines the callback to use
  98027. */
  98028. onlefttriggerchanged(callback: (value: number) => void): void;
  98029. /**
  98030. * Defines the callback to call when right trigger is pressed
  98031. * @param callback defines the callback to use
  98032. */
  98033. onrighttriggerchanged(callback: (value: number) => void): void;
  98034. /**
  98035. * Gets the left trigger value
  98036. */
  98037. /**
  98038. * Sets the left trigger value
  98039. */
  98040. leftTrigger: number;
  98041. /**
  98042. * Gets the right trigger value
  98043. */
  98044. /**
  98045. * Sets the right trigger value
  98046. */
  98047. rightTrigger: number;
  98048. /**
  98049. * Defines the callback to call when a button is pressed
  98050. * @param callback defines the callback to use
  98051. */
  98052. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  98053. /**
  98054. * Defines the callback to call when a button is released
  98055. * @param callback defines the callback to use
  98056. */
  98057. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  98058. /**
  98059. * Defines the callback to call when a pad is pressed
  98060. * @param callback defines the callback to use
  98061. */
  98062. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  98063. /**
  98064. * Defines the callback to call when a pad is released
  98065. * @param callback defines the callback to use
  98066. */
  98067. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  98068. private _setButtonValue;
  98069. private _setDPadValue;
  98070. /**
  98071. * Gets the value of the `A` button
  98072. */
  98073. /**
  98074. * Sets the value of the `A` button
  98075. */
  98076. buttonA: number;
  98077. /**
  98078. * Gets the value of the `B` button
  98079. */
  98080. /**
  98081. * Sets the value of the `B` button
  98082. */
  98083. buttonB: number;
  98084. /**
  98085. * Gets the value of the `X` button
  98086. */
  98087. /**
  98088. * Sets the value of the `X` button
  98089. */
  98090. buttonX: number;
  98091. /**
  98092. * Gets the value of the `Y` button
  98093. */
  98094. /**
  98095. * Sets the value of the `Y` button
  98096. */
  98097. buttonY: number;
  98098. /**
  98099. * Gets the value of the `Start` button
  98100. */
  98101. /**
  98102. * Sets the value of the `Start` button
  98103. */
  98104. buttonStart: number;
  98105. /**
  98106. * Gets the value of the `Back` button
  98107. */
  98108. /**
  98109. * Sets the value of the `Back` button
  98110. */
  98111. buttonBack: number;
  98112. /**
  98113. * Gets the value of the `Left` button
  98114. */
  98115. /**
  98116. * Sets the value of the `Left` button
  98117. */
  98118. buttonLB: number;
  98119. /**
  98120. * Gets the value of the `Right` button
  98121. */
  98122. /**
  98123. * Sets the value of the `Right` button
  98124. */
  98125. buttonRB: number;
  98126. /**
  98127. * Gets the value of the Left joystick
  98128. */
  98129. /**
  98130. * Sets the value of the Left joystick
  98131. */
  98132. buttonLeftStick: number;
  98133. /**
  98134. * Gets the value of the Right joystick
  98135. */
  98136. /**
  98137. * Sets the value of the Right joystick
  98138. */
  98139. buttonRightStick: number;
  98140. /**
  98141. * Gets the value of D-pad up
  98142. */
  98143. /**
  98144. * Sets the value of D-pad up
  98145. */
  98146. dPadUp: number;
  98147. /**
  98148. * Gets the value of D-pad down
  98149. */
  98150. /**
  98151. * Sets the value of D-pad down
  98152. */
  98153. dPadDown: number;
  98154. /**
  98155. * Gets the value of D-pad left
  98156. */
  98157. /**
  98158. * Sets the value of D-pad left
  98159. */
  98160. dPadLeft: number;
  98161. /**
  98162. * Gets the value of D-pad right
  98163. */
  98164. /**
  98165. * Sets the value of D-pad right
  98166. */
  98167. dPadRight: number;
  98168. /**
  98169. * Force the gamepad to synchronize with device values
  98170. */
  98171. update(): void;
  98172. /**
  98173. * Disposes the gamepad
  98174. */
  98175. dispose(): void;
  98176. }
  98177. }
  98178. declare module BABYLON {
  98179. /**
  98180. * Base class of materials working in push mode in babylon JS
  98181. * @hidden
  98182. */
  98183. export class PushMaterial extends Material {
  98184. protected _activeEffect: Effect;
  98185. protected _normalMatrix: Matrix;
  98186. /**
  98187. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98188. * This means that the material can keep using a previous shader while a new one is being compiled.
  98189. * This is mostly used when shader parallel compilation is supported (true by default)
  98190. */
  98191. allowShaderHotSwapping: boolean;
  98192. constructor(name: string, scene: Scene);
  98193. getEffect(): Effect;
  98194. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98195. /**
  98196. * Binds the given world matrix to the active effect
  98197. *
  98198. * @param world the matrix to bind
  98199. */
  98200. bindOnlyWorldMatrix(world: Matrix): void;
  98201. /**
  98202. * Binds the given normal matrix to the active effect
  98203. *
  98204. * @param normalMatrix the matrix to bind
  98205. */
  98206. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98207. bind(world: Matrix, mesh?: Mesh): void;
  98208. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98209. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98210. }
  98211. }
  98212. declare module BABYLON {
  98213. /**
  98214. * This groups all the flags used to control the materials channel.
  98215. */
  98216. export class MaterialFlags {
  98217. private static _DiffuseTextureEnabled;
  98218. /**
  98219. * Are diffuse textures enabled in the application.
  98220. */
  98221. static DiffuseTextureEnabled: boolean;
  98222. private static _AmbientTextureEnabled;
  98223. /**
  98224. * Are ambient textures enabled in the application.
  98225. */
  98226. static AmbientTextureEnabled: boolean;
  98227. private static _OpacityTextureEnabled;
  98228. /**
  98229. * Are opacity textures enabled in the application.
  98230. */
  98231. static OpacityTextureEnabled: boolean;
  98232. private static _ReflectionTextureEnabled;
  98233. /**
  98234. * Are reflection textures enabled in the application.
  98235. */
  98236. static ReflectionTextureEnabled: boolean;
  98237. private static _EmissiveTextureEnabled;
  98238. /**
  98239. * Are emissive textures enabled in the application.
  98240. */
  98241. static EmissiveTextureEnabled: boolean;
  98242. private static _SpecularTextureEnabled;
  98243. /**
  98244. * Are specular textures enabled in the application.
  98245. */
  98246. static SpecularTextureEnabled: boolean;
  98247. private static _BumpTextureEnabled;
  98248. /**
  98249. * Are bump textures enabled in the application.
  98250. */
  98251. static BumpTextureEnabled: boolean;
  98252. private static _LightmapTextureEnabled;
  98253. /**
  98254. * Are lightmap textures enabled in the application.
  98255. */
  98256. static LightmapTextureEnabled: boolean;
  98257. private static _RefractionTextureEnabled;
  98258. /**
  98259. * Are refraction textures enabled in the application.
  98260. */
  98261. static RefractionTextureEnabled: boolean;
  98262. private static _ColorGradingTextureEnabled;
  98263. /**
  98264. * Are color grading textures enabled in the application.
  98265. */
  98266. static ColorGradingTextureEnabled: boolean;
  98267. private static _FresnelEnabled;
  98268. /**
  98269. * Are fresnels enabled in the application.
  98270. */
  98271. static FresnelEnabled: boolean;
  98272. private static _ClearCoatTextureEnabled;
  98273. /**
  98274. * Are clear coat textures enabled in the application.
  98275. */
  98276. static ClearCoatTextureEnabled: boolean;
  98277. private static _ClearCoatBumpTextureEnabled;
  98278. /**
  98279. * Are clear coat bump textures enabled in the application.
  98280. */
  98281. static ClearCoatBumpTextureEnabled: boolean;
  98282. private static _ClearCoatTintTextureEnabled;
  98283. /**
  98284. * Are clear coat tint textures enabled in the application.
  98285. */
  98286. static ClearCoatTintTextureEnabled: boolean;
  98287. private static _SheenTextureEnabled;
  98288. /**
  98289. * Are sheen textures enabled in the application.
  98290. */
  98291. static SheenTextureEnabled: boolean;
  98292. private static _AnisotropicTextureEnabled;
  98293. /**
  98294. * Are anisotropic textures enabled in the application.
  98295. */
  98296. static AnisotropicTextureEnabled: boolean;
  98297. private static _ThicknessTextureEnabled;
  98298. /**
  98299. * Are thickness textures enabled in the application.
  98300. */
  98301. static ThicknessTextureEnabled: boolean;
  98302. }
  98303. }
  98304. declare module BABYLON {
  98305. /** @hidden */
  98306. export var defaultFragmentDeclaration: {
  98307. name: string;
  98308. shader: string;
  98309. };
  98310. }
  98311. declare module BABYLON {
  98312. /** @hidden */
  98313. export var defaultUboDeclaration: {
  98314. name: string;
  98315. shader: string;
  98316. };
  98317. }
  98318. declare module BABYLON {
  98319. /** @hidden */
  98320. export var lightFragmentDeclaration: {
  98321. name: string;
  98322. shader: string;
  98323. };
  98324. }
  98325. declare module BABYLON {
  98326. /** @hidden */
  98327. export var lightUboDeclaration: {
  98328. name: string;
  98329. shader: string;
  98330. };
  98331. }
  98332. declare module BABYLON {
  98333. /** @hidden */
  98334. export var lightsFragmentFunctions: {
  98335. name: string;
  98336. shader: string;
  98337. };
  98338. }
  98339. declare module BABYLON {
  98340. /** @hidden */
  98341. export var shadowsFragmentFunctions: {
  98342. name: string;
  98343. shader: string;
  98344. };
  98345. }
  98346. declare module BABYLON {
  98347. /** @hidden */
  98348. export var fresnelFunction: {
  98349. name: string;
  98350. shader: string;
  98351. };
  98352. }
  98353. declare module BABYLON {
  98354. /** @hidden */
  98355. export var reflectionFunction: {
  98356. name: string;
  98357. shader: string;
  98358. };
  98359. }
  98360. declare module BABYLON {
  98361. /** @hidden */
  98362. export var bumpFragmentFunctions: {
  98363. name: string;
  98364. shader: string;
  98365. };
  98366. }
  98367. declare module BABYLON {
  98368. /** @hidden */
  98369. export var logDepthDeclaration: {
  98370. name: string;
  98371. shader: string;
  98372. };
  98373. }
  98374. declare module BABYLON {
  98375. /** @hidden */
  98376. export var bumpFragment: {
  98377. name: string;
  98378. shader: string;
  98379. };
  98380. }
  98381. declare module BABYLON {
  98382. /** @hidden */
  98383. export var depthPrePass: {
  98384. name: string;
  98385. shader: string;
  98386. };
  98387. }
  98388. declare module BABYLON {
  98389. /** @hidden */
  98390. export var lightFragment: {
  98391. name: string;
  98392. shader: string;
  98393. };
  98394. }
  98395. declare module BABYLON {
  98396. /** @hidden */
  98397. export var logDepthFragment: {
  98398. name: string;
  98399. shader: string;
  98400. };
  98401. }
  98402. declare module BABYLON {
  98403. /** @hidden */
  98404. export var defaultPixelShader: {
  98405. name: string;
  98406. shader: string;
  98407. };
  98408. }
  98409. declare module BABYLON {
  98410. /** @hidden */
  98411. export var defaultVertexDeclaration: {
  98412. name: string;
  98413. shader: string;
  98414. };
  98415. }
  98416. declare module BABYLON {
  98417. /** @hidden */
  98418. export var bumpVertexDeclaration: {
  98419. name: string;
  98420. shader: string;
  98421. };
  98422. }
  98423. declare module BABYLON {
  98424. /** @hidden */
  98425. export var bumpVertex: {
  98426. name: string;
  98427. shader: string;
  98428. };
  98429. }
  98430. declare module BABYLON {
  98431. /** @hidden */
  98432. export var fogVertex: {
  98433. name: string;
  98434. shader: string;
  98435. };
  98436. }
  98437. declare module BABYLON {
  98438. /** @hidden */
  98439. export var shadowsVertex: {
  98440. name: string;
  98441. shader: string;
  98442. };
  98443. }
  98444. declare module BABYLON {
  98445. /** @hidden */
  98446. export var pointCloudVertex: {
  98447. name: string;
  98448. shader: string;
  98449. };
  98450. }
  98451. declare module BABYLON {
  98452. /** @hidden */
  98453. export var logDepthVertex: {
  98454. name: string;
  98455. shader: string;
  98456. };
  98457. }
  98458. declare module BABYLON {
  98459. /** @hidden */
  98460. export var defaultVertexShader: {
  98461. name: string;
  98462. shader: string;
  98463. };
  98464. }
  98465. declare module BABYLON {
  98466. /** @hidden */
  98467. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98468. MAINUV1: boolean;
  98469. MAINUV2: boolean;
  98470. DIFFUSE: boolean;
  98471. DIFFUSEDIRECTUV: number;
  98472. AMBIENT: boolean;
  98473. AMBIENTDIRECTUV: number;
  98474. OPACITY: boolean;
  98475. OPACITYDIRECTUV: number;
  98476. OPACITYRGB: boolean;
  98477. REFLECTION: boolean;
  98478. EMISSIVE: boolean;
  98479. EMISSIVEDIRECTUV: number;
  98480. SPECULAR: boolean;
  98481. SPECULARDIRECTUV: number;
  98482. BUMP: boolean;
  98483. BUMPDIRECTUV: number;
  98484. PARALLAX: boolean;
  98485. PARALLAXOCCLUSION: boolean;
  98486. SPECULAROVERALPHA: boolean;
  98487. CLIPPLANE: boolean;
  98488. CLIPPLANE2: boolean;
  98489. CLIPPLANE3: boolean;
  98490. CLIPPLANE4: boolean;
  98491. ALPHATEST: boolean;
  98492. DEPTHPREPASS: boolean;
  98493. ALPHAFROMDIFFUSE: boolean;
  98494. POINTSIZE: boolean;
  98495. FOG: boolean;
  98496. SPECULARTERM: boolean;
  98497. DIFFUSEFRESNEL: boolean;
  98498. OPACITYFRESNEL: boolean;
  98499. REFLECTIONFRESNEL: boolean;
  98500. REFRACTIONFRESNEL: boolean;
  98501. EMISSIVEFRESNEL: boolean;
  98502. FRESNEL: boolean;
  98503. NORMAL: boolean;
  98504. UV1: boolean;
  98505. UV2: boolean;
  98506. VERTEXCOLOR: boolean;
  98507. VERTEXALPHA: boolean;
  98508. NUM_BONE_INFLUENCERS: number;
  98509. BonesPerMesh: number;
  98510. BONETEXTURE: boolean;
  98511. INSTANCES: boolean;
  98512. GLOSSINESS: boolean;
  98513. ROUGHNESS: boolean;
  98514. EMISSIVEASILLUMINATION: boolean;
  98515. LINKEMISSIVEWITHDIFFUSE: boolean;
  98516. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98517. LIGHTMAP: boolean;
  98518. LIGHTMAPDIRECTUV: number;
  98519. OBJECTSPACE_NORMALMAP: boolean;
  98520. USELIGHTMAPASSHADOWMAP: boolean;
  98521. REFLECTIONMAP_3D: boolean;
  98522. REFLECTIONMAP_SPHERICAL: boolean;
  98523. REFLECTIONMAP_PLANAR: boolean;
  98524. REFLECTIONMAP_CUBIC: boolean;
  98525. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98526. REFLECTIONMAP_PROJECTION: boolean;
  98527. REFLECTIONMAP_SKYBOX: boolean;
  98528. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98529. REFLECTIONMAP_EXPLICIT: boolean;
  98530. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98531. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98532. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98533. INVERTCUBICMAP: boolean;
  98534. LOGARITHMICDEPTH: boolean;
  98535. REFRACTION: boolean;
  98536. REFRACTIONMAP_3D: boolean;
  98537. REFLECTIONOVERALPHA: boolean;
  98538. TWOSIDEDLIGHTING: boolean;
  98539. SHADOWFLOAT: boolean;
  98540. MORPHTARGETS: boolean;
  98541. MORPHTARGETS_NORMAL: boolean;
  98542. MORPHTARGETS_TANGENT: boolean;
  98543. NUM_MORPH_INFLUENCERS: number;
  98544. NONUNIFORMSCALING: boolean;
  98545. PREMULTIPLYALPHA: boolean;
  98546. IMAGEPROCESSING: boolean;
  98547. VIGNETTE: boolean;
  98548. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98549. VIGNETTEBLENDMODEOPAQUE: boolean;
  98550. TONEMAPPING: boolean;
  98551. TONEMAPPING_ACES: boolean;
  98552. CONTRAST: boolean;
  98553. COLORCURVES: boolean;
  98554. COLORGRADING: boolean;
  98555. COLORGRADING3D: boolean;
  98556. SAMPLER3DGREENDEPTH: boolean;
  98557. SAMPLER3DBGRMAP: boolean;
  98558. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98559. MULTIVIEW: boolean;
  98560. /**
  98561. * If the reflection texture on this material is in linear color space
  98562. * @hidden
  98563. */
  98564. IS_REFLECTION_LINEAR: boolean;
  98565. /**
  98566. * If the refraction texture on this material is in linear color space
  98567. * @hidden
  98568. */
  98569. IS_REFRACTION_LINEAR: boolean;
  98570. EXPOSURE: boolean;
  98571. constructor();
  98572. setReflectionMode(modeToEnable: string): void;
  98573. }
  98574. /**
  98575. * This is the default material used in Babylon. It is the best trade off between quality
  98576. * and performances.
  98577. * @see http://doc.babylonjs.com/babylon101/materials
  98578. */
  98579. export class StandardMaterial extends PushMaterial {
  98580. private _diffuseTexture;
  98581. /**
  98582. * The basic texture of the material as viewed under a light.
  98583. */
  98584. diffuseTexture: Nullable<BaseTexture>;
  98585. private _ambientTexture;
  98586. /**
  98587. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98588. */
  98589. ambientTexture: Nullable<BaseTexture>;
  98590. private _opacityTexture;
  98591. /**
  98592. * Define the transparency of the material from a texture.
  98593. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98594. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98595. */
  98596. opacityTexture: Nullable<BaseTexture>;
  98597. private _reflectionTexture;
  98598. /**
  98599. * Define the texture used to display the reflection.
  98600. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98601. */
  98602. reflectionTexture: Nullable<BaseTexture>;
  98603. private _emissiveTexture;
  98604. /**
  98605. * Define texture of the material as if self lit.
  98606. * This will be mixed in the final result even in the absence of light.
  98607. */
  98608. emissiveTexture: Nullable<BaseTexture>;
  98609. private _specularTexture;
  98610. /**
  98611. * Define how the color and intensity of the highlight given by the light in the material.
  98612. */
  98613. specularTexture: Nullable<BaseTexture>;
  98614. private _bumpTexture;
  98615. /**
  98616. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98617. * 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.
  98618. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98619. */
  98620. bumpTexture: Nullable<BaseTexture>;
  98621. private _lightmapTexture;
  98622. /**
  98623. * Complex lighting can be computationally expensive to compute at runtime.
  98624. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98625. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98626. */
  98627. lightmapTexture: Nullable<BaseTexture>;
  98628. private _refractionTexture;
  98629. /**
  98630. * Define the texture used to display the refraction.
  98631. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98632. */
  98633. refractionTexture: Nullable<BaseTexture>;
  98634. /**
  98635. * The color of the material lit by the environmental background lighting.
  98636. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98637. */
  98638. ambientColor: Color3;
  98639. /**
  98640. * The basic color of the material as viewed under a light.
  98641. */
  98642. diffuseColor: Color3;
  98643. /**
  98644. * Define how the color and intensity of the highlight given by the light in the material.
  98645. */
  98646. specularColor: Color3;
  98647. /**
  98648. * Define the color of the material as if self lit.
  98649. * This will be mixed in the final result even in the absence of light.
  98650. */
  98651. emissiveColor: Color3;
  98652. /**
  98653. * Defines how sharp are the highlights in the material.
  98654. * The bigger the value the sharper giving a more glossy feeling to the result.
  98655. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98656. */
  98657. specularPower: number;
  98658. private _useAlphaFromDiffuseTexture;
  98659. /**
  98660. * Does the transparency come from the diffuse texture alpha channel.
  98661. */
  98662. useAlphaFromDiffuseTexture: boolean;
  98663. private _useEmissiveAsIllumination;
  98664. /**
  98665. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98666. */
  98667. useEmissiveAsIllumination: boolean;
  98668. private _linkEmissiveWithDiffuse;
  98669. /**
  98670. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98671. * the emissive level when the final color is close to one.
  98672. */
  98673. linkEmissiveWithDiffuse: boolean;
  98674. private _useSpecularOverAlpha;
  98675. /**
  98676. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98677. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98678. */
  98679. useSpecularOverAlpha: boolean;
  98680. private _useReflectionOverAlpha;
  98681. /**
  98682. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98683. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98684. */
  98685. useReflectionOverAlpha: boolean;
  98686. private _disableLighting;
  98687. /**
  98688. * Does lights from the scene impacts this material.
  98689. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98690. */
  98691. disableLighting: boolean;
  98692. private _useObjectSpaceNormalMap;
  98693. /**
  98694. * Allows using an object space normal map (instead of tangent space).
  98695. */
  98696. useObjectSpaceNormalMap: boolean;
  98697. private _useParallax;
  98698. /**
  98699. * Is parallax enabled or not.
  98700. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98701. */
  98702. useParallax: boolean;
  98703. private _useParallaxOcclusion;
  98704. /**
  98705. * Is parallax occlusion enabled or not.
  98706. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98707. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98708. */
  98709. useParallaxOcclusion: boolean;
  98710. /**
  98711. * 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.
  98712. */
  98713. parallaxScaleBias: number;
  98714. private _roughness;
  98715. /**
  98716. * Helps to define how blurry the reflections should appears in the material.
  98717. */
  98718. roughness: number;
  98719. /**
  98720. * In case of refraction, define the value of the indice of refraction.
  98721. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98722. */
  98723. indexOfRefraction: number;
  98724. /**
  98725. * Invert the refraction texture alongside the y axis.
  98726. * It can be useful with procedural textures or probe for instance.
  98727. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98728. */
  98729. invertRefractionY: boolean;
  98730. /**
  98731. * Defines the alpha limits in alpha test mode.
  98732. */
  98733. alphaCutOff: number;
  98734. private _useLightmapAsShadowmap;
  98735. /**
  98736. * In case of light mapping, define whether the map contains light or shadow informations.
  98737. */
  98738. useLightmapAsShadowmap: boolean;
  98739. private _diffuseFresnelParameters;
  98740. /**
  98741. * Define the diffuse fresnel parameters of the material.
  98742. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98743. */
  98744. diffuseFresnelParameters: FresnelParameters;
  98745. private _opacityFresnelParameters;
  98746. /**
  98747. * Define the opacity fresnel parameters of the material.
  98748. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98749. */
  98750. opacityFresnelParameters: FresnelParameters;
  98751. private _reflectionFresnelParameters;
  98752. /**
  98753. * Define the reflection fresnel parameters of the material.
  98754. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98755. */
  98756. reflectionFresnelParameters: FresnelParameters;
  98757. private _refractionFresnelParameters;
  98758. /**
  98759. * Define the refraction fresnel parameters of the material.
  98760. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98761. */
  98762. refractionFresnelParameters: FresnelParameters;
  98763. private _emissiveFresnelParameters;
  98764. /**
  98765. * Define the emissive fresnel parameters of the material.
  98766. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98767. */
  98768. emissiveFresnelParameters: FresnelParameters;
  98769. private _useReflectionFresnelFromSpecular;
  98770. /**
  98771. * If true automatically deducts the fresnels values from the material specularity.
  98772. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98773. */
  98774. useReflectionFresnelFromSpecular: boolean;
  98775. private _useGlossinessFromSpecularMapAlpha;
  98776. /**
  98777. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98778. */
  98779. useGlossinessFromSpecularMapAlpha: boolean;
  98780. private _maxSimultaneousLights;
  98781. /**
  98782. * Defines the maximum number of lights that can be used in the material
  98783. */
  98784. maxSimultaneousLights: number;
  98785. private _invertNormalMapX;
  98786. /**
  98787. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98788. */
  98789. invertNormalMapX: boolean;
  98790. private _invertNormalMapY;
  98791. /**
  98792. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98793. */
  98794. invertNormalMapY: boolean;
  98795. private _twoSidedLighting;
  98796. /**
  98797. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98798. */
  98799. twoSidedLighting: boolean;
  98800. /**
  98801. * Default configuration related to image processing available in the standard Material.
  98802. */
  98803. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98804. /**
  98805. * Gets the image processing configuration used either in this material.
  98806. */
  98807. /**
  98808. * Sets the Default image processing configuration used either in the this material.
  98809. *
  98810. * If sets to null, the scene one is in use.
  98811. */
  98812. imageProcessingConfiguration: ImageProcessingConfiguration;
  98813. /**
  98814. * Keep track of the image processing observer to allow dispose and replace.
  98815. */
  98816. private _imageProcessingObserver;
  98817. /**
  98818. * Attaches a new image processing configuration to the Standard Material.
  98819. * @param configuration
  98820. */
  98821. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98822. /**
  98823. * Gets wether the color curves effect is enabled.
  98824. */
  98825. /**
  98826. * Sets wether the color curves effect is enabled.
  98827. */
  98828. cameraColorCurvesEnabled: boolean;
  98829. /**
  98830. * Gets wether the color grading effect is enabled.
  98831. */
  98832. /**
  98833. * Gets wether the color grading effect is enabled.
  98834. */
  98835. cameraColorGradingEnabled: boolean;
  98836. /**
  98837. * Gets wether tonemapping is enabled or not.
  98838. */
  98839. /**
  98840. * Sets wether tonemapping is enabled or not
  98841. */
  98842. cameraToneMappingEnabled: boolean;
  98843. /**
  98844. * The camera exposure used on this material.
  98845. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98846. * This corresponds to a photographic exposure.
  98847. */
  98848. /**
  98849. * The camera exposure used on this material.
  98850. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98851. * This corresponds to a photographic exposure.
  98852. */
  98853. cameraExposure: number;
  98854. /**
  98855. * Gets The camera contrast used on this material.
  98856. */
  98857. /**
  98858. * Sets The camera contrast used on this material.
  98859. */
  98860. cameraContrast: number;
  98861. /**
  98862. * Gets the Color Grading 2D Lookup Texture.
  98863. */
  98864. /**
  98865. * Sets the Color Grading 2D Lookup Texture.
  98866. */
  98867. cameraColorGradingTexture: Nullable<BaseTexture>;
  98868. /**
  98869. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98870. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98871. * 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;
  98872. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98873. */
  98874. /**
  98875. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98876. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98877. * 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;
  98878. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98879. */
  98880. cameraColorCurves: Nullable<ColorCurves>;
  98881. /**
  98882. * Custom callback helping to override the default shader used in the material.
  98883. */
  98884. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98885. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98886. protected _worldViewProjectionMatrix: Matrix;
  98887. protected _globalAmbientColor: Color3;
  98888. protected _useLogarithmicDepth: boolean;
  98889. /**
  98890. * Instantiates a new standard material.
  98891. * This is the default material used in Babylon. It is the best trade off between quality
  98892. * and performances.
  98893. * @see http://doc.babylonjs.com/babylon101/materials
  98894. * @param name Define the name of the material in the scene
  98895. * @param scene Define the scene the material belong to
  98896. */
  98897. constructor(name: string, scene: Scene);
  98898. /**
  98899. * Gets a boolean indicating that current material needs to register RTT
  98900. */
  98901. readonly hasRenderTargetTextures: boolean;
  98902. /**
  98903. * Gets the current class name of the material e.g. "StandardMaterial"
  98904. * Mainly use in serialization.
  98905. * @returns the class name
  98906. */
  98907. getClassName(): string;
  98908. /**
  98909. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98910. * You can try switching to logarithmic depth.
  98911. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98912. */
  98913. useLogarithmicDepth: boolean;
  98914. /**
  98915. * Specifies if the material will require alpha blending
  98916. * @returns a boolean specifying if alpha blending is needed
  98917. */
  98918. needAlphaBlending(): boolean;
  98919. /**
  98920. * Specifies if this material should be rendered in alpha test mode
  98921. * @returns a boolean specifying if an alpha test is needed.
  98922. */
  98923. needAlphaTesting(): boolean;
  98924. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98925. /**
  98926. * Get the texture used for alpha test purpose.
  98927. * @returns the diffuse texture in case of the standard material.
  98928. */
  98929. getAlphaTestTexture(): Nullable<BaseTexture>;
  98930. /**
  98931. * Get if the submesh is ready to be used and all its information available.
  98932. * Child classes can use it to update shaders
  98933. * @param mesh defines the mesh to check
  98934. * @param subMesh defines which submesh to check
  98935. * @param useInstances specifies that instances should be used
  98936. * @returns a boolean indicating that the submesh is ready or not
  98937. */
  98938. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98939. /**
  98940. * Builds the material UBO layouts.
  98941. * Used internally during the effect preparation.
  98942. */
  98943. buildUniformLayout(): void;
  98944. /**
  98945. * Unbinds the material from the mesh
  98946. */
  98947. unbind(): void;
  98948. /**
  98949. * Binds the submesh to this material by preparing the effect and shader to draw
  98950. * @param world defines the world transformation matrix
  98951. * @param mesh defines the mesh containing the submesh
  98952. * @param subMesh defines the submesh to bind the material to
  98953. */
  98954. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98955. /**
  98956. * Get the list of animatables in the material.
  98957. * @returns the list of animatables object used in the material
  98958. */
  98959. getAnimatables(): IAnimatable[];
  98960. /**
  98961. * Gets the active textures from the material
  98962. * @returns an array of textures
  98963. */
  98964. getActiveTextures(): BaseTexture[];
  98965. /**
  98966. * Specifies if the material uses a texture
  98967. * @param texture defines the texture to check against the material
  98968. * @returns a boolean specifying if the material uses the texture
  98969. */
  98970. hasTexture(texture: BaseTexture): boolean;
  98971. /**
  98972. * Disposes the material
  98973. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98974. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98975. */
  98976. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98977. /**
  98978. * Makes a duplicate of the material, and gives it a new name
  98979. * @param name defines the new name for the duplicated material
  98980. * @returns the cloned material
  98981. */
  98982. clone(name: string): StandardMaterial;
  98983. /**
  98984. * Serializes this material in a JSON representation
  98985. * @returns the serialized material object
  98986. */
  98987. serialize(): any;
  98988. /**
  98989. * Creates a standard material from parsed material data
  98990. * @param source defines the JSON representation of the material
  98991. * @param scene defines the hosting scene
  98992. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98993. * @returns a new standard material
  98994. */
  98995. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98996. /**
  98997. * Are diffuse textures enabled in the application.
  98998. */
  98999. static DiffuseTextureEnabled: boolean;
  99000. /**
  99001. * Are ambient textures enabled in the application.
  99002. */
  99003. static AmbientTextureEnabled: boolean;
  99004. /**
  99005. * Are opacity textures enabled in the application.
  99006. */
  99007. static OpacityTextureEnabled: boolean;
  99008. /**
  99009. * Are reflection textures enabled in the application.
  99010. */
  99011. static ReflectionTextureEnabled: boolean;
  99012. /**
  99013. * Are emissive textures enabled in the application.
  99014. */
  99015. static EmissiveTextureEnabled: boolean;
  99016. /**
  99017. * Are specular textures enabled in the application.
  99018. */
  99019. static SpecularTextureEnabled: boolean;
  99020. /**
  99021. * Are bump textures enabled in the application.
  99022. */
  99023. static BumpTextureEnabled: boolean;
  99024. /**
  99025. * Are lightmap textures enabled in the application.
  99026. */
  99027. static LightmapTextureEnabled: boolean;
  99028. /**
  99029. * Are refraction textures enabled in the application.
  99030. */
  99031. static RefractionTextureEnabled: boolean;
  99032. /**
  99033. * Are color grading textures enabled in the application.
  99034. */
  99035. static ColorGradingTextureEnabled: boolean;
  99036. /**
  99037. * Are fresnels enabled in the application.
  99038. */
  99039. static FresnelEnabled: boolean;
  99040. }
  99041. }
  99042. declare module BABYLON {
  99043. /**
  99044. * A class extending Texture allowing drawing on a texture
  99045. * @see http://doc.babylonjs.com/how_to/dynamictexture
  99046. */
  99047. export class DynamicTexture extends Texture {
  99048. private _generateMipMaps;
  99049. private _canvas;
  99050. private _context;
  99051. private _engine;
  99052. /**
  99053. * Creates a DynamicTexture
  99054. * @param name defines the name of the texture
  99055. * @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
  99056. * @param scene defines the scene where you want the texture
  99057. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  99058. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  99059. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  99060. */
  99061. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  99062. /**
  99063. * Get the current class name of the texture useful for serialization or dynamic coding.
  99064. * @returns "DynamicTexture"
  99065. */
  99066. getClassName(): string;
  99067. /**
  99068. * Gets the current state of canRescale
  99069. */
  99070. readonly canRescale: boolean;
  99071. private _recreate;
  99072. /**
  99073. * Scales the texture
  99074. * @param ratio the scale factor to apply to both width and height
  99075. */
  99076. scale(ratio: number): void;
  99077. /**
  99078. * Resizes the texture
  99079. * @param width the new width
  99080. * @param height the new height
  99081. */
  99082. scaleTo(width: number, height: number): void;
  99083. /**
  99084. * Gets the context of the canvas used by the texture
  99085. * @returns the canvas context of the dynamic texture
  99086. */
  99087. getContext(): CanvasRenderingContext2D;
  99088. /**
  99089. * Clears the texture
  99090. */
  99091. clear(): void;
  99092. /**
  99093. * Updates the texture
  99094. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99095. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  99096. */
  99097. update(invertY?: boolean, premulAlpha?: boolean): void;
  99098. /**
  99099. * Draws text onto the texture
  99100. * @param text defines the text to be drawn
  99101. * @param x defines the placement of the text from the left
  99102. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  99103. * @param font defines the font to be used with font-style, font-size, font-name
  99104. * @param color defines the color used for the text
  99105. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  99106. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99107. * @param update defines whether texture is immediately update (default is true)
  99108. */
  99109. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  99110. /**
  99111. * Clones the texture
  99112. * @returns the clone of the texture.
  99113. */
  99114. clone(): DynamicTexture;
  99115. /**
  99116. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  99117. * @returns a serialized dynamic texture object
  99118. */
  99119. serialize(): any;
  99120. /** @hidden */
  99121. _rebuild(): void;
  99122. }
  99123. }
  99124. declare module BABYLON {
  99125. /** @hidden */
  99126. export var imageProcessingPixelShader: {
  99127. name: string;
  99128. shader: string;
  99129. };
  99130. }
  99131. declare module BABYLON {
  99132. /**
  99133. * ImageProcessingPostProcess
  99134. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99135. */
  99136. export class ImageProcessingPostProcess extends PostProcess {
  99137. /**
  99138. * Default configuration related to image processing available in the PBR Material.
  99139. */
  99140. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99141. /**
  99142. * Gets the image processing configuration used either in this material.
  99143. */
  99144. /**
  99145. * Sets the Default image processing configuration used either in the this material.
  99146. *
  99147. * If sets to null, the scene one is in use.
  99148. */
  99149. imageProcessingConfiguration: ImageProcessingConfiguration;
  99150. /**
  99151. * Keep track of the image processing observer to allow dispose and replace.
  99152. */
  99153. private _imageProcessingObserver;
  99154. /**
  99155. * Attaches a new image processing configuration to the PBR Material.
  99156. * @param configuration
  99157. */
  99158. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99159. /**
  99160. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99161. */
  99162. /**
  99163. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99164. */
  99165. colorCurves: Nullable<ColorCurves>;
  99166. /**
  99167. * Gets wether the color curves effect is enabled.
  99168. */
  99169. /**
  99170. * Sets wether the color curves effect is enabled.
  99171. */
  99172. colorCurvesEnabled: boolean;
  99173. /**
  99174. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99175. */
  99176. /**
  99177. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99178. */
  99179. colorGradingTexture: Nullable<BaseTexture>;
  99180. /**
  99181. * Gets wether the color grading effect is enabled.
  99182. */
  99183. /**
  99184. * Gets wether the color grading effect is enabled.
  99185. */
  99186. colorGradingEnabled: boolean;
  99187. /**
  99188. * Gets exposure used in the effect.
  99189. */
  99190. /**
  99191. * Sets exposure used in the effect.
  99192. */
  99193. exposure: number;
  99194. /**
  99195. * Gets wether tonemapping is enabled or not.
  99196. */
  99197. /**
  99198. * Sets wether tonemapping is enabled or not
  99199. */
  99200. toneMappingEnabled: boolean;
  99201. /**
  99202. * Gets the type of tone mapping effect.
  99203. */
  99204. /**
  99205. * Sets the type of tone mapping effect.
  99206. */
  99207. toneMappingType: number;
  99208. /**
  99209. * Gets contrast used in the effect.
  99210. */
  99211. /**
  99212. * Sets contrast used in the effect.
  99213. */
  99214. contrast: number;
  99215. /**
  99216. * Gets Vignette stretch size.
  99217. */
  99218. /**
  99219. * Sets Vignette stretch size.
  99220. */
  99221. vignetteStretch: number;
  99222. /**
  99223. * Gets Vignette centre X Offset.
  99224. */
  99225. /**
  99226. * Sets Vignette centre X Offset.
  99227. */
  99228. vignetteCentreX: number;
  99229. /**
  99230. * Gets Vignette centre Y Offset.
  99231. */
  99232. /**
  99233. * Sets Vignette centre Y Offset.
  99234. */
  99235. vignetteCentreY: number;
  99236. /**
  99237. * Gets Vignette weight or intensity of the vignette effect.
  99238. */
  99239. /**
  99240. * Sets Vignette weight or intensity of the vignette effect.
  99241. */
  99242. vignetteWeight: number;
  99243. /**
  99244. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99245. * if vignetteEnabled is set to true.
  99246. */
  99247. /**
  99248. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99249. * if vignetteEnabled is set to true.
  99250. */
  99251. vignetteColor: Color4;
  99252. /**
  99253. * Gets Camera field of view used by the Vignette effect.
  99254. */
  99255. /**
  99256. * Sets Camera field of view used by the Vignette effect.
  99257. */
  99258. vignetteCameraFov: number;
  99259. /**
  99260. * Gets the vignette blend mode allowing different kind of effect.
  99261. */
  99262. /**
  99263. * Sets the vignette blend mode allowing different kind of effect.
  99264. */
  99265. vignetteBlendMode: number;
  99266. /**
  99267. * Gets wether the vignette effect is enabled.
  99268. */
  99269. /**
  99270. * Sets wether the vignette effect is enabled.
  99271. */
  99272. vignetteEnabled: boolean;
  99273. private _fromLinearSpace;
  99274. /**
  99275. * Gets wether the input of the processing is in Gamma or Linear Space.
  99276. */
  99277. /**
  99278. * Sets wether the input of the processing is in Gamma or Linear Space.
  99279. */
  99280. fromLinearSpace: boolean;
  99281. /**
  99282. * Defines cache preventing GC.
  99283. */
  99284. private _defines;
  99285. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99286. /**
  99287. * "ImageProcessingPostProcess"
  99288. * @returns "ImageProcessingPostProcess"
  99289. */
  99290. getClassName(): string;
  99291. protected _updateParameters(): void;
  99292. dispose(camera?: Camera): void;
  99293. }
  99294. }
  99295. declare module BABYLON {
  99296. /**
  99297. * Class containing static functions to help procedurally build meshes
  99298. */
  99299. export class GroundBuilder {
  99300. /**
  99301. * Creates a ground mesh
  99302. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  99303. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  99304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99305. * @param name defines the name of the mesh
  99306. * @param options defines the options used to create the mesh
  99307. * @param scene defines the hosting scene
  99308. * @returns the ground mesh
  99309. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  99310. */
  99311. static CreateGround(name: string, options: {
  99312. width?: number;
  99313. height?: number;
  99314. subdivisions?: number;
  99315. subdivisionsX?: number;
  99316. subdivisionsY?: number;
  99317. updatable?: boolean;
  99318. }, scene: any): Mesh;
  99319. /**
  99320. * Creates a tiled ground mesh
  99321. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  99322. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  99323. * * 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
  99324. * * 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
  99325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99326. * @param name defines the name of the mesh
  99327. * @param options defines the options used to create the mesh
  99328. * @param scene defines the hosting scene
  99329. * @returns the tiled ground mesh
  99330. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  99331. */
  99332. static CreateTiledGround(name: string, options: {
  99333. xmin: number;
  99334. zmin: number;
  99335. xmax: number;
  99336. zmax: number;
  99337. subdivisions?: {
  99338. w: number;
  99339. h: number;
  99340. };
  99341. precision?: {
  99342. w: number;
  99343. h: number;
  99344. };
  99345. updatable?: boolean;
  99346. }, scene?: Nullable<Scene>): Mesh;
  99347. /**
  99348. * Creates a ground mesh from a height map
  99349. * * The parameter `url` sets the URL of the height map image resource.
  99350. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  99351. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  99352. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  99353. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  99354. * * 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.
  99355. * * 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).
  99356. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99358. * @param name defines the name of the mesh
  99359. * @param url defines the url to the height map
  99360. * @param options defines the options used to create the mesh
  99361. * @param scene defines the hosting scene
  99362. * @returns the ground mesh
  99363. * @see https://doc.babylonjs.com/babylon101/height_map
  99364. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  99365. */
  99366. static CreateGroundFromHeightMap(name: string, url: string, options: {
  99367. width?: number;
  99368. height?: number;
  99369. subdivisions?: number;
  99370. minHeight?: number;
  99371. maxHeight?: number;
  99372. colorFilter?: Color3;
  99373. alphaFilter?: number;
  99374. updatable?: boolean;
  99375. onReady?: (mesh: GroundMesh) => void;
  99376. }, scene?: Nullable<Scene>): GroundMesh;
  99377. }
  99378. }
  99379. declare module BABYLON {
  99380. /**
  99381. * Class containing static functions to help procedurally build meshes
  99382. */
  99383. export class TorusBuilder {
  99384. /**
  99385. * Creates a torus mesh
  99386. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99387. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99388. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99392. * @param name defines the name of the mesh
  99393. * @param options defines the options used to create the mesh
  99394. * @param scene defines the hosting scene
  99395. * @returns the torus mesh
  99396. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99397. */
  99398. static CreateTorus(name: string, options: {
  99399. diameter?: number;
  99400. thickness?: number;
  99401. tessellation?: number;
  99402. updatable?: boolean;
  99403. sideOrientation?: number;
  99404. frontUVs?: Vector4;
  99405. backUVs?: Vector4;
  99406. }, scene: any): Mesh;
  99407. }
  99408. }
  99409. declare module BABYLON {
  99410. /**
  99411. * Class containing static functions to help procedurally build meshes
  99412. */
  99413. export class CylinderBuilder {
  99414. /**
  99415. * Creates a cylinder or a cone mesh
  99416. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99417. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99418. * * 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.
  99419. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99420. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99421. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99422. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99423. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99424. * * 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).
  99425. * * 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
  99426. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99427. * * 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
  99428. * * 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.
  99429. * * If `enclose` is false, a ring surface is one element.
  99430. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99431. * * 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
  99432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99435. * @param name defines the name of the mesh
  99436. * @param options defines the options used to create the mesh
  99437. * @param scene defines the hosting scene
  99438. * @returns the cylinder mesh
  99439. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99440. */
  99441. static CreateCylinder(name: string, options: {
  99442. height?: number;
  99443. diameterTop?: number;
  99444. diameterBottom?: number;
  99445. diameter?: number;
  99446. tessellation?: number;
  99447. subdivisions?: number;
  99448. arc?: number;
  99449. faceColors?: Color4[];
  99450. faceUV?: Vector4[];
  99451. updatable?: boolean;
  99452. hasRings?: boolean;
  99453. enclose?: boolean;
  99454. sideOrientation?: number;
  99455. frontUVs?: Vector4;
  99456. backUVs?: Vector4;
  99457. }, scene: any): Mesh;
  99458. }
  99459. }
  99460. declare module BABYLON {
  99461. /**
  99462. * Manager for handling gamepads
  99463. */
  99464. export class GamepadManager {
  99465. private _scene?;
  99466. private _babylonGamepads;
  99467. private _oneGamepadConnected;
  99468. /** @hidden */
  99469. _isMonitoring: boolean;
  99470. private _gamepadEventSupported;
  99471. private _gamepadSupport;
  99472. /**
  99473. * observable to be triggered when the gamepad controller has been connected
  99474. */
  99475. onGamepadConnectedObservable: Observable<Gamepad>;
  99476. /**
  99477. * observable to be triggered when the gamepad controller has been disconnected
  99478. */
  99479. onGamepadDisconnectedObservable: Observable<Gamepad>;
  99480. private _onGamepadConnectedEvent;
  99481. private _onGamepadDisconnectedEvent;
  99482. /**
  99483. * Initializes the gamepad manager
  99484. * @param _scene BabylonJS scene
  99485. */
  99486. constructor(_scene?: Scene | undefined);
  99487. /**
  99488. * The gamepads in the game pad manager
  99489. */
  99490. readonly gamepads: Gamepad[];
  99491. /**
  99492. * Get the gamepad controllers based on type
  99493. * @param type The type of gamepad controller
  99494. * @returns Nullable gamepad
  99495. */
  99496. getGamepadByType(type?: number): Nullable<Gamepad>;
  99497. /**
  99498. * Disposes the gamepad manager
  99499. */
  99500. dispose(): void;
  99501. private _addNewGamepad;
  99502. private _startMonitoringGamepads;
  99503. private _stopMonitoringGamepads;
  99504. /** @hidden */
  99505. _checkGamepadsStatus(): void;
  99506. private _updateGamepadObjects;
  99507. }
  99508. }
  99509. declare module BABYLON {
  99510. interface Scene {
  99511. /** @hidden */
  99512. _gamepadManager: Nullable<GamepadManager>;
  99513. /**
  99514. * Gets the gamepad manager associated with the scene
  99515. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  99516. */
  99517. gamepadManager: GamepadManager;
  99518. }
  99519. /**
  99520. * Interface representing a free camera inputs manager
  99521. */
  99522. interface FreeCameraInputsManager {
  99523. /**
  99524. * Adds gamepad input support to the FreeCameraInputsManager.
  99525. * @returns the FreeCameraInputsManager
  99526. */
  99527. addGamepad(): FreeCameraInputsManager;
  99528. }
  99529. /**
  99530. * Interface representing an arc rotate camera inputs manager
  99531. */
  99532. interface ArcRotateCameraInputsManager {
  99533. /**
  99534. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99535. * @returns the camera inputs manager
  99536. */
  99537. addGamepad(): ArcRotateCameraInputsManager;
  99538. }
  99539. /**
  99540. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99541. */
  99542. export class GamepadSystemSceneComponent implements ISceneComponent {
  99543. /**
  99544. * The component name helpfull to identify the component in the list of scene components.
  99545. */
  99546. readonly name: string;
  99547. /**
  99548. * The scene the component belongs to.
  99549. */
  99550. scene: Scene;
  99551. /**
  99552. * Creates a new instance of the component for the given scene
  99553. * @param scene Defines the scene to register the component in
  99554. */
  99555. constructor(scene: Scene);
  99556. /**
  99557. * Registers the component in a given scene
  99558. */
  99559. register(): void;
  99560. /**
  99561. * Rebuilds the elements related to this component in case of
  99562. * context lost for instance.
  99563. */
  99564. rebuild(): void;
  99565. /**
  99566. * Disposes the component and the associated ressources
  99567. */
  99568. dispose(): void;
  99569. private _beforeCameraUpdate;
  99570. }
  99571. }
  99572. declare module BABYLON {
  99573. /**
  99574. * Options to modify the vr teleportation behavior.
  99575. */
  99576. export interface VRTeleportationOptions {
  99577. /**
  99578. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99579. */
  99580. floorMeshName?: string;
  99581. /**
  99582. * A list of meshes to be used as the teleportation floor. (default: empty)
  99583. */
  99584. floorMeshes?: Mesh[];
  99585. }
  99586. /**
  99587. * Options to modify the vr experience helper's behavior.
  99588. */
  99589. export interface VRExperienceHelperOptions extends WebVROptions {
  99590. /**
  99591. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99592. */
  99593. createDeviceOrientationCamera?: boolean;
  99594. /**
  99595. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99596. */
  99597. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99598. /**
  99599. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99600. */
  99601. laserToggle?: boolean;
  99602. /**
  99603. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99604. */
  99605. floorMeshes?: Mesh[];
  99606. /**
  99607. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99608. */
  99609. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99610. }
  99611. /**
  99612. * Event containing information after VR has been entered
  99613. */
  99614. export class OnAfterEnteringVRObservableEvent {
  99615. /**
  99616. * If entering vr was successful
  99617. */
  99618. success: boolean;
  99619. }
  99620. /**
  99621. * Helps to quickly add VR support to an existing scene.
  99622. * See http://doc.babylonjs.com/how_to/webvr_helper
  99623. */
  99624. export class VRExperienceHelper {
  99625. /** Options to modify the vr experience helper's behavior. */
  99626. webVROptions: VRExperienceHelperOptions;
  99627. private _scene;
  99628. private _position;
  99629. private _btnVR;
  99630. private _btnVRDisplayed;
  99631. private _webVRsupported;
  99632. private _webVRready;
  99633. private _webVRrequesting;
  99634. private _webVRpresenting;
  99635. private _hasEnteredVR;
  99636. private _fullscreenVRpresenting;
  99637. private _canvas;
  99638. private _webVRCamera;
  99639. private _vrDeviceOrientationCamera;
  99640. private _deviceOrientationCamera;
  99641. private _existingCamera;
  99642. private _onKeyDown;
  99643. private _onVrDisplayPresentChange;
  99644. private _onVRDisplayChanged;
  99645. private _onVRRequestPresentStart;
  99646. private _onVRRequestPresentComplete;
  99647. /**
  99648. * Observable raised right before entering VR.
  99649. */
  99650. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99651. /**
  99652. * Observable raised when entering VR has completed.
  99653. */
  99654. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99655. /**
  99656. * Observable raised when exiting VR.
  99657. */
  99658. onExitingVRObservable: Observable<VRExperienceHelper>;
  99659. /**
  99660. * Observable raised when controller mesh is loaded.
  99661. */
  99662. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99663. /** Return this.onEnteringVRObservable
  99664. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99665. */
  99666. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99667. /** Return this.onExitingVRObservable
  99668. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99669. */
  99670. readonly onExitingVR: Observable<VRExperienceHelper>;
  99671. /** Return this.onControllerMeshLoadedObservable
  99672. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99673. */
  99674. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99675. private _rayLength;
  99676. private _useCustomVRButton;
  99677. private _teleportationRequested;
  99678. private _teleportActive;
  99679. private _floorMeshName;
  99680. private _floorMeshesCollection;
  99681. private _rotationAllowed;
  99682. private _teleportBackwardsVector;
  99683. private _teleportationTarget;
  99684. private _isDefaultTeleportationTarget;
  99685. private _postProcessMove;
  99686. private _teleportationFillColor;
  99687. private _teleportationBorderColor;
  99688. private _rotationAngle;
  99689. private _haloCenter;
  99690. private _cameraGazer;
  99691. private _padSensibilityUp;
  99692. private _padSensibilityDown;
  99693. private _leftController;
  99694. private _rightController;
  99695. /**
  99696. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99697. */
  99698. onNewMeshSelected: Observable<AbstractMesh>;
  99699. /**
  99700. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99701. */
  99702. onNewMeshPicked: Observable<PickingInfo>;
  99703. private _circleEase;
  99704. /**
  99705. * Observable raised before camera teleportation
  99706. */
  99707. onBeforeCameraTeleport: Observable<Vector3>;
  99708. /**
  99709. * Observable raised after camera teleportation
  99710. */
  99711. onAfterCameraTeleport: Observable<Vector3>;
  99712. /**
  99713. * Observable raised when current selected mesh gets unselected
  99714. */
  99715. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99716. private _raySelectionPredicate;
  99717. /**
  99718. * To be optionaly changed by user to define custom ray selection
  99719. */
  99720. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99721. /**
  99722. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99723. */
  99724. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99725. /**
  99726. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99727. */
  99728. teleportationEnabled: boolean;
  99729. private _defaultHeight;
  99730. private _teleportationInitialized;
  99731. private _interactionsEnabled;
  99732. private _interactionsRequested;
  99733. private _displayGaze;
  99734. private _displayLaserPointer;
  99735. /**
  99736. * The mesh used to display where the user is going to teleport.
  99737. */
  99738. /**
  99739. * Sets the mesh to be used to display where the user is going to teleport.
  99740. */
  99741. teleportationTarget: Mesh;
  99742. /**
  99743. * 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
  99744. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99745. * See http://doc.babylonjs.com/resources/baking_transformations
  99746. */
  99747. gazeTrackerMesh: Mesh;
  99748. /**
  99749. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99750. */
  99751. updateGazeTrackerScale: boolean;
  99752. /**
  99753. * If the gaze trackers color should be updated when selecting meshes
  99754. */
  99755. updateGazeTrackerColor: boolean;
  99756. /**
  99757. * The gaze tracking mesh corresponding to the left controller
  99758. */
  99759. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99760. /**
  99761. * The gaze tracking mesh corresponding to the right controller
  99762. */
  99763. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99764. /**
  99765. * If the ray of the gaze should be displayed.
  99766. */
  99767. /**
  99768. * Sets if the ray of the gaze should be displayed.
  99769. */
  99770. displayGaze: boolean;
  99771. /**
  99772. * If the ray of the LaserPointer should be displayed.
  99773. */
  99774. /**
  99775. * Sets if the ray of the LaserPointer should be displayed.
  99776. */
  99777. displayLaserPointer: boolean;
  99778. /**
  99779. * The deviceOrientationCamera used as the camera when not in VR.
  99780. */
  99781. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99782. /**
  99783. * Based on the current WebVR support, returns the current VR camera used.
  99784. */
  99785. readonly currentVRCamera: Nullable<Camera>;
  99786. /**
  99787. * The webVRCamera which is used when in VR.
  99788. */
  99789. readonly webVRCamera: WebVRFreeCamera;
  99790. /**
  99791. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99792. */
  99793. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99794. private readonly _teleportationRequestInitiated;
  99795. /**
  99796. * Defines wether or not Pointer lock should be requested when switching to
  99797. * full screen.
  99798. */
  99799. requestPointerLockOnFullScreen: boolean;
  99800. /**
  99801. * Instantiates a VRExperienceHelper.
  99802. * Helps to quickly add VR support to an existing scene.
  99803. * @param scene The scene the VRExperienceHelper belongs to.
  99804. * @param webVROptions Options to modify the vr experience helper's behavior.
  99805. */
  99806. constructor(scene: Scene,
  99807. /** Options to modify the vr experience helper's behavior. */
  99808. webVROptions?: VRExperienceHelperOptions);
  99809. private _onDefaultMeshLoaded;
  99810. private _onResize;
  99811. private _onFullscreenChange;
  99812. /**
  99813. * Gets a value indicating if we are currently in VR mode.
  99814. */
  99815. readonly isInVRMode: boolean;
  99816. private onVrDisplayPresentChange;
  99817. private onVRDisplayChanged;
  99818. private moveButtonToBottomRight;
  99819. private displayVRButton;
  99820. private updateButtonVisibility;
  99821. private _cachedAngularSensibility;
  99822. /**
  99823. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99824. * Otherwise, will use the fullscreen API.
  99825. */
  99826. enterVR(): void;
  99827. /**
  99828. * Attempt to exit VR, or fullscreen.
  99829. */
  99830. exitVR(): void;
  99831. /**
  99832. * The position of the vr experience helper.
  99833. */
  99834. /**
  99835. * Sets the position of the vr experience helper.
  99836. */
  99837. position: Vector3;
  99838. /**
  99839. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99840. */
  99841. enableInteractions(): void;
  99842. private readonly _noControllerIsActive;
  99843. private beforeRender;
  99844. private _isTeleportationFloor;
  99845. /**
  99846. * Adds a floor mesh to be used for teleportation.
  99847. * @param floorMesh the mesh to be used for teleportation.
  99848. */
  99849. addFloorMesh(floorMesh: Mesh): void;
  99850. /**
  99851. * Removes a floor mesh from being used for teleportation.
  99852. * @param floorMesh the mesh to be removed.
  99853. */
  99854. removeFloorMesh(floorMesh: Mesh): void;
  99855. /**
  99856. * Enables interactions and teleportation using the VR controllers and gaze.
  99857. * @param vrTeleportationOptions options to modify teleportation behavior.
  99858. */
  99859. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99860. private _onNewGamepadConnected;
  99861. private _tryEnableInteractionOnController;
  99862. private _onNewGamepadDisconnected;
  99863. private _enableInteractionOnController;
  99864. private _checkTeleportWithRay;
  99865. private _checkRotate;
  99866. private _checkTeleportBackwards;
  99867. private _enableTeleportationOnController;
  99868. private _createTeleportationCircles;
  99869. private _displayTeleportationTarget;
  99870. private _hideTeleportationTarget;
  99871. private _rotateCamera;
  99872. private _moveTeleportationSelectorTo;
  99873. private _workingVector;
  99874. private _workingQuaternion;
  99875. private _workingMatrix;
  99876. /**
  99877. * Teleports the users feet to the desired location
  99878. * @param location The location where the user's feet should be placed
  99879. */
  99880. teleportCamera(location: Vector3): void;
  99881. private _convertNormalToDirectionOfRay;
  99882. private _castRayAndSelectObject;
  99883. private _notifySelectedMeshUnselected;
  99884. /**
  99885. * Sets the color of the laser ray from the vr controllers.
  99886. * @param color new color for the ray.
  99887. */
  99888. changeLaserColor(color: Color3): void;
  99889. /**
  99890. * Sets the color of the ray from the vr headsets gaze.
  99891. * @param color new color for the ray.
  99892. */
  99893. changeGazeColor(color: Color3): void;
  99894. /**
  99895. * Exits VR and disposes of the vr experience helper
  99896. */
  99897. dispose(): void;
  99898. /**
  99899. * Gets the name of the VRExperienceHelper class
  99900. * @returns "VRExperienceHelper"
  99901. */
  99902. getClassName(): string;
  99903. }
  99904. }
  99905. declare module BABYLON {
  99906. /**
  99907. * Manages an XRSession
  99908. * @see https://doc.babylonjs.com/how_to/webxr
  99909. */
  99910. export class WebXRSessionManager implements IDisposable {
  99911. private scene;
  99912. /**
  99913. * Fires every time a new xrFrame arrives which can be used to update the camera
  99914. */
  99915. onXRFrameObservable: Observable<any>;
  99916. /**
  99917. * Fires when the xr session is ended either by the device or manually done
  99918. */
  99919. onXRSessionEnded: Observable<any>;
  99920. /** @hidden */
  99921. _xrSession: XRSession;
  99922. /** @hidden */
  99923. _frameOfReference: XRFrameOfReference;
  99924. /** @hidden */
  99925. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99926. /** @hidden */
  99927. _currentXRFrame: Nullable<XRFrame>;
  99928. private _xrNavigator;
  99929. private _xrDevice;
  99930. private _tmpMatrix;
  99931. /**
  99932. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99933. * @param scene The scene which the session should be created for
  99934. */
  99935. constructor(scene: Scene);
  99936. /**
  99937. * Initializes the manager
  99938. * After initialization enterXR can be called to start an XR session
  99939. * @returns Promise which resolves after it is initialized
  99940. */
  99941. initializeAsync(): Promise<void>;
  99942. /**
  99943. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99944. * @param sessionCreationOptions xr options to create the session with
  99945. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99946. * @returns Promise which resolves after it enters XR
  99947. */
  99948. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99949. /**
  99950. * Stops the xrSession and restores the renderloop
  99951. * @returns Promise which resolves after it exits XR
  99952. */
  99953. exitXRAsync(): Promise<void>;
  99954. /**
  99955. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99956. * @param ray ray to cast into the environment
  99957. * @returns Promise which resolves with a collision point in the environment if it exists
  99958. */
  99959. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99960. /**
  99961. * Checks if a session would be supported for the creation options specified
  99962. * @param options creation options to check if they are supported
  99963. * @returns true if supported
  99964. */
  99965. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99966. /**
  99967. * @hidden
  99968. * Converts the render layer of xrSession to a render target
  99969. * @param session session to create render target for
  99970. * @param scene scene the new render target should be created for
  99971. */
  99972. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99973. /**
  99974. * Disposes of the session manager
  99975. */
  99976. dispose(): void;
  99977. }
  99978. }
  99979. declare module BABYLON {
  99980. /**
  99981. * WebXR Camera which holds the views for the xrSession
  99982. * @see https://doc.babylonjs.com/how_to/webxr
  99983. */
  99984. export class WebXRCamera extends FreeCamera {
  99985. private static _TmpMatrix;
  99986. /**
  99987. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99988. * @param name the name of the camera
  99989. * @param scene the scene to add the camera to
  99990. */
  99991. constructor(name: string, scene: Scene);
  99992. private _updateNumberOfRigCameras;
  99993. /** @hidden */
  99994. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99995. /**
  99996. * Updates the cameras position from the current pose information of the XR session
  99997. * @param xrSessionManager the session containing pose information
  99998. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99999. */
  100000. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  100001. }
  100002. }
  100003. declare module BABYLON {
  100004. /**
  100005. * States of the webXR experience
  100006. */
  100007. export enum WebXRState {
  100008. /**
  100009. * Transitioning to being in XR mode
  100010. */
  100011. ENTERING_XR = 0,
  100012. /**
  100013. * Transitioning to non XR mode
  100014. */
  100015. EXITING_XR = 1,
  100016. /**
  100017. * In XR mode and presenting
  100018. */
  100019. IN_XR = 2,
  100020. /**
  100021. * Not entered XR mode
  100022. */
  100023. NOT_IN_XR = 3
  100024. }
  100025. /**
  100026. * Helper class used to enable XR
  100027. * @see https://doc.babylonjs.com/how_to/webxr
  100028. */
  100029. export class WebXRExperienceHelper implements IDisposable {
  100030. private scene;
  100031. /**
  100032. * 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
  100033. */
  100034. container: AbstractMesh;
  100035. /**
  100036. * Camera used to render xr content
  100037. */
  100038. camera: WebXRCamera;
  100039. /**
  100040. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  100041. */
  100042. state: WebXRState;
  100043. private _setState;
  100044. private static _TmpVector;
  100045. /**
  100046. * Fires when the state of the experience helper has changed
  100047. */
  100048. onStateChangedObservable: Observable<WebXRState>;
  100049. /** @hidden */
  100050. _sessionManager: WebXRSessionManager;
  100051. private _nonVRCamera;
  100052. private _originalSceneAutoClear;
  100053. private _supported;
  100054. /**
  100055. * Creates the experience helper
  100056. * @param scene the scene to attach the experience helper to
  100057. * @returns a promise for the experience helper
  100058. */
  100059. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  100060. /**
  100061. * Creates a WebXRExperienceHelper
  100062. * @param scene The scene the helper should be created in
  100063. */
  100064. private constructor();
  100065. /**
  100066. * Exits XR mode and returns the scene to its original state
  100067. * @returns promise that resolves after xr mode has exited
  100068. */
  100069. exitXRAsync(): Promise<void>;
  100070. /**
  100071. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  100072. * @param sessionCreationOptions options for the XR session
  100073. * @param frameOfReference frame of reference of the XR session
  100074. * @returns promise that resolves after xr mode has entered
  100075. */
  100076. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  100077. /**
  100078. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100079. * @param ray ray to cast into the environment
  100080. * @returns Promise which resolves with a collision point in the environment if it exists
  100081. */
  100082. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100083. /**
  100084. * Updates the global position of the camera by moving the camera's container
  100085. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  100086. * @param position The desired global position of the camera
  100087. */
  100088. setPositionOfCameraUsingContainer(position: Vector3): void;
  100089. /**
  100090. * Rotates the xr camera by rotating the camera's container around the camera's position
  100091. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  100092. * @param rotation the desired quaternion rotation to apply to the camera
  100093. */
  100094. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  100095. /**
  100096. * Checks if the creation options are supported by the xr session
  100097. * @param options creation options
  100098. * @returns true if supported
  100099. */
  100100. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100101. /**
  100102. * Disposes of the experience helper
  100103. */
  100104. dispose(): void;
  100105. }
  100106. }
  100107. declare module BABYLON {
  100108. /**
  100109. * Button which can be used to enter a different mode of XR
  100110. */
  100111. export class WebXREnterExitUIButton {
  100112. /** button element */
  100113. element: HTMLElement;
  100114. /** XR initialization options for the button */
  100115. initializationOptions: XRSessionCreationOptions;
  100116. /**
  100117. * Creates a WebXREnterExitUIButton
  100118. * @param element button element
  100119. * @param initializationOptions XR initialization options for the button
  100120. */
  100121. constructor(
  100122. /** button element */
  100123. element: HTMLElement,
  100124. /** XR initialization options for the button */
  100125. initializationOptions: XRSessionCreationOptions);
  100126. /**
  100127. * Overwritable function which can be used to update the button's visuals when the state changes
  100128. * @param activeButton the current active button in the UI
  100129. */
  100130. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  100131. }
  100132. /**
  100133. * Options to create the webXR UI
  100134. */
  100135. export class WebXREnterExitUIOptions {
  100136. /**
  100137. * Context to enter xr with
  100138. */
  100139. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  100140. /**
  100141. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  100142. */
  100143. customButtons?: Array<WebXREnterExitUIButton>;
  100144. }
  100145. /**
  100146. * UI to allow the user to enter/exit XR mode
  100147. */
  100148. export class WebXREnterExitUI implements IDisposable {
  100149. private scene;
  100150. private _overlay;
  100151. private _buttons;
  100152. private _activeButton;
  100153. /**
  100154. * Fired every time the active button is changed.
  100155. *
  100156. * When xr is entered via a button that launches xr that button will be the callback parameter
  100157. *
  100158. * When exiting xr the callback parameter will be null)
  100159. */
  100160. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  100161. /**
  100162. * Creates UI to allow the user to enter/exit XR mode
  100163. * @param scene the scene to add the ui to
  100164. * @param helper the xr experience helper to enter/exit xr with
  100165. * @param options options to configure the UI
  100166. * @returns the created ui
  100167. */
  100168. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  100169. private constructor();
  100170. private _updateButtons;
  100171. /**
  100172. * Disposes of the object
  100173. */
  100174. dispose(): void;
  100175. }
  100176. }
  100177. declare module BABYLON {
  100178. /**
  100179. * Represents an XR input
  100180. */
  100181. export class WebXRController {
  100182. /**
  100183. * 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
  100184. */
  100185. grip?: AbstractMesh;
  100186. /**
  100187. * Pointer which can be used to select objects or attach a visible laser to
  100188. */
  100189. pointer: AbstractMesh;
  100190. /**
  100191. * Creates the controller
  100192. * @see https://doc.babylonjs.com/how_to/webxr
  100193. * @param scene the scene which the controller should be associated to
  100194. */
  100195. constructor(scene: Scene);
  100196. /**
  100197. * Disposes of the object
  100198. */
  100199. dispose(): void;
  100200. }
  100201. /**
  100202. * XR input used to track XR inputs such as controllers/rays
  100203. */
  100204. export class WebXRInput implements IDisposable {
  100205. private helper;
  100206. /**
  100207. * XR controllers being tracked
  100208. */
  100209. controllers: Array<WebXRController>;
  100210. private _tmpMatrix;
  100211. private _frameObserver;
  100212. /**
  100213. * Initializes the WebXRInput
  100214. * @param helper experience helper which the input should be created for
  100215. */
  100216. constructor(helper: WebXRExperienceHelper);
  100217. /**
  100218. * Disposes of the object
  100219. */
  100220. dispose(): void;
  100221. }
  100222. }
  100223. declare module BABYLON {
  100224. /**
  100225. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  100226. */
  100227. export class WebXRManagedOutputCanvas implements IDisposable {
  100228. private _canvas;
  100229. /**
  100230. * xrpresent context of the canvas which can be used to display/mirror xr content
  100231. */
  100232. canvasContext: Nullable<WebGLRenderingContext>;
  100233. /**
  100234. * Initializes the canvas to be added/removed upon entering/exiting xr
  100235. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  100236. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  100237. */
  100238. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  100239. /**
  100240. * Disposes of the object
  100241. */
  100242. dispose(): void;
  100243. private _setManagedOutputCanvas;
  100244. private _addCanvas;
  100245. private _removeCanvas;
  100246. }
  100247. }
  100248. declare module BABYLON {
  100249. /**
  100250. * Contains an array of blocks representing the octree
  100251. */
  100252. export interface IOctreeContainer<T> {
  100253. /**
  100254. * Blocks within the octree
  100255. */
  100256. blocks: Array<OctreeBlock<T>>;
  100257. }
  100258. /**
  100259. * Class used to store a cell in an octree
  100260. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100261. */
  100262. export class OctreeBlock<T> {
  100263. /**
  100264. * Gets the content of the current block
  100265. */
  100266. entries: T[];
  100267. /**
  100268. * Gets the list of block children
  100269. */
  100270. blocks: Array<OctreeBlock<T>>;
  100271. private _depth;
  100272. private _maxDepth;
  100273. private _capacity;
  100274. private _minPoint;
  100275. private _maxPoint;
  100276. private _boundingVectors;
  100277. private _creationFunc;
  100278. /**
  100279. * Creates a new block
  100280. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  100281. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  100282. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100283. * @param depth defines the current depth of this block in the octree
  100284. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  100285. * @param creationFunc defines a callback to call when an element is added to the block
  100286. */
  100287. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  100288. /**
  100289. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100290. */
  100291. readonly capacity: number;
  100292. /**
  100293. * Gets the minimum vector (in world space) of the block's bounding box
  100294. */
  100295. readonly minPoint: Vector3;
  100296. /**
  100297. * Gets the maximum vector (in world space) of the block's bounding box
  100298. */
  100299. readonly maxPoint: Vector3;
  100300. /**
  100301. * Add a new element to this block
  100302. * @param entry defines the element to add
  100303. */
  100304. addEntry(entry: T): void;
  100305. /**
  100306. * Remove an element from this block
  100307. * @param entry defines the element to remove
  100308. */
  100309. removeEntry(entry: T): void;
  100310. /**
  100311. * Add an array of elements to this block
  100312. * @param entries defines the array of elements to add
  100313. */
  100314. addEntries(entries: T[]): void;
  100315. /**
  100316. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  100317. * @param frustumPlanes defines the frustum planes to test
  100318. * @param selection defines the array to store current content if selection is positive
  100319. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100320. */
  100321. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100322. /**
  100323. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  100324. * @param sphereCenter defines the bounding sphere center
  100325. * @param sphereRadius defines the bounding sphere radius
  100326. * @param selection defines the array to store current content if selection is positive
  100327. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100328. */
  100329. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100330. /**
  100331. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  100332. * @param ray defines the ray to test with
  100333. * @param selection defines the array to store current content if selection is positive
  100334. */
  100335. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  100336. /**
  100337. * Subdivide the content into child blocks (this block will then be empty)
  100338. */
  100339. createInnerBlocks(): void;
  100340. /**
  100341. * @hidden
  100342. */
  100343. 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;
  100344. }
  100345. }
  100346. declare module BABYLON {
  100347. /**
  100348. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  100349. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100350. */
  100351. export class Octree<T> {
  100352. /** 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.) */
  100353. maxDepth: number;
  100354. /**
  100355. * Blocks within the octree containing objects
  100356. */
  100357. blocks: Array<OctreeBlock<T>>;
  100358. /**
  100359. * Content stored in the octree
  100360. */
  100361. dynamicContent: T[];
  100362. private _maxBlockCapacity;
  100363. private _selectionContent;
  100364. private _creationFunc;
  100365. /**
  100366. * Creates a octree
  100367. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100368. * @param creationFunc function to be used to instatiate the octree
  100369. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  100370. * @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.)
  100371. */
  100372. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100373. /** 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.) */
  100374. maxDepth?: number);
  100375. /**
  100376. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100377. * @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);
  100378. * @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);
  100379. * @param entries meshes to be added to the octree blocks
  100380. */
  100381. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100382. /**
  100383. * Adds a mesh to the octree
  100384. * @param entry Mesh to add to the octree
  100385. */
  100386. addMesh(entry: T): void;
  100387. /**
  100388. * Remove an element from the octree
  100389. * @param entry defines the element to remove
  100390. */
  100391. removeMesh(entry: T): void;
  100392. /**
  100393. * Selects an array of meshes within the frustum
  100394. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100395. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100396. * @returns array of meshes within the frustum
  100397. */
  100398. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100399. /**
  100400. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100401. * @param sphereCenter defines the bounding sphere center
  100402. * @param sphereRadius defines the bounding sphere radius
  100403. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100404. * @returns an array of objects that intersect the sphere
  100405. */
  100406. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100407. /**
  100408. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100409. * @param ray defines the ray to test with
  100410. * @returns array of intersected objects
  100411. */
  100412. intersectsRay(ray: Ray): SmartArray<T>;
  100413. /**
  100414. * Adds a mesh into the octree block if it intersects the block
  100415. */
  100416. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100417. /**
  100418. * Adds a submesh into the octree block if it intersects the block
  100419. */
  100420. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100421. }
  100422. }
  100423. declare module BABYLON {
  100424. interface Scene {
  100425. /**
  100426. * @hidden
  100427. * Backing Filed
  100428. */
  100429. _selectionOctree: Octree<AbstractMesh>;
  100430. /**
  100431. * Gets the octree used to boost mesh selection (picking)
  100432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100433. */
  100434. selectionOctree: Octree<AbstractMesh>;
  100435. /**
  100436. * Creates or updates the octree used to boost selection (picking)
  100437. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100438. * @param maxCapacity defines the maximum capacity per leaf
  100439. * @param maxDepth defines the maximum depth of the octree
  100440. * @returns an octree of AbstractMesh
  100441. */
  100442. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100443. }
  100444. interface AbstractMesh {
  100445. /**
  100446. * @hidden
  100447. * Backing Field
  100448. */
  100449. _submeshesOctree: Octree<SubMesh>;
  100450. /**
  100451. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100452. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100453. * @param maxCapacity defines the maximum size of each block (64 by default)
  100454. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100455. * @returns the new octree
  100456. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100457. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100458. */
  100459. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100460. }
  100461. /**
  100462. * Defines the octree scene component responsible to manage any octrees
  100463. * in a given scene.
  100464. */
  100465. export class OctreeSceneComponent {
  100466. /**
  100467. * The component name help to identify the component in the list of scene components.
  100468. */
  100469. readonly name: string;
  100470. /**
  100471. * The scene the component belongs to.
  100472. */
  100473. scene: Scene;
  100474. /**
  100475. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100476. */
  100477. readonly checksIsEnabled: boolean;
  100478. /**
  100479. * Creates a new instance of the component for the given scene
  100480. * @param scene Defines the scene to register the component in
  100481. */
  100482. constructor(scene: Scene);
  100483. /**
  100484. * Registers the component in a given scene
  100485. */
  100486. register(): void;
  100487. /**
  100488. * Return the list of active meshes
  100489. * @returns the list of active meshes
  100490. */
  100491. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100492. /**
  100493. * Return the list of active sub meshes
  100494. * @param mesh The mesh to get the candidates sub meshes from
  100495. * @returns the list of active sub meshes
  100496. */
  100497. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100498. private _tempRay;
  100499. /**
  100500. * Return the list of sub meshes intersecting with a given local ray
  100501. * @param mesh defines the mesh to find the submesh for
  100502. * @param localRay defines the ray in local space
  100503. * @returns the list of intersecting sub meshes
  100504. */
  100505. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100506. /**
  100507. * Return the list of sub meshes colliding with a collider
  100508. * @param mesh defines the mesh to find the submesh for
  100509. * @param collider defines the collider to evaluate the collision against
  100510. * @returns the list of colliding sub meshes
  100511. */
  100512. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100513. /**
  100514. * Rebuilds the elements related to this component in case of
  100515. * context lost for instance.
  100516. */
  100517. rebuild(): void;
  100518. /**
  100519. * Disposes the component and the associated ressources.
  100520. */
  100521. dispose(): void;
  100522. }
  100523. }
  100524. declare module BABYLON {
  100525. /**
  100526. * Renders a layer on top of an existing scene
  100527. */
  100528. export class UtilityLayerRenderer implements IDisposable {
  100529. /** the original scene that will be rendered on top of */
  100530. originalScene: Scene;
  100531. private _pointerCaptures;
  100532. private _lastPointerEvents;
  100533. private static _DefaultUtilityLayer;
  100534. private static _DefaultKeepDepthUtilityLayer;
  100535. private _sharedGizmoLight;
  100536. /**
  100537. * @hidden
  100538. * Light which used by gizmos to get light shading
  100539. */
  100540. _getSharedGizmoLight(): HemisphericLight;
  100541. /**
  100542. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100543. */
  100544. pickUtilitySceneFirst: boolean;
  100545. /**
  100546. * 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)
  100547. */
  100548. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100549. /**
  100550. * 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)
  100551. */
  100552. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100553. /**
  100554. * The scene that is rendered on top of the original scene
  100555. */
  100556. utilityLayerScene: Scene;
  100557. /**
  100558. * If the utility layer should automatically be rendered on top of existing scene
  100559. */
  100560. shouldRender: boolean;
  100561. /**
  100562. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100563. */
  100564. onlyCheckPointerDownEvents: boolean;
  100565. /**
  100566. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100567. */
  100568. processAllEvents: boolean;
  100569. /**
  100570. * Observable raised when the pointer move from the utility layer scene to the main scene
  100571. */
  100572. onPointerOutObservable: Observable<number>;
  100573. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100574. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100575. private _afterRenderObserver;
  100576. private _sceneDisposeObserver;
  100577. private _originalPointerObserver;
  100578. /**
  100579. * Instantiates a UtilityLayerRenderer
  100580. * @param originalScene the original scene that will be rendered on top of
  100581. * @param handleEvents boolean indicating if the utility layer should handle events
  100582. */
  100583. constructor(
  100584. /** the original scene that will be rendered on top of */
  100585. originalScene: Scene, handleEvents?: boolean);
  100586. private _notifyObservers;
  100587. /**
  100588. * Renders the utility layers scene on top of the original scene
  100589. */
  100590. render(): void;
  100591. /**
  100592. * Disposes of the renderer
  100593. */
  100594. dispose(): void;
  100595. private _updateCamera;
  100596. }
  100597. }
  100598. declare module BABYLON {
  100599. /**
  100600. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100601. */
  100602. export class Gizmo implements IDisposable {
  100603. /** The utility layer the gizmo will be added to */
  100604. gizmoLayer: UtilityLayerRenderer;
  100605. /**
  100606. * The root mesh of the gizmo
  100607. */
  100608. _rootMesh: Mesh;
  100609. private _attachedMesh;
  100610. /**
  100611. * Ratio for the scale of the gizmo (Default: 1)
  100612. */
  100613. scaleRatio: number;
  100614. /**
  100615. * If a custom mesh has been set (Default: false)
  100616. */
  100617. protected _customMeshSet: boolean;
  100618. /**
  100619. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100620. * * When set, interactions will be enabled
  100621. */
  100622. attachedMesh: Nullable<AbstractMesh>;
  100623. /**
  100624. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100625. * @param mesh The mesh to replace the default mesh of the gizmo
  100626. */
  100627. setCustomMesh(mesh: Mesh): void;
  100628. /**
  100629. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100630. */
  100631. updateGizmoRotationToMatchAttachedMesh: boolean;
  100632. /**
  100633. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100634. */
  100635. updateGizmoPositionToMatchAttachedMesh: boolean;
  100636. /**
  100637. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100638. */
  100639. protected _updateScale: boolean;
  100640. protected _interactionsEnabled: boolean;
  100641. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100642. private _beforeRenderObserver;
  100643. private _tempVector;
  100644. /**
  100645. * Creates a gizmo
  100646. * @param gizmoLayer The utility layer the gizmo will be added to
  100647. */
  100648. constructor(
  100649. /** The utility layer the gizmo will be added to */
  100650. gizmoLayer?: UtilityLayerRenderer);
  100651. /**
  100652. * Updates the gizmo to match the attached mesh's position/rotation
  100653. */
  100654. protected _update(): void;
  100655. /**
  100656. * Disposes of the gizmo
  100657. */
  100658. dispose(): void;
  100659. }
  100660. }
  100661. declare module BABYLON {
  100662. /**
  100663. * Single axis drag gizmo
  100664. */
  100665. export class AxisDragGizmo extends Gizmo {
  100666. /**
  100667. * Drag behavior responsible for the gizmos dragging interactions
  100668. */
  100669. dragBehavior: PointerDragBehavior;
  100670. private _pointerObserver;
  100671. /**
  100672. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100673. */
  100674. snapDistance: number;
  100675. /**
  100676. * Event that fires each time the gizmo snaps to a new location.
  100677. * * snapDistance is the the change in distance
  100678. */
  100679. onSnapObservable: Observable<{
  100680. snapDistance: number;
  100681. }>;
  100682. /** @hidden */
  100683. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100684. /** @hidden */
  100685. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100686. /**
  100687. * Creates an AxisDragGizmo
  100688. * @param gizmoLayer The utility layer the gizmo will be added to
  100689. * @param dragAxis The axis which the gizmo will be able to drag on
  100690. * @param color The color of the gizmo
  100691. */
  100692. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100693. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100694. /**
  100695. * Disposes of the gizmo
  100696. */
  100697. dispose(): void;
  100698. }
  100699. }
  100700. declare module BABYLON.Debug {
  100701. /**
  100702. * The Axes viewer will show 3 axes in a specific point in space
  100703. */
  100704. export class AxesViewer {
  100705. private _xAxis;
  100706. private _yAxis;
  100707. private _zAxis;
  100708. private _scaleLinesFactor;
  100709. private _instanced;
  100710. /**
  100711. * Gets the hosting scene
  100712. */
  100713. scene: Scene;
  100714. /**
  100715. * Gets or sets a number used to scale line length
  100716. */
  100717. scaleLines: number;
  100718. /** Gets the node hierarchy used to render x-axis */
  100719. readonly xAxis: TransformNode;
  100720. /** Gets the node hierarchy used to render y-axis */
  100721. readonly yAxis: TransformNode;
  100722. /** Gets the node hierarchy used to render z-axis */
  100723. readonly zAxis: TransformNode;
  100724. /**
  100725. * Creates a new AxesViewer
  100726. * @param scene defines the hosting scene
  100727. * @param scaleLines defines a number used to scale line length (1 by default)
  100728. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100729. * @param xAxis defines the node hierarchy used to render the x-axis
  100730. * @param yAxis defines the node hierarchy used to render the y-axis
  100731. * @param zAxis defines the node hierarchy used to render the z-axis
  100732. */
  100733. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100734. /**
  100735. * Force the viewer to update
  100736. * @param position defines the position of the viewer
  100737. * @param xaxis defines the x axis of the viewer
  100738. * @param yaxis defines the y axis of the viewer
  100739. * @param zaxis defines the z axis of the viewer
  100740. */
  100741. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100742. /**
  100743. * Creates an instance of this axes viewer.
  100744. * @returns a new axes viewer with instanced meshes
  100745. */
  100746. createInstance(): AxesViewer;
  100747. /** Releases resources */
  100748. dispose(): void;
  100749. private static _SetRenderingGroupId;
  100750. }
  100751. }
  100752. declare module BABYLON.Debug {
  100753. /**
  100754. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100755. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100756. */
  100757. export class BoneAxesViewer extends AxesViewer {
  100758. /**
  100759. * Gets or sets the target mesh where to display the axes viewer
  100760. */
  100761. mesh: Nullable<Mesh>;
  100762. /**
  100763. * Gets or sets the target bone where to display the axes viewer
  100764. */
  100765. bone: Nullable<Bone>;
  100766. /** Gets current position */
  100767. pos: Vector3;
  100768. /** Gets direction of X axis */
  100769. xaxis: Vector3;
  100770. /** Gets direction of Y axis */
  100771. yaxis: Vector3;
  100772. /** Gets direction of Z axis */
  100773. zaxis: Vector3;
  100774. /**
  100775. * Creates a new BoneAxesViewer
  100776. * @param scene defines the hosting scene
  100777. * @param bone defines the target bone
  100778. * @param mesh defines the target mesh
  100779. * @param scaleLines defines a scaling factor for line length (1 by default)
  100780. */
  100781. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100782. /**
  100783. * Force the viewer to update
  100784. */
  100785. update(): void;
  100786. /** Releases resources */
  100787. dispose(): void;
  100788. }
  100789. }
  100790. declare module BABYLON {
  100791. /**
  100792. * Interface used to define scene explorer extensibility option
  100793. */
  100794. export interface IExplorerExtensibilityOption {
  100795. /**
  100796. * Define the option label
  100797. */
  100798. label: string;
  100799. /**
  100800. * Defines the action to execute on click
  100801. */
  100802. action: (entity: any) => void;
  100803. }
  100804. /**
  100805. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100806. */
  100807. export interface IExplorerExtensibilityGroup {
  100808. /**
  100809. * Defines a predicate to test if a given type mut be extended
  100810. */
  100811. predicate: (entity: any) => boolean;
  100812. /**
  100813. * Gets the list of options added to a type
  100814. */
  100815. entries: IExplorerExtensibilityOption[];
  100816. }
  100817. /**
  100818. * Interface used to define the options to use to create the Inspector
  100819. */
  100820. export interface IInspectorOptions {
  100821. /**
  100822. * Display in overlay mode (default: false)
  100823. */
  100824. overlay?: boolean;
  100825. /**
  100826. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100827. */
  100828. globalRoot?: HTMLElement;
  100829. /**
  100830. * Display the Scene explorer
  100831. */
  100832. showExplorer?: boolean;
  100833. /**
  100834. * Display the property inspector
  100835. */
  100836. showInspector?: boolean;
  100837. /**
  100838. * Display in embed mode (both panes on the right)
  100839. */
  100840. embedMode?: boolean;
  100841. /**
  100842. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100843. */
  100844. handleResize?: boolean;
  100845. /**
  100846. * Allow the panes to popup (default: true)
  100847. */
  100848. enablePopup?: boolean;
  100849. /**
  100850. * Allow the panes to be closed by users (default: true)
  100851. */
  100852. enableClose?: boolean;
  100853. /**
  100854. * Optional list of extensibility entries
  100855. */
  100856. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100857. /**
  100858. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100859. */
  100860. inspectorURL?: string;
  100861. }
  100862. interface Scene {
  100863. /**
  100864. * @hidden
  100865. * Backing field
  100866. */
  100867. _debugLayer: DebugLayer;
  100868. /**
  100869. * Gets the debug layer (aka Inspector) associated with the scene
  100870. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100871. */
  100872. debugLayer: DebugLayer;
  100873. }
  100874. /**
  100875. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100876. * what is happening in your scene
  100877. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100878. */
  100879. export class DebugLayer {
  100880. /**
  100881. * Define the url to get the inspector script from.
  100882. * By default it uses the babylonjs CDN.
  100883. * @ignoreNaming
  100884. */
  100885. static InspectorURL: string;
  100886. private _scene;
  100887. private BJSINSPECTOR;
  100888. /**
  100889. * Observable triggered when a property is changed through the inspector.
  100890. */
  100891. onPropertyChangedObservable: Observable<{
  100892. object: any;
  100893. property: string;
  100894. value: any;
  100895. initialValue: any;
  100896. }>;
  100897. /**
  100898. * Instantiates a new debug layer.
  100899. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100900. * what is happening in your scene
  100901. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100902. * @param scene Defines the scene to inspect
  100903. */
  100904. constructor(scene: Scene);
  100905. /** Creates the inspector window. */
  100906. private _createInspector;
  100907. /**
  100908. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100909. * @param entity defines the entity to select
  100910. * @param lineContainerTitle defines the specific block to highlight
  100911. */
  100912. select(entity: any, lineContainerTitle?: string): void;
  100913. /** Get the inspector from bundle or global */
  100914. private _getGlobalInspector;
  100915. /**
  100916. * Get if the inspector is visible or not.
  100917. * @returns true if visible otherwise, false
  100918. */
  100919. isVisible(): boolean;
  100920. /**
  100921. * Hide the inspector and close its window.
  100922. */
  100923. hide(): void;
  100924. /**
  100925. * Launch the debugLayer.
  100926. * @param config Define the configuration of the inspector
  100927. * @return a promise fulfilled when the debug layer is visible
  100928. */
  100929. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100930. }
  100931. }
  100932. declare module BABYLON {
  100933. /**
  100934. * Class containing static functions to help procedurally build meshes
  100935. */
  100936. export class BoxBuilder {
  100937. /**
  100938. * Creates a box mesh
  100939. * * The parameter `size` sets the size (float) of each box side (default 1)
  100940. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100941. * * 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)
  100942. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100946. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100947. * @param name defines the name of the mesh
  100948. * @param options defines the options used to create the mesh
  100949. * @param scene defines the hosting scene
  100950. * @returns the box mesh
  100951. */
  100952. static CreateBox(name: string, options: {
  100953. size?: number;
  100954. width?: number;
  100955. height?: number;
  100956. depth?: number;
  100957. faceUV?: Vector4[];
  100958. faceColors?: Color4[];
  100959. sideOrientation?: number;
  100960. frontUVs?: Vector4;
  100961. backUVs?: Vector4;
  100962. wrap?: boolean;
  100963. topBaseAt?: number;
  100964. bottomBaseAt?: number;
  100965. updatable?: boolean;
  100966. }, scene?: Nullable<Scene>): Mesh;
  100967. }
  100968. }
  100969. declare module BABYLON {
  100970. /**
  100971. * Class containing static functions to help procedurally build meshes
  100972. */
  100973. export class SphereBuilder {
  100974. /**
  100975. * Creates a sphere mesh
  100976. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100977. * * 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`)
  100978. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100979. * * 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
  100980. * * 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)
  100981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100984. * @param name defines the name of the mesh
  100985. * @param options defines the options used to create the mesh
  100986. * @param scene defines the hosting scene
  100987. * @returns the sphere mesh
  100988. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100989. */
  100990. static CreateSphere(name: string, options: {
  100991. segments?: number;
  100992. diameter?: number;
  100993. diameterX?: number;
  100994. diameterY?: number;
  100995. diameterZ?: number;
  100996. arc?: number;
  100997. slice?: number;
  100998. sideOrientation?: number;
  100999. frontUVs?: Vector4;
  101000. backUVs?: Vector4;
  101001. updatable?: boolean;
  101002. }, scene: any): Mesh;
  101003. }
  101004. }
  101005. declare module BABYLON.Debug {
  101006. /**
  101007. * Used to show the physics impostor around the specific mesh
  101008. */
  101009. export class PhysicsViewer {
  101010. /** @hidden */
  101011. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  101012. /** @hidden */
  101013. protected _meshes: Array<Nullable<AbstractMesh>>;
  101014. /** @hidden */
  101015. protected _scene: Nullable<Scene>;
  101016. /** @hidden */
  101017. protected _numMeshes: number;
  101018. /** @hidden */
  101019. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  101020. private _renderFunction;
  101021. private _utilityLayer;
  101022. private _debugBoxMesh;
  101023. private _debugSphereMesh;
  101024. private _debugCylinderMesh;
  101025. private _debugMaterial;
  101026. private _debugMeshMeshes;
  101027. /**
  101028. * Creates a new PhysicsViewer
  101029. * @param scene defines the hosting scene
  101030. */
  101031. constructor(scene: Scene);
  101032. /** @hidden */
  101033. protected _updateDebugMeshes(): void;
  101034. /**
  101035. * Renders a specified physic impostor
  101036. * @param impostor defines the impostor to render
  101037. * @param targetMesh defines the mesh represented by the impostor
  101038. * @returns the new debug mesh used to render the impostor
  101039. */
  101040. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  101041. /**
  101042. * Hides a specified physic impostor
  101043. * @param impostor defines the impostor to hide
  101044. */
  101045. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  101046. private _getDebugMaterial;
  101047. private _getDebugBoxMesh;
  101048. private _getDebugSphereMesh;
  101049. private _getDebugCylinderMesh;
  101050. private _getDebugMeshMesh;
  101051. private _getDebugMesh;
  101052. /** Releases all resources */
  101053. dispose(): void;
  101054. }
  101055. }
  101056. declare module BABYLON {
  101057. /**
  101058. * Class containing static functions to help procedurally build meshes
  101059. */
  101060. export class LinesBuilder {
  101061. /**
  101062. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  101063. * * 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
  101064. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  101065. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  101066. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  101067. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  101068. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  101069. * * 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
  101070. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  101071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101072. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  101073. * @param name defines the name of the new line system
  101074. * @param options defines the options used to create the line system
  101075. * @param scene defines the hosting scene
  101076. * @returns a new line system mesh
  101077. */
  101078. static CreateLineSystem(name: string, options: {
  101079. lines: Vector3[][];
  101080. updatable?: boolean;
  101081. instance?: Nullable<LinesMesh>;
  101082. colors?: Nullable<Color4[][]>;
  101083. useVertexAlpha?: boolean;
  101084. }, scene: Nullable<Scene>): LinesMesh;
  101085. /**
  101086. * Creates a line mesh
  101087. * 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
  101088. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101089. * * The parameter `points` is an array successive Vector3
  101090. * * 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
  101091. * * The optional parameter `colors` is an array of successive Color4, one per line point
  101092. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  101093. * * When updating an instance, remember that only point positions can change, not the number of points
  101094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  101096. * @param name defines the name of the new line system
  101097. * @param options defines the options used to create the line system
  101098. * @param scene defines the hosting scene
  101099. * @returns a new line mesh
  101100. */
  101101. static CreateLines(name: string, options: {
  101102. points: Vector3[];
  101103. updatable?: boolean;
  101104. instance?: Nullable<LinesMesh>;
  101105. colors?: Color4[];
  101106. useVertexAlpha?: boolean;
  101107. }, scene?: Nullable<Scene>): LinesMesh;
  101108. /**
  101109. * Creates a dashed line mesh
  101110. * * 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
  101111. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101112. * * The parameter `points` is an array successive Vector3
  101113. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  101114. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  101115. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101116. * * 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
  101117. * * When updating an instance, remember that only point positions can change, not the number of points
  101118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101119. * @param name defines the name of the mesh
  101120. * @param options defines the options used to create the mesh
  101121. * @param scene defines the hosting scene
  101122. * @returns the dashed line mesh
  101123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  101124. */
  101125. static CreateDashedLines(name: string, options: {
  101126. points: Vector3[];
  101127. dashSize?: number;
  101128. gapSize?: number;
  101129. dashNb?: number;
  101130. updatable?: boolean;
  101131. instance?: LinesMesh;
  101132. }, scene?: Nullable<Scene>): LinesMesh;
  101133. }
  101134. }
  101135. declare module BABYLON {
  101136. /**
  101137. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101138. * in order to better appreciate the issue one might have.
  101139. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101140. */
  101141. export class RayHelper {
  101142. /**
  101143. * Defines the ray we are currently tryin to visualize.
  101144. */
  101145. ray: Nullable<Ray>;
  101146. private _renderPoints;
  101147. private _renderLine;
  101148. private _renderFunction;
  101149. private _scene;
  101150. private _updateToMeshFunction;
  101151. private _attachedToMesh;
  101152. private _meshSpaceDirection;
  101153. private _meshSpaceOrigin;
  101154. /**
  101155. * Helper function to create a colored helper in a scene in one line.
  101156. * @param ray Defines the ray we are currently tryin to visualize
  101157. * @param scene Defines the scene the ray is used in
  101158. * @param color Defines the color we want to see the ray in
  101159. * @returns The newly created ray helper.
  101160. */
  101161. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  101162. /**
  101163. * Instantiate a new ray helper.
  101164. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101165. * in order to better appreciate the issue one might have.
  101166. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101167. * @param ray Defines the ray we are currently tryin to visualize
  101168. */
  101169. constructor(ray: Ray);
  101170. /**
  101171. * Shows the ray we are willing to debug.
  101172. * @param scene Defines the scene the ray needs to be rendered in
  101173. * @param color Defines the color the ray needs to be rendered in
  101174. */
  101175. show(scene: Scene, color?: Color3): void;
  101176. /**
  101177. * Hides the ray we are debugging.
  101178. */
  101179. hide(): void;
  101180. private _render;
  101181. /**
  101182. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  101183. * @param mesh Defines the mesh we want the helper attached to
  101184. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  101185. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  101186. * @param length Defines the length of the ray
  101187. */
  101188. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  101189. /**
  101190. * Detach the ray helper from the mesh it has previously been attached to.
  101191. */
  101192. detachFromMesh(): void;
  101193. private _updateToMesh;
  101194. /**
  101195. * Dispose the helper and release its associated resources.
  101196. */
  101197. dispose(): void;
  101198. }
  101199. }
  101200. declare module BABYLON.Debug {
  101201. /**
  101202. * Class used to render a debug view of a given skeleton
  101203. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  101204. */
  101205. export class SkeletonViewer {
  101206. /** defines the skeleton to render */
  101207. skeleton: Skeleton;
  101208. /** defines the mesh attached to the skeleton */
  101209. mesh: AbstractMesh;
  101210. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101211. autoUpdateBonesMatrices: boolean;
  101212. /** defines the rendering group id to use with the viewer */
  101213. renderingGroupId: number;
  101214. /** Gets or sets the color used to render the skeleton */
  101215. color: Color3;
  101216. private _scene;
  101217. private _debugLines;
  101218. private _debugMesh;
  101219. private _isEnabled;
  101220. private _renderFunction;
  101221. private _utilityLayer;
  101222. /**
  101223. * Returns the mesh used to render the bones
  101224. */
  101225. readonly debugMesh: Nullable<LinesMesh>;
  101226. /**
  101227. * Creates a new SkeletonViewer
  101228. * @param skeleton defines the skeleton to render
  101229. * @param mesh defines the mesh attached to the skeleton
  101230. * @param scene defines the hosting scene
  101231. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  101232. * @param renderingGroupId defines the rendering group id to use with the viewer
  101233. */
  101234. constructor(
  101235. /** defines the skeleton to render */
  101236. skeleton: Skeleton,
  101237. /** defines the mesh attached to the skeleton */
  101238. mesh: AbstractMesh, scene: Scene,
  101239. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101240. autoUpdateBonesMatrices?: boolean,
  101241. /** defines the rendering group id to use with the viewer */
  101242. renderingGroupId?: number);
  101243. /** Gets or sets a boolean indicating if the viewer is enabled */
  101244. isEnabled: boolean;
  101245. private _getBonePosition;
  101246. private _getLinesForBonesWithLength;
  101247. private _getLinesForBonesNoLength;
  101248. /** Update the viewer to sync with current skeleton state */
  101249. update(): void;
  101250. /** Release associated resources */
  101251. dispose(): void;
  101252. }
  101253. }
  101254. declare module BABYLON {
  101255. /**
  101256. * Options to create the null engine
  101257. */
  101258. export class NullEngineOptions {
  101259. /**
  101260. * Render width (Default: 512)
  101261. */
  101262. renderWidth: number;
  101263. /**
  101264. * Render height (Default: 256)
  101265. */
  101266. renderHeight: number;
  101267. /**
  101268. * Texture size (Default: 512)
  101269. */
  101270. textureSize: number;
  101271. /**
  101272. * If delta time between frames should be constant
  101273. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101274. */
  101275. deterministicLockstep: boolean;
  101276. /**
  101277. * Maximum about of steps between frames (Default: 4)
  101278. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101279. */
  101280. lockstepMaxSteps: number;
  101281. }
  101282. /**
  101283. * The null engine class provides support for headless version of babylon.js.
  101284. * This can be used in server side scenario or for testing purposes
  101285. */
  101286. export class NullEngine extends Engine {
  101287. private _options;
  101288. /**
  101289. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101290. */
  101291. isDeterministicLockStep(): boolean;
  101292. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  101293. getLockstepMaxSteps(): number;
  101294. /**
  101295. * Sets hardware scaling, used to save performance if needed
  101296. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101297. */
  101298. getHardwareScalingLevel(): number;
  101299. constructor(options?: NullEngineOptions);
  101300. createVertexBuffer(vertices: FloatArray): DataBuffer;
  101301. createIndexBuffer(indices: IndicesArray): DataBuffer;
  101302. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101303. getRenderWidth(useScreen?: boolean): number;
  101304. getRenderHeight(useScreen?: boolean): number;
  101305. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  101306. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  101307. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101308. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101309. bindSamplers(effect: Effect): void;
  101310. enableEffect(effect: Effect): void;
  101311. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101312. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  101313. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  101314. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  101315. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  101316. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  101317. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  101318. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  101319. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  101320. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  101321. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  101322. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  101323. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  101324. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  101325. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  101326. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101327. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101328. setFloat(uniform: WebGLUniformLocation, value: number): void;
  101329. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  101330. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  101331. setBool(uniform: WebGLUniformLocation, bool: number): void;
  101332. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  101333. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  101334. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  101335. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101336. bindBuffers(vertexBuffers: {
  101337. [key: string]: VertexBuffer;
  101338. }, indexBuffer: DataBuffer, effect: Effect): void;
  101339. wipeCaches(bruteForce?: boolean): void;
  101340. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101341. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101342. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101343. /** @hidden */
  101344. _createTexture(): WebGLTexture;
  101345. /** @hidden */
  101346. _releaseTexture(texture: InternalTexture): void;
  101347. 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;
  101348. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  101349. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  101350. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  101351. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101352. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  101353. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  101354. areAllEffectsReady(): boolean;
  101355. /**
  101356. * @hidden
  101357. * Get the current error code of the webGL context
  101358. * @returns the error code
  101359. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101360. */
  101361. getError(): number;
  101362. /** @hidden */
  101363. _getUnpackAlignement(): number;
  101364. /** @hidden */
  101365. _unpackFlipY(value: boolean): void;
  101366. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  101367. /**
  101368. * Updates a dynamic vertex buffer.
  101369. * @param vertexBuffer the vertex buffer to update
  101370. * @param data the data used to update the vertex buffer
  101371. * @param byteOffset the byte offset of the data (optional)
  101372. * @param byteLength the byte length of the data (optional)
  101373. */
  101374. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101375. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101376. /** @hidden */
  101377. _bindTexture(channel: number, texture: InternalTexture): void;
  101378. /** @hidden */
  101379. _releaseBuffer(buffer: DataBuffer): boolean;
  101380. releaseEffects(): void;
  101381. displayLoadingUI(): void;
  101382. hideLoadingUI(): void;
  101383. /** @hidden */
  101384. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101385. /** @hidden */
  101386. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101387. /** @hidden */
  101388. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101389. /** @hidden */
  101390. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101391. }
  101392. }
  101393. declare module BABYLON {
  101394. /** @hidden */
  101395. export class _OcclusionDataStorage {
  101396. /** @hidden */
  101397. occlusionInternalRetryCounter: number;
  101398. /** @hidden */
  101399. isOcclusionQueryInProgress: boolean;
  101400. /** @hidden */
  101401. isOccluded: boolean;
  101402. /** @hidden */
  101403. occlusionRetryCount: number;
  101404. /** @hidden */
  101405. occlusionType: number;
  101406. /** @hidden */
  101407. occlusionQueryAlgorithmType: number;
  101408. }
  101409. interface Engine {
  101410. /**
  101411. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101412. * @return the new query
  101413. */
  101414. createQuery(): WebGLQuery;
  101415. /**
  101416. * Delete and release a webGL query
  101417. * @param query defines the query to delete
  101418. * @return the current engine
  101419. */
  101420. deleteQuery(query: WebGLQuery): Engine;
  101421. /**
  101422. * Check if a given query has resolved and got its value
  101423. * @param query defines the query to check
  101424. * @returns true if the query got its value
  101425. */
  101426. isQueryResultAvailable(query: WebGLQuery): boolean;
  101427. /**
  101428. * Gets the value of a given query
  101429. * @param query defines the query to check
  101430. * @returns the value of the query
  101431. */
  101432. getQueryResult(query: WebGLQuery): number;
  101433. /**
  101434. * Initiates an occlusion query
  101435. * @param algorithmType defines the algorithm to use
  101436. * @param query defines the query to use
  101437. * @returns the current engine
  101438. * @see http://doc.babylonjs.com/features/occlusionquery
  101439. */
  101440. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101441. /**
  101442. * Ends an occlusion query
  101443. * @see http://doc.babylonjs.com/features/occlusionquery
  101444. * @param algorithmType defines the algorithm to use
  101445. * @returns the current engine
  101446. */
  101447. endOcclusionQuery(algorithmType: number): Engine;
  101448. /**
  101449. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101450. * Please note that only one query can be issued at a time
  101451. * @returns a time token used to track the time span
  101452. */
  101453. startTimeQuery(): Nullable<_TimeToken>;
  101454. /**
  101455. * Ends a time query
  101456. * @param token defines the token used to measure the time span
  101457. * @returns the time spent (in ns)
  101458. */
  101459. endTimeQuery(token: _TimeToken): int;
  101460. /** @hidden */
  101461. _currentNonTimestampToken: Nullable<_TimeToken>;
  101462. /** @hidden */
  101463. _createTimeQuery(): WebGLQuery;
  101464. /** @hidden */
  101465. _deleteTimeQuery(query: WebGLQuery): void;
  101466. /** @hidden */
  101467. _getGlAlgorithmType(algorithmType: number): number;
  101468. /** @hidden */
  101469. _getTimeQueryResult(query: WebGLQuery): any;
  101470. /** @hidden */
  101471. _getTimeQueryAvailability(query: WebGLQuery): any;
  101472. }
  101473. interface AbstractMesh {
  101474. /**
  101475. * Backing filed
  101476. * @hidden
  101477. */
  101478. __occlusionDataStorage: _OcclusionDataStorage;
  101479. /**
  101480. * Access property
  101481. * @hidden
  101482. */
  101483. _occlusionDataStorage: _OcclusionDataStorage;
  101484. /**
  101485. * 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.
  101486. * The default value is -1 which means don't break the query and wait till the result
  101487. * @see http://doc.babylonjs.com/features/occlusionquery
  101488. */
  101489. occlusionRetryCount: number;
  101490. /**
  101491. * 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:
  101492. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101493. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101494. * * 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.
  101495. * @see http://doc.babylonjs.com/features/occlusionquery
  101496. */
  101497. occlusionType: number;
  101498. /**
  101499. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101500. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101501. * * 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.
  101502. * @see http://doc.babylonjs.com/features/occlusionquery
  101503. */
  101504. occlusionQueryAlgorithmType: number;
  101505. /**
  101506. * 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
  101507. * @see http://doc.babylonjs.com/features/occlusionquery
  101508. */
  101509. isOccluded: boolean;
  101510. /**
  101511. * Flag to check the progress status of the query
  101512. * @see http://doc.babylonjs.com/features/occlusionquery
  101513. */
  101514. isOcclusionQueryInProgress: boolean;
  101515. }
  101516. }
  101517. declare module BABYLON {
  101518. /** @hidden */
  101519. export var _forceTransformFeedbackToBundle: boolean;
  101520. interface Engine {
  101521. /**
  101522. * Creates a webGL transform feedback object
  101523. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101524. * @returns the webGL transform feedback object
  101525. */
  101526. createTransformFeedback(): WebGLTransformFeedback;
  101527. /**
  101528. * Delete a webGL transform feedback object
  101529. * @param value defines the webGL transform feedback object to delete
  101530. */
  101531. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101532. /**
  101533. * Bind a webGL transform feedback object to the webgl context
  101534. * @param value defines the webGL transform feedback object to bind
  101535. */
  101536. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101537. /**
  101538. * Begins a transform feedback operation
  101539. * @param usePoints defines if points or triangles must be used
  101540. */
  101541. beginTransformFeedback(usePoints: boolean): void;
  101542. /**
  101543. * Ends a transform feedback operation
  101544. */
  101545. endTransformFeedback(): void;
  101546. /**
  101547. * Specify the varyings to use with transform feedback
  101548. * @param program defines the associated webGL program
  101549. * @param value defines the list of strings representing the varying names
  101550. */
  101551. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101552. /**
  101553. * Bind a webGL buffer for a transform feedback operation
  101554. * @param value defines the webGL buffer to bind
  101555. */
  101556. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  101557. }
  101558. }
  101559. declare module BABYLON {
  101560. /**
  101561. * Creation options of the multi render target texture.
  101562. */
  101563. export interface IMultiRenderTargetOptions {
  101564. /**
  101565. * Define if the texture needs to create mip maps after render.
  101566. */
  101567. generateMipMaps?: boolean;
  101568. /**
  101569. * Define the types of all the draw buffers we want to create
  101570. */
  101571. types?: number[];
  101572. /**
  101573. * Define the sampling modes of all the draw buffers we want to create
  101574. */
  101575. samplingModes?: number[];
  101576. /**
  101577. * Define if a depth buffer is required
  101578. */
  101579. generateDepthBuffer?: boolean;
  101580. /**
  101581. * Define if a stencil buffer is required
  101582. */
  101583. generateStencilBuffer?: boolean;
  101584. /**
  101585. * Define if a depth texture is required instead of a depth buffer
  101586. */
  101587. generateDepthTexture?: boolean;
  101588. /**
  101589. * Define the number of desired draw buffers
  101590. */
  101591. textureCount?: number;
  101592. /**
  101593. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101594. */
  101595. doNotChangeAspectRatio?: boolean;
  101596. /**
  101597. * Define the default type of the buffers we are creating
  101598. */
  101599. defaultType?: number;
  101600. }
  101601. /**
  101602. * A multi render target, like a render target provides the ability to render to a texture.
  101603. * Unlike the render target, it can render to several draw buffers in one draw.
  101604. * This is specially interesting in deferred rendering or for any effects requiring more than
  101605. * just one color from a single pass.
  101606. */
  101607. export class MultiRenderTarget extends RenderTargetTexture {
  101608. private _internalTextures;
  101609. private _textures;
  101610. private _multiRenderTargetOptions;
  101611. /**
  101612. * Get if draw buffers are currently supported by the used hardware and browser.
  101613. */
  101614. readonly isSupported: boolean;
  101615. /**
  101616. * Get the list of textures generated by the multi render target.
  101617. */
  101618. readonly textures: Texture[];
  101619. /**
  101620. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101621. */
  101622. readonly depthTexture: Texture;
  101623. /**
  101624. * Set the wrapping mode on U of all the textures we are rendering to.
  101625. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101626. */
  101627. wrapU: number;
  101628. /**
  101629. * Set the wrapping mode on V of all the textures we are rendering to.
  101630. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101631. */
  101632. wrapV: number;
  101633. /**
  101634. * Instantiate a new multi render target texture.
  101635. * A multi render target, like a render target provides the ability to render to a texture.
  101636. * Unlike the render target, it can render to several draw buffers in one draw.
  101637. * This is specially interesting in deferred rendering or for any effects requiring more than
  101638. * just one color from a single pass.
  101639. * @param name Define the name of the texture
  101640. * @param size Define the size of the buffers to render to
  101641. * @param count Define the number of target we are rendering into
  101642. * @param scene Define the scene the texture belongs to
  101643. * @param options Define the options used to create the multi render target
  101644. */
  101645. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101646. /** @hidden */
  101647. _rebuild(): void;
  101648. private _createInternalTextures;
  101649. private _createTextures;
  101650. /**
  101651. * Define the number of samples used if MSAA is enabled.
  101652. */
  101653. samples: number;
  101654. /**
  101655. * Resize all the textures in the multi render target.
  101656. * Be carrefull as it will recreate all the data in the new texture.
  101657. * @param size Define the new size
  101658. */
  101659. resize(size: any): void;
  101660. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101661. /**
  101662. * Dispose the render targets and their associated resources
  101663. */
  101664. dispose(): void;
  101665. /**
  101666. * Release all the underlying texture used as draw buffers.
  101667. */
  101668. releaseInternalTextures(): void;
  101669. }
  101670. }
  101671. declare module BABYLON {
  101672. interface Engine {
  101673. /**
  101674. * Unbind a list of render target textures from the webGL context
  101675. * This is used only when drawBuffer extension or webGL2 are active
  101676. * @param textures defines the render target textures to unbind
  101677. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101678. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101679. */
  101680. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101681. /**
  101682. * Create a multi render target texture
  101683. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101684. * @param size defines the size of the texture
  101685. * @param options defines the creation options
  101686. * @returns the cube texture as an InternalTexture
  101687. */
  101688. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101689. /**
  101690. * Update the sample count for a given multiple render target texture
  101691. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101692. * @param textures defines the textures to update
  101693. * @param samples defines the sample count to set
  101694. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101695. */
  101696. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101697. }
  101698. }
  101699. declare module BABYLON {
  101700. /**
  101701. * Gather the list of clipboard event types as constants.
  101702. */
  101703. export class ClipboardEventTypes {
  101704. /**
  101705. * The clipboard event is fired when a copy command is active (pressed).
  101706. */
  101707. static readonly COPY: number;
  101708. /**
  101709. * The clipboard event is fired when a cut command is active (pressed).
  101710. */
  101711. static readonly CUT: number;
  101712. /**
  101713. * The clipboard event is fired when a paste command is active (pressed).
  101714. */
  101715. static readonly PASTE: number;
  101716. }
  101717. /**
  101718. * This class is used to store clipboard related info for the onClipboardObservable event.
  101719. */
  101720. export class ClipboardInfo {
  101721. /**
  101722. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101723. */
  101724. type: number;
  101725. /**
  101726. * Defines the related dom event
  101727. */
  101728. event: ClipboardEvent;
  101729. /**
  101730. *Creates an instance of ClipboardInfo.
  101731. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101732. * @param event Defines the related dom event
  101733. */
  101734. constructor(
  101735. /**
  101736. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101737. */
  101738. type: number,
  101739. /**
  101740. * Defines the related dom event
  101741. */
  101742. event: ClipboardEvent);
  101743. /**
  101744. * Get the clipboard event's type from the keycode.
  101745. * @param keyCode Defines the keyCode for the current keyboard event.
  101746. * @return {number}
  101747. */
  101748. static GetTypeFromCharacter(keyCode: number): number;
  101749. }
  101750. }
  101751. declare module BABYLON {
  101752. /**
  101753. * Class used to represent data loading progression
  101754. */
  101755. export class SceneLoaderProgressEvent {
  101756. /** defines if data length to load can be evaluated */
  101757. readonly lengthComputable: boolean;
  101758. /** defines the loaded data length */
  101759. readonly loaded: number;
  101760. /** defines the data length to load */
  101761. readonly total: number;
  101762. /**
  101763. * Create a new progress event
  101764. * @param lengthComputable defines if data length to load can be evaluated
  101765. * @param loaded defines the loaded data length
  101766. * @param total defines the data length to load
  101767. */
  101768. constructor(
  101769. /** defines if data length to load can be evaluated */
  101770. lengthComputable: boolean,
  101771. /** defines the loaded data length */
  101772. loaded: number,
  101773. /** defines the data length to load */
  101774. total: number);
  101775. /**
  101776. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101777. * @param event defines the source event
  101778. * @returns a new SceneLoaderProgressEvent
  101779. */
  101780. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101781. }
  101782. /**
  101783. * Interface used by SceneLoader plugins to define supported file extensions
  101784. */
  101785. export interface ISceneLoaderPluginExtensions {
  101786. /**
  101787. * Defines the list of supported extensions
  101788. */
  101789. [extension: string]: {
  101790. isBinary: boolean;
  101791. };
  101792. }
  101793. /**
  101794. * Interface used by SceneLoader plugin factory
  101795. */
  101796. export interface ISceneLoaderPluginFactory {
  101797. /**
  101798. * Defines the name of the factory
  101799. */
  101800. name: string;
  101801. /**
  101802. * Function called to create a new plugin
  101803. * @return the new plugin
  101804. */
  101805. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101806. /**
  101807. * Boolean indicating if the plugin can direct load specific data
  101808. */
  101809. canDirectLoad?: (data: string) => boolean;
  101810. }
  101811. /**
  101812. * Interface used to define a SceneLoader plugin
  101813. */
  101814. export interface ISceneLoaderPlugin {
  101815. /**
  101816. * The friendly name of this plugin.
  101817. */
  101818. name: string;
  101819. /**
  101820. * The file extensions supported by this plugin.
  101821. */
  101822. extensions: string | ISceneLoaderPluginExtensions;
  101823. /**
  101824. * Import meshes into a scene.
  101825. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101826. * @param scene The scene to import into
  101827. * @param data The data to import
  101828. * @param rootUrl The root url for scene and resources
  101829. * @param meshes The meshes array to import into
  101830. * @param particleSystems The particle systems array to import into
  101831. * @param skeletons The skeletons array to import into
  101832. * @param onError The callback when import fails
  101833. * @returns True if successful or false otherwise
  101834. */
  101835. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101836. /**
  101837. * Load into a scene.
  101838. * @param scene The scene to load into
  101839. * @param data The data to import
  101840. * @param rootUrl The root url for scene and resources
  101841. * @param onError The callback when import fails
  101842. * @returns true if successful or false otherwise
  101843. */
  101844. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101845. /**
  101846. * The callback that returns true if the data can be directly loaded.
  101847. */
  101848. canDirectLoad?: (data: string) => boolean;
  101849. /**
  101850. * The callback that allows custom handling of the root url based on the response url.
  101851. */
  101852. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101853. /**
  101854. * Load into an asset container.
  101855. * @param scene The scene to load into
  101856. * @param data The data to import
  101857. * @param rootUrl The root url for scene and resources
  101858. * @param onError The callback when import fails
  101859. * @returns The loaded asset container
  101860. */
  101861. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101862. }
  101863. /**
  101864. * Interface used to define an async SceneLoader plugin
  101865. */
  101866. export interface ISceneLoaderPluginAsync {
  101867. /**
  101868. * The friendly name of this plugin.
  101869. */
  101870. name: string;
  101871. /**
  101872. * The file extensions supported by this plugin.
  101873. */
  101874. extensions: string | ISceneLoaderPluginExtensions;
  101875. /**
  101876. * Import meshes into a scene.
  101877. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101878. * @param scene The scene to import into
  101879. * @param data The data to import
  101880. * @param rootUrl The root url for scene and resources
  101881. * @param onProgress The callback when the load progresses
  101882. * @param fileName Defines the name of the file to load
  101883. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101884. */
  101885. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101886. meshes: AbstractMesh[];
  101887. particleSystems: IParticleSystem[];
  101888. skeletons: Skeleton[];
  101889. animationGroups: AnimationGroup[];
  101890. }>;
  101891. /**
  101892. * Load into a scene.
  101893. * @param scene The scene to load into
  101894. * @param data The data to import
  101895. * @param rootUrl The root url for scene and resources
  101896. * @param onProgress The callback when the load progresses
  101897. * @param fileName Defines the name of the file to load
  101898. * @returns Nothing
  101899. */
  101900. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101901. /**
  101902. * The callback that returns true if the data can be directly loaded.
  101903. */
  101904. canDirectLoad?: (data: string) => boolean;
  101905. /**
  101906. * The callback that allows custom handling of the root url based on the response url.
  101907. */
  101908. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101909. /**
  101910. * Load into an asset container.
  101911. * @param scene The scene to load into
  101912. * @param data The data to import
  101913. * @param rootUrl The root url for scene and resources
  101914. * @param onProgress The callback when the load progresses
  101915. * @param fileName Defines the name of the file to load
  101916. * @returns The loaded asset container
  101917. */
  101918. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101919. }
  101920. /**
  101921. * Class used to load scene from various file formats using registered plugins
  101922. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101923. */
  101924. export class SceneLoader {
  101925. /**
  101926. * No logging while loading
  101927. */
  101928. static readonly NO_LOGGING: number;
  101929. /**
  101930. * Minimal logging while loading
  101931. */
  101932. static readonly MINIMAL_LOGGING: number;
  101933. /**
  101934. * Summary logging while loading
  101935. */
  101936. static readonly SUMMARY_LOGGING: number;
  101937. /**
  101938. * Detailled logging while loading
  101939. */
  101940. static readonly DETAILED_LOGGING: number;
  101941. /**
  101942. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101943. */
  101944. static ForceFullSceneLoadingForIncremental: boolean;
  101945. /**
  101946. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101947. */
  101948. static ShowLoadingScreen: boolean;
  101949. /**
  101950. * Defines the current logging level (while loading the scene)
  101951. * @ignorenaming
  101952. */
  101953. static loggingLevel: number;
  101954. /**
  101955. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101956. */
  101957. static CleanBoneMatrixWeights: boolean;
  101958. /**
  101959. * Event raised when a plugin is used to load a scene
  101960. */
  101961. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101962. private static _registeredPlugins;
  101963. private static _getDefaultPlugin;
  101964. private static _getPluginForExtension;
  101965. private static _getPluginForDirectLoad;
  101966. private static _getPluginForFilename;
  101967. private static _getDirectLoad;
  101968. private static _loadData;
  101969. private static _getFileInfo;
  101970. /**
  101971. * Gets a plugin that can load the given extension
  101972. * @param extension defines the extension to load
  101973. * @returns a plugin or null if none works
  101974. */
  101975. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101976. /**
  101977. * Gets a boolean indicating that the given extension can be loaded
  101978. * @param extension defines the extension to load
  101979. * @returns true if the extension is supported
  101980. */
  101981. static IsPluginForExtensionAvailable(extension: string): boolean;
  101982. /**
  101983. * Adds a new plugin to the list of registered plugins
  101984. * @param plugin defines the plugin to add
  101985. */
  101986. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101987. /**
  101988. * Import meshes into a scene
  101989. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101990. * @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)
  101991. * @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)
  101992. * @param scene the instance of BABYLON.Scene to append to
  101993. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101994. * @param onProgress a callback with a progress event for each file being loaded
  101995. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101996. * @param pluginExtension the extension used to determine the plugin
  101997. * @returns The loaded plugin
  101998. */
  101999. 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>;
  102000. /**
  102001. * Import meshes into a scene
  102002. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102003. * @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)
  102004. * @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)
  102005. * @param scene the instance of BABYLON.Scene to append to
  102006. * @param onProgress a callback with a progress event for each file being loaded
  102007. * @param pluginExtension the extension used to determine the plugin
  102008. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  102009. */
  102010. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  102011. meshes: AbstractMesh[];
  102012. particleSystems: IParticleSystem[];
  102013. skeletons: Skeleton[];
  102014. animationGroups: AnimationGroup[];
  102015. }>;
  102016. /**
  102017. * Load a scene
  102018. * @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)
  102019. * @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)
  102020. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102021. * @param onSuccess a callback with the scene when import succeeds
  102022. * @param onProgress a callback with a progress event for each file being loaded
  102023. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102024. * @param pluginExtension the extension used to determine the plugin
  102025. * @returns The loaded plugin
  102026. */
  102027. 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>;
  102028. /**
  102029. * Load a scene
  102030. * @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)
  102031. * @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)
  102032. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102033. * @param onProgress a callback with a progress event for each file being loaded
  102034. * @param pluginExtension the extension used to determine the plugin
  102035. * @returns The loaded scene
  102036. */
  102037. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102038. /**
  102039. * Append a scene
  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 is the instance of BABYLON.Scene to append to
  102043. * @param onSuccess a callback with the scene 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 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>;
  102050. /**
  102051. * Append a scene
  102052. * @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)
  102053. * @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)
  102054. * @param scene is the instance of BABYLON.Scene to append to
  102055. * @param onProgress a callback with a progress event for each file being loaded
  102056. * @param pluginExtension the extension used to determine the plugin
  102057. * @returns The given scene
  102058. */
  102059. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102060. /**
  102061. * Load a scene into an asset container
  102062. * @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)
  102063. * @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)
  102064. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  102065. * @param onSuccess a callback with the scene when import succeeds
  102066. * @param onProgress a callback with a progress event for each file being loaded
  102067. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102068. * @param pluginExtension the extension used to determine the plugin
  102069. * @returns The loaded plugin
  102070. */
  102071. 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>;
  102072. /**
  102073. * Load a scene into an asset container
  102074. * @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)
  102075. * @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)
  102076. * @param scene is the instance of Scene to append to
  102077. * @param onProgress a callback with a progress event for each file being loaded
  102078. * @param pluginExtension the extension used to determine the plugin
  102079. * @returns The loaded asset container
  102080. */
  102081. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  102082. }
  102083. }
  102084. declare module BABYLON {
  102085. /**
  102086. * Google Daydream controller
  102087. */
  102088. export class DaydreamController extends WebVRController {
  102089. /**
  102090. * Base Url for the controller model.
  102091. */
  102092. static MODEL_BASE_URL: string;
  102093. /**
  102094. * File name for the controller model.
  102095. */
  102096. static MODEL_FILENAME: string;
  102097. /**
  102098. * Gamepad Id prefix used to identify Daydream Controller.
  102099. */
  102100. static readonly GAMEPAD_ID_PREFIX: string;
  102101. /**
  102102. * Creates a new DaydreamController from a gamepad
  102103. * @param vrGamepad the gamepad that the controller should be created from
  102104. */
  102105. constructor(vrGamepad: any);
  102106. /**
  102107. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102108. * @param scene scene in which to add meshes
  102109. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102110. */
  102111. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102112. /**
  102113. * Called once for each button that changed state since the last frame
  102114. * @param buttonIdx Which button index changed
  102115. * @param state New state of the button
  102116. * @param changes Which properties on the state changed since last frame
  102117. */
  102118. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102119. }
  102120. }
  102121. declare module BABYLON {
  102122. /**
  102123. * Gear VR Controller
  102124. */
  102125. export class GearVRController extends WebVRController {
  102126. /**
  102127. * Base Url for the controller model.
  102128. */
  102129. static MODEL_BASE_URL: string;
  102130. /**
  102131. * File name for the controller model.
  102132. */
  102133. static MODEL_FILENAME: string;
  102134. /**
  102135. * Gamepad Id prefix used to identify this controller.
  102136. */
  102137. static readonly GAMEPAD_ID_PREFIX: string;
  102138. private readonly _buttonIndexToObservableNameMap;
  102139. /**
  102140. * Creates a new GearVRController from a gamepad
  102141. * @param vrGamepad the gamepad that the controller should be created from
  102142. */
  102143. constructor(vrGamepad: any);
  102144. /**
  102145. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102146. * @param scene scene in which to add meshes
  102147. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102148. */
  102149. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102150. /**
  102151. * Called once for each button that changed state since the last frame
  102152. * @param buttonIdx Which button index changed
  102153. * @param state New state of the button
  102154. * @param changes Which properties on the state changed since last frame
  102155. */
  102156. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102157. }
  102158. }
  102159. declare module BABYLON {
  102160. /**
  102161. * Generic Controller
  102162. */
  102163. export class GenericController extends WebVRController {
  102164. /**
  102165. * Base Url for the controller model.
  102166. */
  102167. static readonly MODEL_BASE_URL: string;
  102168. /**
  102169. * File name for the controller model.
  102170. */
  102171. static readonly MODEL_FILENAME: string;
  102172. /**
  102173. * Creates a new GenericController from a gamepad
  102174. * @param vrGamepad the gamepad that the controller should be created from
  102175. */
  102176. constructor(vrGamepad: any);
  102177. /**
  102178. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102179. * @param scene scene in which to add meshes
  102180. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102181. */
  102182. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102183. /**
  102184. * Called once for each button that changed state since the last frame
  102185. * @param buttonIdx Which button index changed
  102186. * @param state New state of the button
  102187. * @param changes Which properties on the state changed since last frame
  102188. */
  102189. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102190. }
  102191. }
  102192. declare module BABYLON {
  102193. /**
  102194. * Oculus Touch Controller
  102195. */
  102196. export class OculusTouchController extends WebVRController {
  102197. /**
  102198. * Base Url for the controller model.
  102199. */
  102200. static MODEL_BASE_URL: string;
  102201. /**
  102202. * File name for the left controller model.
  102203. */
  102204. static MODEL_LEFT_FILENAME: string;
  102205. /**
  102206. * File name for the right controller model.
  102207. */
  102208. static MODEL_RIGHT_FILENAME: string;
  102209. /**
  102210. * Fired when the secondary trigger on this controller is modified
  102211. */
  102212. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  102213. /**
  102214. * Fired when the thumb rest on this controller is modified
  102215. */
  102216. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  102217. /**
  102218. * Creates a new OculusTouchController from a gamepad
  102219. * @param vrGamepad the gamepad that the controller should be created from
  102220. */
  102221. constructor(vrGamepad: any);
  102222. /**
  102223. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102224. * @param scene scene in which to add meshes
  102225. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102226. */
  102227. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102228. /**
  102229. * Fired when the A button on this controller is modified
  102230. */
  102231. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102232. /**
  102233. * Fired when the B button on this controller is modified
  102234. */
  102235. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102236. /**
  102237. * Fired when the X button on this controller is modified
  102238. */
  102239. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102240. /**
  102241. * Fired when the Y button on this controller is modified
  102242. */
  102243. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102244. /**
  102245. * Called once for each button that changed state since the last frame
  102246. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  102247. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  102248. * 2) secondary trigger (same)
  102249. * 3) A (right) X (left), touch, pressed = value
  102250. * 4) B / Y
  102251. * 5) thumb rest
  102252. * @param buttonIdx Which button index changed
  102253. * @param state New state of the button
  102254. * @param changes Which properties on the state changed since last frame
  102255. */
  102256. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102257. }
  102258. }
  102259. declare module BABYLON {
  102260. /**
  102261. * Vive Controller
  102262. */
  102263. export class ViveController extends WebVRController {
  102264. /**
  102265. * Base Url for the controller model.
  102266. */
  102267. static MODEL_BASE_URL: string;
  102268. /**
  102269. * File name for the controller model.
  102270. */
  102271. static MODEL_FILENAME: string;
  102272. /**
  102273. * Creates a new ViveController from a gamepad
  102274. * @param vrGamepad the gamepad that the controller should be created from
  102275. */
  102276. constructor(vrGamepad: any);
  102277. /**
  102278. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102279. * @param scene scene in which to add meshes
  102280. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102281. */
  102282. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102283. /**
  102284. * Fired when the left button on this controller is modified
  102285. */
  102286. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102287. /**
  102288. * Fired when the right button on this controller is modified
  102289. */
  102290. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102291. /**
  102292. * Fired when the menu button on this controller is modified
  102293. */
  102294. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102295. /**
  102296. * Called once for each button that changed state since the last frame
  102297. * Vive mapping:
  102298. * 0: touchpad
  102299. * 1: trigger
  102300. * 2: left AND right buttons
  102301. * 3: menu button
  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. * Defines the WindowsMotionController object that the state of the windows motion controller
  102312. */
  102313. export class WindowsMotionController extends WebVRController {
  102314. /**
  102315. * The base url used to load the left and right controller models
  102316. */
  102317. static MODEL_BASE_URL: string;
  102318. /**
  102319. * The name of the left controller model file
  102320. */
  102321. static MODEL_LEFT_FILENAME: string;
  102322. /**
  102323. * The name of the right controller model file
  102324. */
  102325. static MODEL_RIGHT_FILENAME: string;
  102326. /**
  102327. * The controller name prefix for this controller type
  102328. */
  102329. static readonly GAMEPAD_ID_PREFIX: string;
  102330. /**
  102331. * The controller id pattern for this controller type
  102332. */
  102333. private static readonly GAMEPAD_ID_PATTERN;
  102334. private _loadedMeshInfo;
  102335. private readonly _mapping;
  102336. /**
  102337. * Fired when the trackpad on this controller is clicked
  102338. */
  102339. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  102340. /**
  102341. * Fired when the trackpad on this controller is modified
  102342. */
  102343. onTrackpadValuesChangedObservable: Observable<StickValues>;
  102344. /**
  102345. * The current x and y values of this controller's trackpad
  102346. */
  102347. trackpad: StickValues;
  102348. /**
  102349. * Creates a new WindowsMotionController from a gamepad
  102350. * @param vrGamepad the gamepad that the controller should be created from
  102351. */
  102352. constructor(vrGamepad: any);
  102353. /**
  102354. * Fired when the trigger on this controller is modified
  102355. */
  102356. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102357. /**
  102358. * Fired when the menu button on this controller is modified
  102359. */
  102360. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102361. /**
  102362. * Fired when the grip button on this controller is modified
  102363. */
  102364. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102365. /**
  102366. * Fired when the thumbstick button on this controller is modified
  102367. */
  102368. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102369. /**
  102370. * Fired when the touchpad button on this controller is modified
  102371. */
  102372. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102373. /**
  102374. * Fired when the touchpad values on this controller are modified
  102375. */
  102376. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102377. private _updateTrackpad;
  102378. /**
  102379. * Called once per frame by the engine.
  102380. */
  102381. update(): void;
  102382. /**
  102383. * Called once for each button that changed state since the last frame
  102384. * @param buttonIdx Which button index changed
  102385. * @param state New state of the button
  102386. * @param changes Which properties on the state changed since last frame
  102387. */
  102388. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102389. /**
  102390. * Moves the buttons on the controller mesh based on their current state
  102391. * @param buttonName the name of the button to move
  102392. * @param buttonValue the value of the button which determines the buttons new position
  102393. */
  102394. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102395. /**
  102396. * Moves the axis on the controller mesh based on its current state
  102397. * @param axis the index of the axis
  102398. * @param axisValue the value of the axis which determines the meshes new position
  102399. * @hidden
  102400. */
  102401. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102402. /**
  102403. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102404. * @param scene scene in which to add meshes
  102405. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102406. */
  102407. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102408. /**
  102409. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102410. * can be transformed by button presses and axes values, based on this._mapping.
  102411. *
  102412. * @param scene scene in which the meshes exist
  102413. * @param meshes list of meshes that make up the controller model to process
  102414. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102415. */
  102416. private processModel;
  102417. private createMeshInfo;
  102418. /**
  102419. * Gets the ray of the controller in the direction the controller is pointing
  102420. * @param length the length the resulting ray should be
  102421. * @returns a ray in the direction the controller is pointing
  102422. */
  102423. getForwardRay(length?: number): Ray;
  102424. /**
  102425. * Disposes of the controller
  102426. */
  102427. dispose(): void;
  102428. }
  102429. }
  102430. declare module BABYLON {
  102431. /**
  102432. * Single axis scale gizmo
  102433. */
  102434. export class AxisScaleGizmo extends Gizmo {
  102435. private _coloredMaterial;
  102436. /**
  102437. * Drag behavior responsible for the gizmos dragging interactions
  102438. */
  102439. dragBehavior: PointerDragBehavior;
  102440. private _pointerObserver;
  102441. /**
  102442. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102443. */
  102444. snapDistance: number;
  102445. /**
  102446. * Event that fires each time the gizmo snaps to a new location.
  102447. * * snapDistance is the the change in distance
  102448. */
  102449. onSnapObservable: Observable<{
  102450. snapDistance: number;
  102451. }>;
  102452. /**
  102453. * If the scaling operation should be done on all axis (default: false)
  102454. */
  102455. uniformScaling: boolean;
  102456. /**
  102457. * Creates an AxisScaleGizmo
  102458. * @param gizmoLayer The utility layer the gizmo will be added to
  102459. * @param dragAxis The axis which the gizmo will be able to scale on
  102460. * @param color The color of the gizmo
  102461. */
  102462. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102463. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102464. /**
  102465. * Disposes of the gizmo
  102466. */
  102467. dispose(): void;
  102468. /**
  102469. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102470. * @param mesh The mesh to replace the default mesh of the gizmo
  102471. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102472. */
  102473. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102474. }
  102475. }
  102476. declare module BABYLON {
  102477. /**
  102478. * Bounding box gizmo
  102479. */
  102480. export class BoundingBoxGizmo extends Gizmo {
  102481. private _lineBoundingBox;
  102482. private _rotateSpheresParent;
  102483. private _scaleBoxesParent;
  102484. private _boundingDimensions;
  102485. private _renderObserver;
  102486. private _pointerObserver;
  102487. private _scaleDragSpeed;
  102488. private _tmpQuaternion;
  102489. private _tmpVector;
  102490. private _tmpRotationMatrix;
  102491. /**
  102492. * 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)
  102493. */
  102494. ignoreChildren: boolean;
  102495. /**
  102496. * 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)
  102497. */
  102498. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102499. /**
  102500. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102501. */
  102502. rotationSphereSize: number;
  102503. /**
  102504. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102505. */
  102506. scaleBoxSize: number;
  102507. /**
  102508. * 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)
  102509. */
  102510. fixedDragMeshScreenSize: boolean;
  102511. /**
  102512. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102513. */
  102514. fixedDragMeshScreenSizeDistanceFactor: number;
  102515. /**
  102516. * Fired when a rotation sphere or scale box is dragged
  102517. */
  102518. onDragStartObservable: Observable<{}>;
  102519. /**
  102520. * Fired when a scale box is dragged
  102521. */
  102522. onScaleBoxDragObservable: Observable<{}>;
  102523. /**
  102524. * Fired when a scale box drag is ended
  102525. */
  102526. onScaleBoxDragEndObservable: Observable<{}>;
  102527. /**
  102528. * Fired when a rotation sphere is dragged
  102529. */
  102530. onRotationSphereDragObservable: Observable<{}>;
  102531. /**
  102532. * Fired when a rotation sphere drag is ended
  102533. */
  102534. onRotationSphereDragEndObservable: Observable<{}>;
  102535. /**
  102536. * 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)
  102537. */
  102538. scalePivot: Nullable<Vector3>;
  102539. /**
  102540. * Mesh used as a pivot to rotate the attached mesh
  102541. */
  102542. private _anchorMesh;
  102543. private _existingMeshScale;
  102544. private _dragMesh;
  102545. private pointerDragBehavior;
  102546. private coloredMaterial;
  102547. private hoverColoredMaterial;
  102548. /**
  102549. * Sets the color of the bounding box gizmo
  102550. * @param color the color to set
  102551. */
  102552. setColor(color: Color3): void;
  102553. /**
  102554. * Creates an BoundingBoxGizmo
  102555. * @param gizmoLayer The utility layer the gizmo will be added to
  102556. * @param color The color of the gizmo
  102557. */
  102558. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102559. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102560. private _selectNode;
  102561. /**
  102562. * Updates the bounding box information for the Gizmo
  102563. */
  102564. updateBoundingBox(): void;
  102565. private _updateRotationSpheres;
  102566. private _updateScaleBoxes;
  102567. /**
  102568. * Enables rotation on the specified axis and disables rotation on the others
  102569. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102570. */
  102571. setEnabledRotationAxis(axis: string): void;
  102572. /**
  102573. * Enables/disables scaling
  102574. * @param enable if scaling should be enabled
  102575. */
  102576. setEnabledScaling(enable: boolean): void;
  102577. private _updateDummy;
  102578. /**
  102579. * Enables a pointer drag behavior on the bounding box of the gizmo
  102580. */
  102581. enableDragBehavior(): void;
  102582. /**
  102583. * Disposes of the gizmo
  102584. */
  102585. dispose(): void;
  102586. /**
  102587. * 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)
  102588. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102589. * @returns the bounding box mesh with the passed in mesh as a child
  102590. */
  102591. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102592. /**
  102593. * CustomMeshes are not supported by this gizmo
  102594. * @param mesh The mesh to replace the default mesh of the gizmo
  102595. */
  102596. setCustomMesh(mesh: Mesh): void;
  102597. }
  102598. }
  102599. declare module BABYLON {
  102600. /**
  102601. * Single plane rotation gizmo
  102602. */
  102603. export class PlaneRotationGizmo extends Gizmo {
  102604. /**
  102605. * Drag behavior responsible for the gizmos dragging interactions
  102606. */
  102607. dragBehavior: PointerDragBehavior;
  102608. private _pointerObserver;
  102609. /**
  102610. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102611. */
  102612. snapDistance: number;
  102613. /**
  102614. * Event that fires each time the gizmo snaps to a new location.
  102615. * * snapDistance is the the change in distance
  102616. */
  102617. onSnapObservable: Observable<{
  102618. snapDistance: number;
  102619. }>;
  102620. /**
  102621. * Creates a PlaneRotationGizmo
  102622. * @param gizmoLayer The utility layer the gizmo will be added to
  102623. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102624. * @param color The color of the gizmo
  102625. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102626. */
  102627. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102628. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102629. /**
  102630. * Disposes of the gizmo
  102631. */
  102632. dispose(): void;
  102633. }
  102634. }
  102635. declare module BABYLON {
  102636. /**
  102637. * Gizmo that enables rotating a mesh along 3 axis
  102638. */
  102639. export class RotationGizmo extends Gizmo {
  102640. /**
  102641. * Internal gizmo used for interactions on the x axis
  102642. */
  102643. xGizmo: PlaneRotationGizmo;
  102644. /**
  102645. * Internal gizmo used for interactions on the y axis
  102646. */
  102647. yGizmo: PlaneRotationGizmo;
  102648. /**
  102649. * Internal gizmo used for interactions on the z axis
  102650. */
  102651. zGizmo: PlaneRotationGizmo;
  102652. /** Fires an event when any of it's sub gizmos are dragged */
  102653. onDragStartObservable: Observable<{}>;
  102654. /** Fires an event when any of it's sub gizmos are released from dragging */
  102655. onDragEndObservable: Observable<{}>;
  102656. attachedMesh: Nullable<AbstractMesh>;
  102657. /**
  102658. * Creates a RotationGizmo
  102659. * @param gizmoLayer The utility layer the gizmo will be added to
  102660. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102661. */
  102662. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102663. updateGizmoRotationToMatchAttachedMesh: boolean;
  102664. /**
  102665. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102666. */
  102667. snapDistance: number;
  102668. /**
  102669. * Ratio for the scale of the gizmo (Default: 1)
  102670. */
  102671. scaleRatio: number;
  102672. /**
  102673. * Disposes of the gizmo
  102674. */
  102675. dispose(): void;
  102676. /**
  102677. * CustomMeshes are not supported by this gizmo
  102678. * @param mesh The mesh to replace the default mesh of the gizmo
  102679. */
  102680. setCustomMesh(mesh: Mesh): void;
  102681. }
  102682. }
  102683. declare module BABYLON {
  102684. /**
  102685. * Gizmo that enables dragging a mesh along 3 axis
  102686. */
  102687. export class PositionGizmo extends Gizmo {
  102688. /**
  102689. * Internal gizmo used for interactions on the x axis
  102690. */
  102691. xGizmo: AxisDragGizmo;
  102692. /**
  102693. * Internal gizmo used for interactions on the y axis
  102694. */
  102695. yGizmo: AxisDragGizmo;
  102696. /**
  102697. * Internal gizmo used for interactions on the z axis
  102698. */
  102699. zGizmo: AxisDragGizmo;
  102700. /** Fires an event when any of it's sub gizmos are dragged */
  102701. onDragStartObservable: Observable<{}>;
  102702. /** Fires an event when any of it's sub gizmos are released from dragging */
  102703. onDragEndObservable: Observable<{}>;
  102704. attachedMesh: Nullable<AbstractMesh>;
  102705. /**
  102706. * Creates a PositionGizmo
  102707. * @param gizmoLayer The utility layer the gizmo will be added to
  102708. */
  102709. constructor(gizmoLayer?: UtilityLayerRenderer);
  102710. updateGizmoRotationToMatchAttachedMesh: boolean;
  102711. /**
  102712. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102713. */
  102714. snapDistance: number;
  102715. /**
  102716. * Ratio for the scale of the gizmo (Default: 1)
  102717. */
  102718. scaleRatio: number;
  102719. /**
  102720. * Disposes of the gizmo
  102721. */
  102722. dispose(): void;
  102723. /**
  102724. * CustomMeshes are not supported by this gizmo
  102725. * @param mesh The mesh to replace the default mesh of the gizmo
  102726. */
  102727. setCustomMesh(mesh: Mesh): void;
  102728. }
  102729. }
  102730. declare module BABYLON {
  102731. /**
  102732. * Class containing static functions to help procedurally build meshes
  102733. */
  102734. export class PolyhedronBuilder {
  102735. /**
  102736. * Creates a polyhedron mesh
  102737. * * 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
  102738. * * The parameter `size` (positive float, default 1) sets the polygon size
  102739. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102740. * * 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`
  102741. * * 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
  102742. * * 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)`)
  102743. * * 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
  102744. * * 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
  102745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102748. * @param name defines the name of the mesh
  102749. * @param options defines the options used to create the mesh
  102750. * @param scene defines the hosting scene
  102751. * @returns the polyhedron mesh
  102752. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102753. */
  102754. static CreatePolyhedron(name: string, options: {
  102755. type?: number;
  102756. size?: number;
  102757. sizeX?: number;
  102758. sizeY?: number;
  102759. sizeZ?: number;
  102760. custom?: any;
  102761. faceUV?: Vector4[];
  102762. faceColors?: Color4[];
  102763. flat?: boolean;
  102764. updatable?: boolean;
  102765. sideOrientation?: number;
  102766. frontUVs?: Vector4;
  102767. backUVs?: Vector4;
  102768. }, scene?: Nullable<Scene>): Mesh;
  102769. }
  102770. }
  102771. declare module BABYLON {
  102772. /**
  102773. * Gizmo that enables scaling a mesh along 3 axis
  102774. */
  102775. export class ScaleGizmo extends Gizmo {
  102776. /**
  102777. * Internal gizmo used for interactions on the x axis
  102778. */
  102779. xGizmo: AxisScaleGizmo;
  102780. /**
  102781. * Internal gizmo used for interactions on the y axis
  102782. */
  102783. yGizmo: AxisScaleGizmo;
  102784. /**
  102785. * Internal gizmo used for interactions on the z axis
  102786. */
  102787. zGizmo: AxisScaleGizmo;
  102788. /**
  102789. * Internal gizmo used to scale all axis equally
  102790. */
  102791. uniformScaleGizmo: AxisScaleGizmo;
  102792. /** Fires an event when any of it's sub gizmos are dragged */
  102793. onDragStartObservable: Observable<{}>;
  102794. /** Fires an event when any of it's sub gizmos are released from dragging */
  102795. onDragEndObservable: Observable<{}>;
  102796. attachedMesh: Nullable<AbstractMesh>;
  102797. /**
  102798. * Creates a ScaleGizmo
  102799. * @param gizmoLayer The utility layer the gizmo will be added to
  102800. */
  102801. constructor(gizmoLayer?: UtilityLayerRenderer);
  102802. updateGizmoRotationToMatchAttachedMesh: boolean;
  102803. /**
  102804. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102805. */
  102806. snapDistance: number;
  102807. /**
  102808. * Ratio for the scale of the gizmo (Default: 1)
  102809. */
  102810. scaleRatio: number;
  102811. /**
  102812. * Disposes of the gizmo
  102813. */
  102814. dispose(): void;
  102815. }
  102816. }
  102817. declare module BABYLON {
  102818. /**
  102819. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102820. */
  102821. export class GizmoManager implements IDisposable {
  102822. private scene;
  102823. /**
  102824. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102825. */
  102826. gizmos: {
  102827. positionGizmo: Nullable<PositionGizmo>;
  102828. rotationGizmo: Nullable<RotationGizmo>;
  102829. scaleGizmo: Nullable<ScaleGizmo>;
  102830. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102831. };
  102832. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102833. clearGizmoOnEmptyPointerEvent: boolean;
  102834. /** Fires an event when the manager is attached to a mesh */
  102835. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102836. private _gizmosEnabled;
  102837. private _pointerObserver;
  102838. private _attachedMesh;
  102839. private _boundingBoxColor;
  102840. private _defaultUtilityLayer;
  102841. private _defaultKeepDepthUtilityLayer;
  102842. /**
  102843. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102844. */
  102845. boundingBoxDragBehavior: SixDofDragBehavior;
  102846. /**
  102847. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102848. */
  102849. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102850. /**
  102851. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102852. */
  102853. usePointerToAttachGizmos: boolean;
  102854. /**
  102855. * Instatiates a gizmo manager
  102856. * @param scene the scene to overlay the gizmos on top of
  102857. */
  102858. constructor(scene: Scene);
  102859. /**
  102860. * Attaches a set of gizmos to the specified mesh
  102861. * @param mesh The mesh the gizmo's should be attached to
  102862. */
  102863. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102864. /**
  102865. * If the position gizmo is enabled
  102866. */
  102867. positionGizmoEnabled: boolean;
  102868. /**
  102869. * If the rotation gizmo is enabled
  102870. */
  102871. rotationGizmoEnabled: boolean;
  102872. /**
  102873. * If the scale gizmo is enabled
  102874. */
  102875. scaleGizmoEnabled: boolean;
  102876. /**
  102877. * If the boundingBox gizmo is enabled
  102878. */
  102879. boundingBoxGizmoEnabled: boolean;
  102880. /**
  102881. * Disposes of the gizmo manager
  102882. */
  102883. dispose(): void;
  102884. }
  102885. }
  102886. declare module BABYLON {
  102887. /**
  102888. * A directional light is defined by a direction (what a surprise!).
  102889. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102890. * 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.
  102891. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102892. */
  102893. export class DirectionalLight extends ShadowLight {
  102894. private _shadowFrustumSize;
  102895. /**
  102896. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102897. */
  102898. /**
  102899. * Specifies a fix frustum size for the shadow generation.
  102900. */
  102901. shadowFrustumSize: number;
  102902. private _shadowOrthoScale;
  102903. /**
  102904. * Gets the shadow projection scale against the optimal computed one.
  102905. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102906. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102907. */
  102908. /**
  102909. * Sets the shadow projection scale against the optimal computed one.
  102910. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102911. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102912. */
  102913. shadowOrthoScale: number;
  102914. /**
  102915. * Automatically compute the projection matrix to best fit (including all the casters)
  102916. * on each frame.
  102917. */
  102918. autoUpdateExtends: boolean;
  102919. private _orthoLeft;
  102920. private _orthoRight;
  102921. private _orthoTop;
  102922. private _orthoBottom;
  102923. /**
  102924. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102925. * The directional light is emitted from everywhere in the given direction.
  102926. * It can cast shadows.
  102927. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102928. * @param name The friendly name of the light
  102929. * @param direction The direction of the light
  102930. * @param scene The scene the light belongs to
  102931. */
  102932. constructor(name: string, direction: Vector3, scene: Scene);
  102933. /**
  102934. * Returns the string "DirectionalLight".
  102935. * @return The class name
  102936. */
  102937. getClassName(): string;
  102938. /**
  102939. * Returns the integer 1.
  102940. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102941. */
  102942. getTypeID(): number;
  102943. /**
  102944. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102945. * Returns the DirectionalLight Shadow projection matrix.
  102946. */
  102947. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102948. /**
  102949. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102950. * Returns the DirectionalLight Shadow projection matrix.
  102951. */
  102952. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102953. /**
  102954. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102955. * Returns the DirectionalLight Shadow projection matrix.
  102956. */
  102957. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102958. protected _buildUniformLayout(): void;
  102959. /**
  102960. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102961. * @param effect The effect to update
  102962. * @param lightIndex The index of the light in the effect to update
  102963. * @returns The directional light
  102964. */
  102965. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102966. /**
  102967. * Gets the minZ used for shadow according to both the scene and the light.
  102968. *
  102969. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102970. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102971. * @param activeCamera The camera we are returning the min for
  102972. * @returns the depth min z
  102973. */
  102974. getDepthMinZ(activeCamera: Camera): number;
  102975. /**
  102976. * Gets the maxZ used for shadow according to both the scene and the light.
  102977. *
  102978. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102979. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102980. * @param activeCamera The camera we are returning the max for
  102981. * @returns the depth max z
  102982. */
  102983. getDepthMaxZ(activeCamera: Camera): number;
  102984. /**
  102985. * Prepares the list of defines specific to the light type.
  102986. * @param defines the list of defines
  102987. * @param lightIndex defines the index of the light for the effect
  102988. */
  102989. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102990. }
  102991. }
  102992. declare module BABYLON {
  102993. /**
  102994. * Class containing static functions to help procedurally build meshes
  102995. */
  102996. export class HemisphereBuilder {
  102997. /**
  102998. * Creates a hemisphere mesh
  102999. * @param name defines the name of the mesh
  103000. * @param options defines the options used to create the mesh
  103001. * @param scene defines the hosting scene
  103002. * @returns the hemisphere mesh
  103003. */
  103004. static CreateHemisphere(name: string, options: {
  103005. segments?: number;
  103006. diameter?: number;
  103007. sideOrientation?: number;
  103008. }, scene: any): Mesh;
  103009. }
  103010. }
  103011. declare module BABYLON {
  103012. /**
  103013. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103014. * These values define a cone of light starting from the position, emitting toward the direction.
  103015. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103016. * and the exponent defines the speed of the decay of the light with distance (reach).
  103017. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103018. */
  103019. export class SpotLight extends ShadowLight {
  103020. private _angle;
  103021. private _innerAngle;
  103022. private _cosHalfAngle;
  103023. private _lightAngleScale;
  103024. private _lightAngleOffset;
  103025. /**
  103026. * Gets the cone angle of the spot light in Radians.
  103027. */
  103028. /**
  103029. * Sets the cone angle of the spot light in Radians.
  103030. */
  103031. angle: number;
  103032. /**
  103033. * Only used in gltf falloff mode, this defines the angle where
  103034. * the directional falloff will start before cutting at angle which could be seen
  103035. * as outer angle.
  103036. */
  103037. /**
  103038. * Only used in gltf falloff mode, this defines the angle where
  103039. * the directional falloff will start before cutting at angle which could be seen
  103040. * as outer angle.
  103041. */
  103042. innerAngle: number;
  103043. private _shadowAngleScale;
  103044. /**
  103045. * Allows scaling the angle of the light for shadow generation only.
  103046. */
  103047. /**
  103048. * Allows scaling the angle of the light for shadow generation only.
  103049. */
  103050. shadowAngleScale: number;
  103051. /**
  103052. * The light decay speed with the distance from the emission spot.
  103053. */
  103054. exponent: number;
  103055. private _projectionTextureMatrix;
  103056. /**
  103057. * Allows reading the projecton texture
  103058. */
  103059. readonly projectionTextureMatrix: Matrix;
  103060. protected _projectionTextureLightNear: number;
  103061. /**
  103062. * Gets the near clip of the Spotlight for texture projection.
  103063. */
  103064. /**
  103065. * Sets the near clip of the Spotlight for texture projection.
  103066. */
  103067. projectionTextureLightNear: number;
  103068. protected _projectionTextureLightFar: number;
  103069. /**
  103070. * Gets the far clip of the Spotlight for texture projection.
  103071. */
  103072. /**
  103073. * Sets the far clip of the Spotlight for texture projection.
  103074. */
  103075. projectionTextureLightFar: number;
  103076. protected _projectionTextureUpDirection: Vector3;
  103077. /**
  103078. * Gets the Up vector of the Spotlight for texture projection.
  103079. */
  103080. /**
  103081. * Sets the Up vector of the Spotlight for texture projection.
  103082. */
  103083. projectionTextureUpDirection: Vector3;
  103084. private _projectionTexture;
  103085. /**
  103086. * Gets the projection texture of the light.
  103087. */
  103088. /**
  103089. * Sets the projection texture of the light.
  103090. */
  103091. projectionTexture: Nullable<BaseTexture>;
  103092. private _projectionTextureViewLightDirty;
  103093. private _projectionTextureProjectionLightDirty;
  103094. private _projectionTextureDirty;
  103095. private _projectionTextureViewTargetVector;
  103096. private _projectionTextureViewLightMatrix;
  103097. private _projectionTextureProjectionLightMatrix;
  103098. private _projectionTextureScalingMatrix;
  103099. /**
  103100. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103101. * It can cast shadows.
  103102. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103103. * @param name The light friendly name
  103104. * @param position The position of the spot light in the scene
  103105. * @param direction The direction of the light in the scene
  103106. * @param angle The cone angle of the light in Radians
  103107. * @param exponent The light decay speed with the distance from the emission spot
  103108. * @param scene The scene the lights belongs to
  103109. */
  103110. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103111. /**
  103112. * Returns the string "SpotLight".
  103113. * @returns the class name
  103114. */
  103115. getClassName(): string;
  103116. /**
  103117. * Returns the integer 2.
  103118. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103119. */
  103120. getTypeID(): number;
  103121. /**
  103122. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103123. */
  103124. protected _setDirection(value: Vector3): void;
  103125. /**
  103126. * Overrides the position setter to recompute the projection texture view light Matrix.
  103127. */
  103128. protected _setPosition(value: Vector3): void;
  103129. /**
  103130. * 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.
  103131. * Returns the SpotLight.
  103132. */
  103133. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103134. protected _computeProjectionTextureViewLightMatrix(): void;
  103135. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103136. /**
  103137. * Main function for light texture projection matrix computing.
  103138. */
  103139. protected _computeProjectionTextureMatrix(): void;
  103140. protected _buildUniformLayout(): void;
  103141. private _computeAngleValues;
  103142. /**
  103143. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103144. * @param effect The effect to update
  103145. * @param lightIndex The index of the light in the effect to update
  103146. * @returns The spot light
  103147. */
  103148. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103149. /**
  103150. * Disposes the light and the associated resources.
  103151. */
  103152. dispose(): void;
  103153. /**
  103154. * Prepares the list of defines specific to the light type.
  103155. * @param defines the list of defines
  103156. * @param lightIndex defines the index of the light for the effect
  103157. */
  103158. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103159. }
  103160. }
  103161. declare module BABYLON {
  103162. /**
  103163. * Gizmo that enables viewing a light
  103164. */
  103165. export class LightGizmo extends Gizmo {
  103166. private _lightMesh;
  103167. private _material;
  103168. /**
  103169. * Creates a LightGizmo
  103170. * @param gizmoLayer The utility layer the gizmo will be added to
  103171. */
  103172. constructor(gizmoLayer?: UtilityLayerRenderer);
  103173. private _light;
  103174. /**
  103175. * The light that the gizmo is attached to
  103176. */
  103177. light: Nullable<Light>;
  103178. /**
  103179. * @hidden
  103180. * Updates the gizmo to match the attached mesh's position/rotation
  103181. */
  103182. protected _update(): void;
  103183. private static _Scale;
  103184. /**
  103185. * Creates the lines for a light mesh
  103186. */
  103187. private static _createLightLines;
  103188. private static _CreateHemisphericLightMesh;
  103189. private static _CreatePointLightMesh;
  103190. private static _CreateSpotLightMesh;
  103191. private static _CreateDirectionalLightMesh;
  103192. }
  103193. }
  103194. declare module BABYLON {
  103195. /** @hidden */
  103196. export var backgroundFragmentDeclaration: {
  103197. name: string;
  103198. shader: string;
  103199. };
  103200. }
  103201. declare module BABYLON {
  103202. /** @hidden */
  103203. export var backgroundUboDeclaration: {
  103204. name: string;
  103205. shader: string;
  103206. };
  103207. }
  103208. declare module BABYLON {
  103209. /** @hidden */
  103210. export var backgroundPixelShader: {
  103211. name: string;
  103212. shader: string;
  103213. };
  103214. }
  103215. declare module BABYLON {
  103216. /** @hidden */
  103217. export var backgroundVertexDeclaration: {
  103218. name: string;
  103219. shader: string;
  103220. };
  103221. }
  103222. declare module BABYLON {
  103223. /** @hidden */
  103224. export var backgroundVertexShader: {
  103225. name: string;
  103226. shader: string;
  103227. };
  103228. }
  103229. declare module BABYLON {
  103230. /**
  103231. * Background material used to create an efficient environement around your scene.
  103232. */
  103233. export class BackgroundMaterial extends PushMaterial {
  103234. /**
  103235. * Standard reflectance value at parallel view angle.
  103236. */
  103237. static StandardReflectance0: number;
  103238. /**
  103239. * Standard reflectance value at grazing angle.
  103240. */
  103241. static StandardReflectance90: number;
  103242. protected _primaryColor: Color3;
  103243. /**
  103244. * Key light Color (multiply against the environement texture)
  103245. */
  103246. primaryColor: Color3;
  103247. protected __perceptualColor: Nullable<Color3>;
  103248. /**
  103249. * Experimental Internal Use Only.
  103250. *
  103251. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  103252. * This acts as a helper to set the primary color to a more "human friendly" value.
  103253. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  103254. * output color as close as possible from the chosen value.
  103255. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  103256. * part of lighting setup.)
  103257. */
  103258. _perceptualColor: Nullable<Color3>;
  103259. protected _primaryColorShadowLevel: float;
  103260. /**
  103261. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  103262. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  103263. */
  103264. primaryColorShadowLevel: float;
  103265. protected _primaryColorHighlightLevel: float;
  103266. /**
  103267. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  103268. * The primary color is used at the level chosen to define what the white area would look.
  103269. */
  103270. primaryColorHighlightLevel: float;
  103271. protected _reflectionTexture: Nullable<BaseTexture>;
  103272. /**
  103273. * Reflection Texture used in the material.
  103274. * Should be author in a specific way for the best result (refer to the documentation).
  103275. */
  103276. reflectionTexture: Nullable<BaseTexture>;
  103277. protected _reflectionBlur: float;
  103278. /**
  103279. * Reflection Texture level of blur.
  103280. *
  103281. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  103282. * texture twice.
  103283. */
  103284. reflectionBlur: float;
  103285. protected _diffuseTexture: Nullable<BaseTexture>;
  103286. /**
  103287. * Diffuse Texture used in the material.
  103288. * Should be author in a specific way for the best result (refer to the documentation).
  103289. */
  103290. diffuseTexture: Nullable<BaseTexture>;
  103291. protected _shadowLights: Nullable<IShadowLight[]>;
  103292. /**
  103293. * Specify the list of lights casting shadow on the material.
  103294. * All scene shadow lights will be included if null.
  103295. */
  103296. shadowLights: Nullable<IShadowLight[]>;
  103297. protected _shadowLevel: float;
  103298. /**
  103299. * Helps adjusting the shadow to a softer level if required.
  103300. * 0 means black shadows and 1 means no shadows.
  103301. */
  103302. shadowLevel: float;
  103303. protected _sceneCenter: Vector3;
  103304. /**
  103305. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  103306. * It is usually zero but might be interesting to modify according to your setup.
  103307. */
  103308. sceneCenter: Vector3;
  103309. protected _opacityFresnel: boolean;
  103310. /**
  103311. * This helps specifying that the material is falling off to the sky box at grazing angle.
  103312. * This helps ensuring a nice transition when the camera goes under the ground.
  103313. */
  103314. opacityFresnel: boolean;
  103315. protected _reflectionFresnel: boolean;
  103316. /**
  103317. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  103318. * This helps adding a mirror texture on the ground.
  103319. */
  103320. reflectionFresnel: boolean;
  103321. protected _reflectionFalloffDistance: number;
  103322. /**
  103323. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  103324. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  103325. */
  103326. reflectionFalloffDistance: number;
  103327. protected _reflectionAmount: number;
  103328. /**
  103329. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  103330. */
  103331. reflectionAmount: number;
  103332. protected _reflectionReflectance0: number;
  103333. /**
  103334. * This specifies the weight of the reflection at grazing angle.
  103335. */
  103336. reflectionReflectance0: number;
  103337. protected _reflectionReflectance90: number;
  103338. /**
  103339. * This specifies the weight of the reflection at a perpendicular point of view.
  103340. */
  103341. reflectionReflectance90: number;
  103342. /**
  103343. * Sets the reflection reflectance fresnel values according to the default standard
  103344. * empirically know to work well :-)
  103345. */
  103346. reflectionStandardFresnelWeight: number;
  103347. protected _useRGBColor: boolean;
  103348. /**
  103349. * Helps to directly use the maps channels instead of their level.
  103350. */
  103351. useRGBColor: boolean;
  103352. protected _enableNoise: boolean;
  103353. /**
  103354. * This helps reducing the banding effect that could occur on the background.
  103355. */
  103356. enableNoise: boolean;
  103357. /**
  103358. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103359. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  103360. * Recommended to be keep at 1.0 except for special cases.
  103361. */
  103362. fovMultiplier: number;
  103363. private _fovMultiplier;
  103364. /**
  103365. * Enable the FOV adjustment feature controlled by fovMultiplier.
  103366. */
  103367. useEquirectangularFOV: boolean;
  103368. private _maxSimultaneousLights;
  103369. /**
  103370. * Number of Simultaneous lights allowed on the material.
  103371. */
  103372. maxSimultaneousLights: int;
  103373. /**
  103374. * Default configuration related to image processing available in the Background Material.
  103375. */
  103376. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103377. /**
  103378. * Keep track of the image processing observer to allow dispose and replace.
  103379. */
  103380. private _imageProcessingObserver;
  103381. /**
  103382. * Attaches a new image processing configuration to the PBR Material.
  103383. * @param configuration (if null the scene configuration will be use)
  103384. */
  103385. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103386. /**
  103387. * Gets the image processing configuration used either in this material.
  103388. */
  103389. /**
  103390. * Sets the Default image processing configuration used either in the this material.
  103391. *
  103392. * If sets to null, the scene one is in use.
  103393. */
  103394. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103395. /**
  103396. * Gets wether the color curves effect is enabled.
  103397. */
  103398. /**
  103399. * Sets wether the color curves effect is enabled.
  103400. */
  103401. cameraColorCurvesEnabled: boolean;
  103402. /**
  103403. * Gets wether the color grading effect is enabled.
  103404. */
  103405. /**
  103406. * Gets wether the color grading effect is enabled.
  103407. */
  103408. cameraColorGradingEnabled: boolean;
  103409. /**
  103410. * Gets wether tonemapping is enabled or not.
  103411. */
  103412. /**
  103413. * Sets wether tonemapping is enabled or not
  103414. */
  103415. cameraToneMappingEnabled: boolean;
  103416. /**
  103417. * The camera exposure used on this material.
  103418. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103419. * This corresponds to a photographic exposure.
  103420. */
  103421. /**
  103422. * The camera exposure used on this material.
  103423. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103424. * This corresponds to a photographic exposure.
  103425. */
  103426. cameraExposure: float;
  103427. /**
  103428. * Gets The camera contrast used on this material.
  103429. */
  103430. /**
  103431. * Sets The camera contrast used on this material.
  103432. */
  103433. cameraContrast: float;
  103434. /**
  103435. * Gets the Color Grading 2D Lookup Texture.
  103436. */
  103437. /**
  103438. * Sets the Color Grading 2D Lookup Texture.
  103439. */
  103440. cameraColorGradingTexture: Nullable<BaseTexture>;
  103441. /**
  103442. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103443. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103444. * 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;
  103445. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103446. */
  103447. /**
  103448. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103449. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103450. * 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;
  103451. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103452. */
  103453. cameraColorCurves: Nullable<ColorCurves>;
  103454. /**
  103455. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103456. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103457. */
  103458. switchToBGR: boolean;
  103459. private _renderTargets;
  103460. private _reflectionControls;
  103461. private _white;
  103462. private _primaryShadowColor;
  103463. private _primaryHighlightColor;
  103464. /**
  103465. * Instantiates a Background Material in the given scene
  103466. * @param name The friendly name of the material
  103467. * @param scene The scene to add the material to
  103468. */
  103469. constructor(name: string, scene: Scene);
  103470. /**
  103471. * Gets a boolean indicating that current material needs to register RTT
  103472. */
  103473. readonly hasRenderTargetTextures: boolean;
  103474. /**
  103475. * The entire material has been created in order to prevent overdraw.
  103476. * @returns false
  103477. */
  103478. needAlphaTesting(): boolean;
  103479. /**
  103480. * The entire material has been created in order to prevent overdraw.
  103481. * @returns true if blending is enable
  103482. */
  103483. needAlphaBlending(): boolean;
  103484. /**
  103485. * Checks wether the material is ready to be rendered for a given mesh.
  103486. * @param mesh The mesh to render
  103487. * @param subMesh The submesh to check against
  103488. * @param useInstances Specify wether or not the material is used with instances
  103489. * @returns true if all the dependencies are ready (Textures, Effects...)
  103490. */
  103491. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103492. /**
  103493. * Compute the primary color according to the chosen perceptual color.
  103494. */
  103495. private _computePrimaryColorFromPerceptualColor;
  103496. /**
  103497. * Compute the highlights and shadow colors according to their chosen levels.
  103498. */
  103499. private _computePrimaryColors;
  103500. /**
  103501. * Build the uniform buffer used in the material.
  103502. */
  103503. buildUniformLayout(): void;
  103504. /**
  103505. * Unbind the material.
  103506. */
  103507. unbind(): void;
  103508. /**
  103509. * Bind only the world matrix to the material.
  103510. * @param world The world matrix to bind.
  103511. */
  103512. bindOnlyWorldMatrix(world: Matrix): void;
  103513. /**
  103514. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103515. * @param world The world matrix to bind.
  103516. * @param subMesh The submesh to bind for.
  103517. */
  103518. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103519. /**
  103520. * Dispose the material.
  103521. * @param forceDisposeEffect Force disposal of the associated effect.
  103522. * @param forceDisposeTextures Force disposal of the associated textures.
  103523. */
  103524. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103525. /**
  103526. * Clones the material.
  103527. * @param name The cloned name.
  103528. * @returns The cloned material.
  103529. */
  103530. clone(name: string): BackgroundMaterial;
  103531. /**
  103532. * Serializes the current material to its JSON representation.
  103533. * @returns The JSON representation.
  103534. */
  103535. serialize(): any;
  103536. /**
  103537. * Gets the class name of the material
  103538. * @returns "BackgroundMaterial"
  103539. */
  103540. getClassName(): string;
  103541. /**
  103542. * Parse a JSON input to create back a background material.
  103543. * @param source The JSON data to parse
  103544. * @param scene The scene to create the parsed material in
  103545. * @param rootUrl The root url of the assets the material depends upon
  103546. * @returns the instantiated BackgroundMaterial.
  103547. */
  103548. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103549. }
  103550. }
  103551. declare module BABYLON {
  103552. /**
  103553. * Represents the different options available during the creation of
  103554. * a Environment helper.
  103555. *
  103556. * This can control the default ground, skybox and image processing setup of your scene.
  103557. */
  103558. export interface IEnvironmentHelperOptions {
  103559. /**
  103560. * Specifies wether or not to create a ground.
  103561. * True by default.
  103562. */
  103563. createGround: boolean;
  103564. /**
  103565. * Specifies the ground size.
  103566. * 15 by default.
  103567. */
  103568. groundSize: number;
  103569. /**
  103570. * The texture used on the ground for the main color.
  103571. * Comes from the BabylonJS CDN by default.
  103572. *
  103573. * Remarks: Can be either a texture or a url.
  103574. */
  103575. groundTexture: string | BaseTexture;
  103576. /**
  103577. * The color mixed in the ground texture by default.
  103578. * BabylonJS clearColor by default.
  103579. */
  103580. groundColor: Color3;
  103581. /**
  103582. * Specifies the ground opacity.
  103583. * 1 by default.
  103584. */
  103585. groundOpacity: number;
  103586. /**
  103587. * Enables the ground to receive shadows.
  103588. * True by default.
  103589. */
  103590. enableGroundShadow: boolean;
  103591. /**
  103592. * Helps preventing the shadow to be fully black on the ground.
  103593. * 0.5 by default.
  103594. */
  103595. groundShadowLevel: number;
  103596. /**
  103597. * Creates a mirror texture attach to the ground.
  103598. * false by default.
  103599. */
  103600. enableGroundMirror: boolean;
  103601. /**
  103602. * Specifies the ground mirror size ratio.
  103603. * 0.3 by default as the default kernel is 64.
  103604. */
  103605. groundMirrorSizeRatio: number;
  103606. /**
  103607. * Specifies the ground mirror blur kernel size.
  103608. * 64 by default.
  103609. */
  103610. groundMirrorBlurKernel: number;
  103611. /**
  103612. * Specifies the ground mirror visibility amount.
  103613. * 1 by default
  103614. */
  103615. groundMirrorAmount: number;
  103616. /**
  103617. * Specifies the ground mirror reflectance weight.
  103618. * This uses the standard weight of the background material to setup the fresnel effect
  103619. * of the mirror.
  103620. * 1 by default.
  103621. */
  103622. groundMirrorFresnelWeight: number;
  103623. /**
  103624. * Specifies the ground mirror Falloff distance.
  103625. * This can helps reducing the size of the reflection.
  103626. * 0 by Default.
  103627. */
  103628. groundMirrorFallOffDistance: number;
  103629. /**
  103630. * Specifies the ground mirror texture type.
  103631. * Unsigned Int by Default.
  103632. */
  103633. groundMirrorTextureType: number;
  103634. /**
  103635. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103636. * the shown objects.
  103637. */
  103638. groundYBias: number;
  103639. /**
  103640. * Specifies wether or not to create a skybox.
  103641. * True by default.
  103642. */
  103643. createSkybox: boolean;
  103644. /**
  103645. * Specifies the skybox size.
  103646. * 20 by default.
  103647. */
  103648. skyboxSize: number;
  103649. /**
  103650. * The texture used on the skybox for the main color.
  103651. * Comes from the BabylonJS CDN by default.
  103652. *
  103653. * Remarks: Can be either a texture or a url.
  103654. */
  103655. skyboxTexture: string | BaseTexture;
  103656. /**
  103657. * The color mixed in the skybox texture by default.
  103658. * BabylonJS clearColor by default.
  103659. */
  103660. skyboxColor: Color3;
  103661. /**
  103662. * The background rotation around the Y axis of the scene.
  103663. * This helps aligning the key lights of your scene with the background.
  103664. * 0 by default.
  103665. */
  103666. backgroundYRotation: number;
  103667. /**
  103668. * Compute automatically the size of the elements to best fit with the scene.
  103669. */
  103670. sizeAuto: boolean;
  103671. /**
  103672. * Default position of the rootMesh if autoSize is not true.
  103673. */
  103674. rootPosition: Vector3;
  103675. /**
  103676. * Sets up the image processing in the scene.
  103677. * true by default.
  103678. */
  103679. setupImageProcessing: boolean;
  103680. /**
  103681. * The texture used as your environment texture in the scene.
  103682. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103683. *
  103684. * Remarks: Can be either a texture or a url.
  103685. */
  103686. environmentTexture: string | BaseTexture;
  103687. /**
  103688. * The value of the exposure to apply to the scene.
  103689. * 0.6 by default if setupImageProcessing is true.
  103690. */
  103691. cameraExposure: number;
  103692. /**
  103693. * The value of the contrast to apply to the scene.
  103694. * 1.6 by default if setupImageProcessing is true.
  103695. */
  103696. cameraContrast: number;
  103697. /**
  103698. * Specifies wether or not tonemapping should be enabled in the scene.
  103699. * true by default if setupImageProcessing is true.
  103700. */
  103701. toneMappingEnabled: boolean;
  103702. }
  103703. /**
  103704. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103705. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103706. * It also helps with the default setup of your imageProcessing configuration.
  103707. */
  103708. export class EnvironmentHelper {
  103709. /**
  103710. * Default ground texture URL.
  103711. */
  103712. private static _groundTextureCDNUrl;
  103713. /**
  103714. * Default skybox texture URL.
  103715. */
  103716. private static _skyboxTextureCDNUrl;
  103717. /**
  103718. * Default environment texture URL.
  103719. */
  103720. private static _environmentTextureCDNUrl;
  103721. /**
  103722. * Creates the default options for the helper.
  103723. */
  103724. private static _getDefaultOptions;
  103725. private _rootMesh;
  103726. /**
  103727. * Gets the root mesh created by the helper.
  103728. */
  103729. readonly rootMesh: Mesh;
  103730. private _skybox;
  103731. /**
  103732. * Gets the skybox created by the helper.
  103733. */
  103734. readonly skybox: Nullable<Mesh>;
  103735. private _skyboxTexture;
  103736. /**
  103737. * Gets the skybox texture created by the helper.
  103738. */
  103739. readonly skyboxTexture: Nullable<BaseTexture>;
  103740. private _skyboxMaterial;
  103741. /**
  103742. * Gets the skybox material created by the helper.
  103743. */
  103744. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103745. private _ground;
  103746. /**
  103747. * Gets the ground mesh created by the helper.
  103748. */
  103749. readonly ground: Nullable<Mesh>;
  103750. private _groundTexture;
  103751. /**
  103752. * Gets the ground texture created by the helper.
  103753. */
  103754. readonly groundTexture: Nullable<BaseTexture>;
  103755. private _groundMirror;
  103756. /**
  103757. * Gets the ground mirror created by the helper.
  103758. */
  103759. readonly groundMirror: Nullable<MirrorTexture>;
  103760. /**
  103761. * Gets the ground mirror render list to helps pushing the meshes
  103762. * you wish in the ground reflection.
  103763. */
  103764. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103765. private _groundMaterial;
  103766. /**
  103767. * Gets the ground material created by the helper.
  103768. */
  103769. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103770. /**
  103771. * Stores the creation options.
  103772. */
  103773. private readonly _scene;
  103774. private _options;
  103775. /**
  103776. * This observable will be notified with any error during the creation of the environment,
  103777. * mainly texture creation errors.
  103778. */
  103779. onErrorObservable: Observable<{
  103780. message?: string;
  103781. exception?: any;
  103782. }>;
  103783. /**
  103784. * constructor
  103785. * @param options Defines the options we want to customize the helper
  103786. * @param scene The scene to add the material to
  103787. */
  103788. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103789. /**
  103790. * Updates the background according to the new options
  103791. * @param options
  103792. */
  103793. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103794. /**
  103795. * Sets the primary color of all the available elements.
  103796. * @param color the main color to affect to the ground and the background
  103797. */
  103798. setMainColor(color: Color3): void;
  103799. /**
  103800. * Setup the image processing according to the specified options.
  103801. */
  103802. private _setupImageProcessing;
  103803. /**
  103804. * Setup the environment texture according to the specified options.
  103805. */
  103806. private _setupEnvironmentTexture;
  103807. /**
  103808. * Setup the background according to the specified options.
  103809. */
  103810. private _setupBackground;
  103811. /**
  103812. * Get the scene sizes according to the setup.
  103813. */
  103814. private _getSceneSize;
  103815. /**
  103816. * Setup the ground according to the specified options.
  103817. */
  103818. private _setupGround;
  103819. /**
  103820. * Setup the ground material according to the specified options.
  103821. */
  103822. private _setupGroundMaterial;
  103823. /**
  103824. * Setup the ground diffuse texture according to the specified options.
  103825. */
  103826. private _setupGroundDiffuseTexture;
  103827. /**
  103828. * Setup the ground mirror texture according to the specified options.
  103829. */
  103830. private _setupGroundMirrorTexture;
  103831. /**
  103832. * Setup the ground to receive the mirror texture.
  103833. */
  103834. private _setupMirrorInGroundMaterial;
  103835. /**
  103836. * Setup the skybox according to the specified options.
  103837. */
  103838. private _setupSkybox;
  103839. /**
  103840. * Setup the skybox material according to the specified options.
  103841. */
  103842. private _setupSkyboxMaterial;
  103843. /**
  103844. * Setup the skybox reflection texture according to the specified options.
  103845. */
  103846. private _setupSkyboxReflectionTexture;
  103847. private _errorHandler;
  103848. /**
  103849. * Dispose all the elements created by the Helper.
  103850. */
  103851. dispose(): void;
  103852. }
  103853. }
  103854. declare module BABYLON {
  103855. /**
  103856. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103857. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103858. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103859. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103860. */
  103861. export class PhotoDome extends TransformNode {
  103862. private _useDirectMapping;
  103863. /**
  103864. * The texture being displayed on the sphere
  103865. */
  103866. protected _photoTexture: Texture;
  103867. /**
  103868. * Gets or sets the texture being displayed on the sphere
  103869. */
  103870. photoTexture: Texture;
  103871. /**
  103872. * Observable raised when an error occured while loading the 360 image
  103873. */
  103874. onLoadErrorObservable: Observable<string>;
  103875. /**
  103876. * The skybox material
  103877. */
  103878. protected _material: BackgroundMaterial;
  103879. /**
  103880. * The surface used for the skybox
  103881. */
  103882. protected _mesh: Mesh;
  103883. /**
  103884. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103885. * Also see the options.resolution property.
  103886. */
  103887. fovMultiplier: number;
  103888. /**
  103889. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103890. * @param name Element's name, child elements will append suffixes for their own names.
  103891. * @param urlsOfPhoto defines the url of the photo to display
  103892. * @param options defines an object containing optional or exposed sub element properties
  103893. * @param onError defines a callback called when an error occured while loading the texture
  103894. */
  103895. constructor(name: string, urlOfPhoto: string, options: {
  103896. resolution?: number;
  103897. size?: number;
  103898. useDirectMapping?: boolean;
  103899. faceForward?: boolean;
  103900. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103901. /**
  103902. * Releases resources associated with this node.
  103903. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103904. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103905. */
  103906. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103907. }
  103908. }
  103909. declare module BABYLON {
  103910. /** @hidden */
  103911. export var rgbdDecodePixelShader: {
  103912. name: string;
  103913. shader: string;
  103914. };
  103915. }
  103916. declare module BABYLON {
  103917. /**
  103918. * Class used to host texture specific utilities
  103919. */
  103920. export class BRDFTextureTools {
  103921. /**
  103922. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103923. * @param texture the texture to expand.
  103924. */
  103925. private static _ExpandDefaultBRDFTexture;
  103926. /**
  103927. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103928. * @param scene defines the hosting scene
  103929. * @returns the environment BRDF texture
  103930. */
  103931. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103932. private static _environmentBRDFBase64Texture;
  103933. }
  103934. }
  103935. declare module BABYLON {
  103936. /**
  103937. * @hidden
  103938. */
  103939. export interface IMaterialClearCoatDefines {
  103940. CLEARCOAT: boolean;
  103941. CLEARCOAT_DEFAULTIOR: boolean;
  103942. CLEARCOAT_TEXTURE: boolean;
  103943. CLEARCOAT_TEXTUREDIRECTUV: number;
  103944. CLEARCOAT_BUMP: boolean;
  103945. CLEARCOAT_BUMPDIRECTUV: number;
  103946. CLEARCOAT_TINT: boolean;
  103947. CLEARCOAT_TINT_TEXTURE: boolean;
  103948. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103949. /** @hidden */
  103950. _areTexturesDirty: boolean;
  103951. }
  103952. /**
  103953. * Define the code related to the clear coat parameters of the pbr material.
  103954. */
  103955. export class PBRClearCoatConfiguration {
  103956. /**
  103957. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103958. * The default fits with a polyurethane material.
  103959. */
  103960. private static readonly _DefaultIndiceOfRefraction;
  103961. private _isEnabled;
  103962. /**
  103963. * Defines if the clear coat is enabled in the material.
  103964. */
  103965. isEnabled: boolean;
  103966. /**
  103967. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103968. */
  103969. intensity: number;
  103970. /**
  103971. * Defines the clear coat layer roughness.
  103972. */
  103973. roughness: number;
  103974. private _indiceOfRefraction;
  103975. /**
  103976. * Defines the indice of refraction of the clear coat.
  103977. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103978. * The default fits with a polyurethane material.
  103979. * Changing the default value is more performance intensive.
  103980. */
  103981. indiceOfRefraction: number;
  103982. private _texture;
  103983. /**
  103984. * Stores the clear coat values in a texture.
  103985. */
  103986. texture: Nullable<BaseTexture>;
  103987. private _bumpTexture;
  103988. /**
  103989. * Define the clear coat specific bump texture.
  103990. */
  103991. bumpTexture: Nullable<BaseTexture>;
  103992. private _isTintEnabled;
  103993. /**
  103994. * Defines if the clear coat tint is enabled in the material.
  103995. */
  103996. isTintEnabled: boolean;
  103997. /**
  103998. * Defines the clear coat tint of the material.
  103999. * This is only use if tint is enabled
  104000. */
  104001. tintColor: Color3;
  104002. /**
  104003. * Defines the distance at which the tint color should be found in the
  104004. * clear coat media.
  104005. * This is only use if tint is enabled
  104006. */
  104007. tintColorAtDistance: number;
  104008. /**
  104009. * Defines the clear coat layer thickness.
  104010. * This is only use if tint is enabled
  104011. */
  104012. tintThickness: number;
  104013. private _tintTexture;
  104014. /**
  104015. * Stores the clear tint values in a texture.
  104016. * rgb is tint
  104017. * a is a thickness factor
  104018. */
  104019. tintTexture: Nullable<BaseTexture>;
  104020. /** @hidden */
  104021. private _internalMarkAllSubMeshesAsTexturesDirty;
  104022. /** @hidden */
  104023. _markAllSubMeshesAsTexturesDirty(): void;
  104024. /**
  104025. * Instantiate a new istance of clear coat configuration.
  104026. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104027. */
  104028. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104029. /**
  104030. * Gets wehter the submesh is ready to be used or not.
  104031. * @param defines the list of "defines" to update.
  104032. * @param scene defines the scene the material belongs to.
  104033. * @param engine defines the engine the material belongs to.
  104034. * @param disableBumpMap defines wether the material disables bump or not.
  104035. * @returns - boolean indicating that the submesh is ready or not.
  104036. */
  104037. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104038. /**
  104039. * Checks to see if a texture is used in the material.
  104040. * @param defines the list of "defines" to update.
  104041. * @param scene defines the scene to the material belongs to.
  104042. */
  104043. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104044. /**
  104045. * Binds the material data.
  104046. * @param uniformBuffer defines the Uniform buffer to fill in.
  104047. * @param scene defines the scene the material belongs to.
  104048. * @param engine defines the engine the material belongs to.
  104049. * @param disableBumpMap defines wether the material disables bump or not.
  104050. * @param isFrozen defines wether the material is frozen or not.
  104051. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104052. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104053. */
  104054. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  104055. /**
  104056. * Checks to see if a texture is used in the material.
  104057. * @param texture - Base texture to use.
  104058. * @returns - Boolean specifying if a texture is used in the material.
  104059. */
  104060. hasTexture(texture: BaseTexture): boolean;
  104061. /**
  104062. * Returns an array of the actively used textures.
  104063. * @param activeTextures Array of BaseTextures
  104064. */
  104065. getActiveTextures(activeTextures: BaseTexture[]): void;
  104066. /**
  104067. * Returns the animatable textures.
  104068. * @param animatables Array of animatable textures.
  104069. */
  104070. getAnimatables(animatables: IAnimatable[]): void;
  104071. /**
  104072. * Disposes the resources of the material.
  104073. * @param forceDisposeTextures - Forces the disposal of all textures.
  104074. */
  104075. dispose(forceDisposeTextures?: boolean): void;
  104076. /**
  104077. * Get the current class name of the texture useful for serialization or dynamic coding.
  104078. * @returns "PBRClearCoatConfiguration"
  104079. */
  104080. getClassName(): string;
  104081. /**
  104082. * Add fallbacks to the effect fallbacks list.
  104083. * @param defines defines the Base texture to use.
  104084. * @param fallbacks defines the current fallback list.
  104085. * @param currentRank defines the current fallback rank.
  104086. * @returns the new fallback rank.
  104087. */
  104088. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104089. /**
  104090. * Add the required uniforms to the current list.
  104091. * @param uniforms defines the current uniform list.
  104092. */
  104093. static AddUniforms(uniforms: string[]): void;
  104094. /**
  104095. * Add the required samplers to the current list.
  104096. * @param samplers defines the current sampler list.
  104097. */
  104098. static AddSamplers(samplers: string[]): void;
  104099. /**
  104100. * Add the required uniforms to the current buffer.
  104101. * @param uniformBuffer defines the current uniform buffer.
  104102. */
  104103. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104104. /**
  104105. * Makes a duplicate of the current configuration into another one.
  104106. * @param clearCoatConfiguration define the config where to copy the info
  104107. */
  104108. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104109. /**
  104110. * Serializes this clear coat configuration.
  104111. * @returns - An object with the serialized config.
  104112. */
  104113. serialize(): any;
  104114. /**
  104115. * Parses a Clear Coat Configuration from a serialized object.
  104116. * @param source - Serialized object.
  104117. */
  104118. parse(source: any): void;
  104119. }
  104120. }
  104121. declare module BABYLON {
  104122. /**
  104123. * @hidden
  104124. */
  104125. export interface IMaterialAnisotropicDefines {
  104126. ANISOTROPIC: boolean;
  104127. ANISOTROPIC_TEXTURE: boolean;
  104128. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104129. MAINUV1: boolean;
  104130. _areTexturesDirty: boolean;
  104131. _needUVs: boolean;
  104132. }
  104133. /**
  104134. * Define the code related to the anisotropic parameters of the pbr material.
  104135. */
  104136. export class PBRAnisotropicConfiguration {
  104137. private _isEnabled;
  104138. /**
  104139. * Defines if the anisotropy is enabled in the material.
  104140. */
  104141. isEnabled: boolean;
  104142. /**
  104143. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104144. */
  104145. intensity: number;
  104146. /**
  104147. * Defines if the effect is along the tangents, bitangents or in between.
  104148. * By default, the effect is "strectching" the highlights along the tangents.
  104149. */
  104150. direction: Vector2;
  104151. private _texture;
  104152. /**
  104153. * Stores the anisotropy values in a texture.
  104154. * rg is direction (like normal from -1 to 1)
  104155. * b is a intensity
  104156. */
  104157. texture: Nullable<BaseTexture>;
  104158. /** @hidden */
  104159. private _internalMarkAllSubMeshesAsTexturesDirty;
  104160. /** @hidden */
  104161. _markAllSubMeshesAsTexturesDirty(): void;
  104162. /**
  104163. * Instantiate a new istance of anisotropy configuration.
  104164. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104165. */
  104166. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104167. /**
  104168. * Specifies that the submesh is ready to be used.
  104169. * @param defines the list of "defines" to update.
  104170. * @param scene defines the scene the material belongs to.
  104171. * @returns - boolean indicating that the submesh is ready or not.
  104172. */
  104173. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104174. /**
  104175. * Checks to see if a texture is used in the material.
  104176. * @param defines the list of "defines" to update.
  104177. * @param mesh the mesh we are preparing the defines for.
  104178. * @param scene defines the scene the material belongs to.
  104179. */
  104180. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104181. /**
  104182. * Binds the material data.
  104183. * @param uniformBuffer defines the Uniform buffer to fill in.
  104184. * @param scene defines the scene the material belongs to.
  104185. * @param isFrozen defines wether the material is frozen or not.
  104186. */
  104187. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104188. /**
  104189. * Checks to see if a texture is used in the material.
  104190. * @param texture - Base texture to use.
  104191. * @returns - Boolean specifying if a texture is used in the material.
  104192. */
  104193. hasTexture(texture: BaseTexture): boolean;
  104194. /**
  104195. * Returns an array of the actively used textures.
  104196. * @param activeTextures Array of BaseTextures
  104197. */
  104198. getActiveTextures(activeTextures: BaseTexture[]): void;
  104199. /**
  104200. * Returns the animatable textures.
  104201. * @param animatables Array of animatable textures.
  104202. */
  104203. getAnimatables(animatables: IAnimatable[]): void;
  104204. /**
  104205. * Disposes the resources of the material.
  104206. * @param forceDisposeTextures - Forces the disposal of all textures.
  104207. */
  104208. dispose(forceDisposeTextures?: boolean): void;
  104209. /**
  104210. * Get the current class name of the texture useful for serialization or dynamic coding.
  104211. * @returns "PBRAnisotropicConfiguration"
  104212. */
  104213. getClassName(): string;
  104214. /**
  104215. * Add fallbacks to the effect fallbacks list.
  104216. * @param defines defines the Base texture to use.
  104217. * @param fallbacks defines the current fallback list.
  104218. * @param currentRank defines the current fallback rank.
  104219. * @returns the new fallback rank.
  104220. */
  104221. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104222. /**
  104223. * Add the required uniforms to the current list.
  104224. * @param uniforms defines the current uniform list.
  104225. */
  104226. static AddUniforms(uniforms: string[]): void;
  104227. /**
  104228. * Add the required uniforms to the current buffer.
  104229. * @param uniformBuffer defines the current uniform buffer.
  104230. */
  104231. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104232. /**
  104233. * Add the required samplers to the current list.
  104234. * @param samplers defines the current sampler list.
  104235. */
  104236. static AddSamplers(samplers: string[]): void;
  104237. /**
  104238. * Makes a duplicate of the current configuration into another one.
  104239. * @param anisotropicConfiguration define the config where to copy the info
  104240. */
  104241. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104242. /**
  104243. * Serializes this anisotropy configuration.
  104244. * @returns - An object with the serialized config.
  104245. */
  104246. serialize(): any;
  104247. /**
  104248. * Parses a anisotropy Configuration from a serialized object.
  104249. * @param source - Serialized object.
  104250. */
  104251. parse(source: any): void;
  104252. }
  104253. }
  104254. declare module BABYLON {
  104255. /**
  104256. * @hidden
  104257. */
  104258. export interface IMaterialBRDFDefines {
  104259. BRDF_V_HEIGHT_CORRELATED: boolean;
  104260. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104261. SPHERICAL_HARMONICS: boolean;
  104262. /** @hidden */
  104263. _areMiscDirty: boolean;
  104264. }
  104265. /**
  104266. * Define the code related to the BRDF parameters of the pbr material.
  104267. */
  104268. export class PBRBRDFConfiguration {
  104269. /**
  104270. * Default value used for the energy conservation.
  104271. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104272. */
  104273. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104274. /**
  104275. * Default value used for the Smith Visibility Height Correlated mode.
  104276. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104277. */
  104278. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104279. /**
  104280. * Default value used for the IBL diffuse part.
  104281. * This can help switching back to the polynomials mode globally which is a tiny bit
  104282. * less GPU intensive at the drawback of a lower quality.
  104283. */
  104284. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104285. private _useEnergyConservation;
  104286. /**
  104287. * Defines if the material uses energy conservation.
  104288. */
  104289. useEnergyConservation: boolean;
  104290. private _useSmithVisibilityHeightCorrelated;
  104291. /**
  104292. * LEGACY Mode set to false
  104293. * Defines if the material uses height smith correlated visibility term.
  104294. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104295. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104296. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104297. * Not relying on height correlated will also disable energy conservation.
  104298. */
  104299. useSmithVisibilityHeightCorrelated: boolean;
  104300. private _useSphericalHarmonics;
  104301. /**
  104302. * LEGACY Mode set to false
  104303. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104304. * diffuse part of the IBL.
  104305. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104306. * to the ground truth.
  104307. */
  104308. useSphericalHarmonics: boolean;
  104309. /** @hidden */
  104310. private _internalMarkAllSubMeshesAsMiscDirty;
  104311. /** @hidden */
  104312. _markAllSubMeshesAsMiscDirty(): void;
  104313. /**
  104314. * Instantiate a new istance of clear coat configuration.
  104315. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104316. */
  104317. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104318. /**
  104319. * Checks to see if a texture is used in the material.
  104320. * @param defines the list of "defines" to update.
  104321. */
  104322. prepareDefines(defines: IMaterialBRDFDefines): void;
  104323. /**
  104324. * Get the current class name of the texture useful for serialization or dynamic coding.
  104325. * @returns "PBRClearCoatConfiguration"
  104326. */
  104327. getClassName(): string;
  104328. /**
  104329. * Makes a duplicate of the current configuration into another one.
  104330. * @param brdfConfiguration define the config where to copy the info
  104331. */
  104332. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104333. /**
  104334. * Serializes this BRDF configuration.
  104335. * @returns - An object with the serialized config.
  104336. */
  104337. serialize(): any;
  104338. /**
  104339. * Parses a BRDF Configuration from a serialized object.
  104340. * @param source - Serialized object.
  104341. */
  104342. parse(source: any): void;
  104343. }
  104344. }
  104345. declare module BABYLON {
  104346. /**
  104347. * @hidden
  104348. */
  104349. export interface IMaterialSheenDefines {
  104350. SHEEN: boolean;
  104351. SHEEN_TEXTURE: boolean;
  104352. SHEEN_TEXTUREDIRECTUV: number;
  104353. SHEEN_LINKWITHALBEDO: boolean;
  104354. /** @hidden */
  104355. _areTexturesDirty: boolean;
  104356. }
  104357. /**
  104358. * Define the code related to the Sheen parameters of the pbr material.
  104359. */
  104360. export class PBRSheenConfiguration {
  104361. private _isEnabled;
  104362. /**
  104363. * Defines if the material uses sheen.
  104364. */
  104365. isEnabled: boolean;
  104366. private _linkSheenWithAlbedo;
  104367. /**
  104368. * Defines if the sheen is linked to the sheen color.
  104369. */
  104370. linkSheenWithAlbedo: boolean;
  104371. /**
  104372. * Defines the sheen intensity.
  104373. */
  104374. intensity: number;
  104375. /**
  104376. * Defines the sheen color.
  104377. */
  104378. color: Color3;
  104379. private _texture;
  104380. /**
  104381. * Stores the sheen tint values in a texture.
  104382. * rgb is tint
  104383. * a is a intensity
  104384. */
  104385. texture: Nullable<BaseTexture>;
  104386. /** @hidden */
  104387. private _internalMarkAllSubMeshesAsTexturesDirty;
  104388. /** @hidden */
  104389. _markAllSubMeshesAsTexturesDirty(): void;
  104390. /**
  104391. * Instantiate a new istance of clear coat configuration.
  104392. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104393. */
  104394. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104395. /**
  104396. * Specifies that the submesh is ready to be used.
  104397. * @param defines the list of "defines" to update.
  104398. * @param scene defines the scene the material belongs to.
  104399. * @returns - boolean indicating that the submesh is ready or not.
  104400. */
  104401. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104402. /**
  104403. * Checks to see if a texture is used in the material.
  104404. * @param defines the list of "defines" to update.
  104405. * @param scene defines the scene the material belongs to.
  104406. */
  104407. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104408. /**
  104409. * Binds the material data.
  104410. * @param uniformBuffer defines the Uniform buffer to fill in.
  104411. * @param scene defines the scene the material belongs to.
  104412. * @param isFrozen defines wether the material is frozen or not.
  104413. */
  104414. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104415. /**
  104416. * Checks to see if a texture is used in the material.
  104417. * @param texture - Base texture to use.
  104418. * @returns - Boolean specifying if a texture is used in the material.
  104419. */
  104420. hasTexture(texture: BaseTexture): boolean;
  104421. /**
  104422. * Returns an array of the actively used textures.
  104423. * @param activeTextures Array of BaseTextures
  104424. */
  104425. getActiveTextures(activeTextures: BaseTexture[]): void;
  104426. /**
  104427. * Returns the animatable textures.
  104428. * @param animatables Array of animatable textures.
  104429. */
  104430. getAnimatables(animatables: IAnimatable[]): void;
  104431. /**
  104432. * Disposes the resources of the material.
  104433. * @param forceDisposeTextures - Forces the disposal of all textures.
  104434. */
  104435. dispose(forceDisposeTextures?: boolean): void;
  104436. /**
  104437. * Get the current class name of the texture useful for serialization or dynamic coding.
  104438. * @returns "PBRSheenConfiguration"
  104439. */
  104440. getClassName(): string;
  104441. /**
  104442. * Add fallbacks to the effect fallbacks list.
  104443. * @param defines defines the Base texture to use.
  104444. * @param fallbacks defines the current fallback list.
  104445. * @param currentRank defines the current fallback rank.
  104446. * @returns the new fallback rank.
  104447. */
  104448. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104449. /**
  104450. * Add the required uniforms to the current list.
  104451. * @param uniforms defines the current uniform list.
  104452. */
  104453. static AddUniforms(uniforms: string[]): void;
  104454. /**
  104455. * Add the required uniforms to the current buffer.
  104456. * @param uniformBuffer defines the current uniform buffer.
  104457. */
  104458. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104459. /**
  104460. * Add the required samplers to the current list.
  104461. * @param samplers defines the current sampler list.
  104462. */
  104463. static AddSamplers(samplers: string[]): void;
  104464. /**
  104465. * Makes a duplicate of the current configuration into another one.
  104466. * @param sheenConfiguration define the config where to copy the info
  104467. */
  104468. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104469. /**
  104470. * Serializes this BRDF configuration.
  104471. * @returns - An object with the serialized config.
  104472. */
  104473. serialize(): any;
  104474. /**
  104475. * Parses a Sheen Configuration from a serialized object.
  104476. * @param source - Serialized object.
  104477. */
  104478. parse(source: any): void;
  104479. }
  104480. }
  104481. declare module BABYLON {
  104482. /**
  104483. * @hidden
  104484. */
  104485. export interface IMaterialSubSurfaceDefines {
  104486. SUBSURFACE: boolean;
  104487. SS_REFRACTION: boolean;
  104488. SS_TRANSLUCENCY: boolean;
  104489. SS_SCATERRING: boolean;
  104490. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104491. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104492. SS_REFRACTIONMAP_3D: boolean;
  104493. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104494. SS_LODINREFRACTIONALPHA: boolean;
  104495. SS_GAMMAREFRACTION: boolean;
  104496. SS_RGBDREFRACTION: boolean;
  104497. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104498. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104499. /** @hidden */
  104500. _areTexturesDirty: boolean;
  104501. }
  104502. /**
  104503. * Define the code related to the sub surface parameters of the pbr material.
  104504. */
  104505. export class PBRSubSurfaceConfiguration {
  104506. private _isRefractionEnabled;
  104507. /**
  104508. * Defines if the refraction is enabled in the material.
  104509. */
  104510. isRefractionEnabled: boolean;
  104511. private _isTranslucencyEnabled;
  104512. /**
  104513. * Defines if the translucency is enabled in the material.
  104514. */
  104515. isTranslucencyEnabled: boolean;
  104516. private _isScatteringEnabled;
  104517. /**
  104518. * Defines the refraction intensity of the material.
  104519. * The refraction when enabled replaces the Diffuse part of the material.
  104520. * The intensity helps transitionning between diffuse and refraction.
  104521. */
  104522. refractionIntensity: number;
  104523. /**
  104524. * Defines the translucency intensity of the material.
  104525. * When translucency has been enabled, this defines how much of the "translucency"
  104526. * is addded to the diffuse part of the material.
  104527. */
  104528. translucencyIntensity: number;
  104529. /**
  104530. * Defines the scattering intensity of the material.
  104531. * When scattering has been enabled, this defines how much of the "scattered light"
  104532. * is addded to the diffuse part of the material.
  104533. */
  104534. scatteringIntensity: number;
  104535. private _thicknessTexture;
  104536. /**
  104537. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104538. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104539. * 0 would mean minimumThickness
  104540. * 1 would mean maximumThickness
  104541. * The other channels might be use as a mask to vary the different effects intensity.
  104542. */
  104543. thicknessTexture: Nullable<BaseTexture>;
  104544. private _refractionTexture;
  104545. /**
  104546. * Defines the texture to use for refraction.
  104547. */
  104548. refractionTexture: Nullable<BaseTexture>;
  104549. private _indexOfRefraction;
  104550. /**
  104551. * Defines the indice of refraction used in the material.
  104552. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104553. */
  104554. indexOfRefraction: number;
  104555. private _invertRefractionY;
  104556. /**
  104557. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104558. */
  104559. invertRefractionY: boolean;
  104560. private _linkRefractionWithTransparency;
  104561. /**
  104562. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104563. * Materials half opaque for instance using refraction could benefit from this control.
  104564. */
  104565. linkRefractionWithTransparency: boolean;
  104566. /**
  104567. * Defines the minimum thickness stored in the thickness map.
  104568. * If no thickness map is defined, this value will be used to simulate thickness.
  104569. */
  104570. minimumThickness: number;
  104571. /**
  104572. * Defines the maximum thickness stored in the thickness map.
  104573. */
  104574. maximumThickness: number;
  104575. /**
  104576. * Defines the volume tint of the material.
  104577. * This is used for both translucency and scattering.
  104578. */
  104579. tintColor: Color3;
  104580. /**
  104581. * Defines the distance at which the tint color should be found in the media.
  104582. * This is used for refraction only.
  104583. */
  104584. tintColorAtDistance: number;
  104585. /**
  104586. * Defines how far each channel transmit through the media.
  104587. * It is defined as a color to simplify it selection.
  104588. */
  104589. diffusionDistance: Color3;
  104590. private _useMaskFromThicknessTexture;
  104591. /**
  104592. * Stores the intensity of the different subsurface effects in the thickness texture.
  104593. * * the green channel is the translucency intensity.
  104594. * * the blue channel is the scattering intensity.
  104595. * * the alpha channel is the refraction intensity.
  104596. */
  104597. useMaskFromThicknessTexture: boolean;
  104598. /** @hidden */
  104599. private _internalMarkAllSubMeshesAsTexturesDirty;
  104600. /** @hidden */
  104601. _markAllSubMeshesAsTexturesDirty(): void;
  104602. /**
  104603. * Instantiate a new istance of sub surface configuration.
  104604. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104605. */
  104606. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104607. /**
  104608. * Gets wehter the submesh is ready to be used or not.
  104609. * @param defines the list of "defines" to update.
  104610. * @param scene defines the scene the material belongs to.
  104611. * @returns - boolean indicating that the submesh is ready or not.
  104612. */
  104613. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104614. /**
  104615. * Checks to see if a texture is used in the material.
  104616. * @param defines the list of "defines" to update.
  104617. * @param scene defines the scene to the material belongs to.
  104618. */
  104619. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104620. /**
  104621. * Binds the material data.
  104622. * @param uniformBuffer defines the Uniform buffer to fill in.
  104623. * @param scene defines the scene the material belongs to.
  104624. * @param engine defines the engine the material belongs to.
  104625. * @param isFrozen defines wether the material is frozen or not.
  104626. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104627. */
  104628. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104629. /**
  104630. * Unbinds the material from the mesh.
  104631. * @param activeEffect defines the effect that should be unbound from.
  104632. * @returns true if unbound, otherwise false
  104633. */
  104634. unbind(activeEffect: Effect): boolean;
  104635. /**
  104636. * Returns the texture used for refraction or null if none is used.
  104637. * @param scene defines the scene the material belongs to.
  104638. * @returns - Refraction texture if present. If no refraction texture and refraction
  104639. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104640. */
  104641. private _getRefractionTexture;
  104642. /**
  104643. * Returns true if alpha blending should be disabled.
  104644. */
  104645. readonly disableAlphaBlending: boolean;
  104646. /**
  104647. * Fills the list of render target textures.
  104648. * @param renderTargets the list of render targets to update
  104649. */
  104650. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104651. /**
  104652. * Checks to see if a texture is used in the material.
  104653. * @param texture - Base texture to use.
  104654. * @returns - Boolean specifying if a texture is used in the material.
  104655. */
  104656. hasTexture(texture: BaseTexture): boolean;
  104657. /**
  104658. * Gets a boolean indicating that current material needs to register RTT
  104659. * @returns true if this uses a render target otherwise false.
  104660. */
  104661. hasRenderTargetTextures(): boolean;
  104662. /**
  104663. * Returns an array of the actively used textures.
  104664. * @param activeTextures Array of BaseTextures
  104665. */
  104666. getActiveTextures(activeTextures: BaseTexture[]): void;
  104667. /**
  104668. * Returns the animatable textures.
  104669. * @param animatables Array of animatable textures.
  104670. */
  104671. getAnimatables(animatables: IAnimatable[]): void;
  104672. /**
  104673. * Disposes the resources of the material.
  104674. * @param forceDisposeTextures - Forces the disposal of all textures.
  104675. */
  104676. dispose(forceDisposeTextures?: boolean): void;
  104677. /**
  104678. * Get the current class name of the texture useful for serialization or dynamic coding.
  104679. * @returns "PBRSubSurfaceConfiguration"
  104680. */
  104681. getClassName(): string;
  104682. /**
  104683. * Add fallbacks to the effect fallbacks list.
  104684. * @param defines defines the Base texture to use.
  104685. * @param fallbacks defines the current fallback list.
  104686. * @param currentRank defines the current fallback rank.
  104687. * @returns the new fallback rank.
  104688. */
  104689. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104690. /**
  104691. * Add the required uniforms to the current list.
  104692. * @param uniforms defines the current uniform list.
  104693. */
  104694. static AddUniforms(uniforms: string[]): void;
  104695. /**
  104696. * Add the required samplers to the current list.
  104697. * @param samplers defines the current sampler list.
  104698. */
  104699. static AddSamplers(samplers: string[]): void;
  104700. /**
  104701. * Add the required uniforms to the current buffer.
  104702. * @param uniformBuffer defines the current uniform buffer.
  104703. */
  104704. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104705. /**
  104706. * Makes a duplicate of the current configuration into another one.
  104707. * @param configuration define the config where to copy the info
  104708. */
  104709. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104710. /**
  104711. * Serializes this Sub Surface configuration.
  104712. * @returns - An object with the serialized config.
  104713. */
  104714. serialize(): any;
  104715. /**
  104716. * Parses a Sub Surface Configuration from a serialized object.
  104717. * @param source - Serialized object.
  104718. */
  104719. parse(source: any): void;
  104720. }
  104721. }
  104722. declare module BABYLON {
  104723. /** @hidden */
  104724. export var pbrFragmentDeclaration: {
  104725. name: string;
  104726. shader: string;
  104727. };
  104728. }
  104729. declare module BABYLON {
  104730. /** @hidden */
  104731. export var pbrUboDeclaration: {
  104732. name: string;
  104733. shader: string;
  104734. };
  104735. }
  104736. declare module BABYLON {
  104737. /** @hidden */
  104738. export var pbrFragmentExtraDeclaration: {
  104739. name: string;
  104740. shader: string;
  104741. };
  104742. }
  104743. declare module BABYLON {
  104744. /** @hidden */
  104745. export var pbrFragmentSamplersDeclaration: {
  104746. name: string;
  104747. shader: string;
  104748. };
  104749. }
  104750. declare module BABYLON {
  104751. /** @hidden */
  104752. export var pbrHelperFunctions: {
  104753. name: string;
  104754. shader: string;
  104755. };
  104756. }
  104757. declare module BABYLON {
  104758. /** @hidden */
  104759. export var harmonicsFunctions: {
  104760. name: string;
  104761. shader: string;
  104762. };
  104763. }
  104764. declare module BABYLON {
  104765. /** @hidden */
  104766. export var pbrDirectLightingSetupFunctions: {
  104767. name: string;
  104768. shader: string;
  104769. };
  104770. }
  104771. declare module BABYLON {
  104772. /** @hidden */
  104773. export var pbrDirectLightingFalloffFunctions: {
  104774. name: string;
  104775. shader: string;
  104776. };
  104777. }
  104778. declare module BABYLON {
  104779. /** @hidden */
  104780. export var pbrBRDFFunctions: {
  104781. name: string;
  104782. shader: string;
  104783. };
  104784. }
  104785. declare module BABYLON {
  104786. /** @hidden */
  104787. export var pbrDirectLightingFunctions: {
  104788. name: string;
  104789. shader: string;
  104790. };
  104791. }
  104792. declare module BABYLON {
  104793. /** @hidden */
  104794. export var pbrIBLFunctions: {
  104795. name: string;
  104796. shader: string;
  104797. };
  104798. }
  104799. declare module BABYLON {
  104800. /** @hidden */
  104801. export var pbrDebug: {
  104802. name: string;
  104803. shader: string;
  104804. };
  104805. }
  104806. declare module BABYLON {
  104807. /** @hidden */
  104808. export var pbrPixelShader: {
  104809. name: string;
  104810. shader: string;
  104811. };
  104812. }
  104813. declare module BABYLON {
  104814. /** @hidden */
  104815. export var pbrVertexDeclaration: {
  104816. name: string;
  104817. shader: string;
  104818. };
  104819. }
  104820. declare module BABYLON {
  104821. /** @hidden */
  104822. export var pbrVertexShader: {
  104823. name: string;
  104824. shader: string;
  104825. };
  104826. }
  104827. declare module BABYLON {
  104828. /**
  104829. * Manages the defines for the PBR Material.
  104830. * @hidden
  104831. */
  104832. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104833. PBR: boolean;
  104834. MAINUV1: boolean;
  104835. MAINUV2: boolean;
  104836. UV1: boolean;
  104837. UV2: boolean;
  104838. ALBEDO: boolean;
  104839. ALBEDODIRECTUV: number;
  104840. VERTEXCOLOR: boolean;
  104841. AMBIENT: boolean;
  104842. AMBIENTDIRECTUV: number;
  104843. AMBIENTINGRAYSCALE: boolean;
  104844. OPACITY: boolean;
  104845. VERTEXALPHA: boolean;
  104846. OPACITYDIRECTUV: number;
  104847. OPACITYRGB: boolean;
  104848. ALPHATEST: boolean;
  104849. DEPTHPREPASS: boolean;
  104850. ALPHABLEND: boolean;
  104851. ALPHAFROMALBEDO: boolean;
  104852. ALPHATESTVALUE: string;
  104853. SPECULAROVERALPHA: boolean;
  104854. RADIANCEOVERALPHA: boolean;
  104855. ALPHAFRESNEL: boolean;
  104856. LINEARALPHAFRESNEL: boolean;
  104857. PREMULTIPLYALPHA: boolean;
  104858. EMISSIVE: boolean;
  104859. EMISSIVEDIRECTUV: number;
  104860. REFLECTIVITY: boolean;
  104861. REFLECTIVITYDIRECTUV: number;
  104862. SPECULARTERM: boolean;
  104863. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104864. MICROSURFACEAUTOMATIC: boolean;
  104865. LODBASEDMICROSFURACE: boolean;
  104866. MICROSURFACEMAP: boolean;
  104867. MICROSURFACEMAPDIRECTUV: number;
  104868. METALLICWORKFLOW: boolean;
  104869. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104870. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104871. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104872. AOSTOREINMETALMAPRED: boolean;
  104873. ENVIRONMENTBRDF: boolean;
  104874. ENVIRONMENTBRDF_RGBD: boolean;
  104875. NORMAL: boolean;
  104876. TANGENT: boolean;
  104877. BUMP: boolean;
  104878. BUMPDIRECTUV: number;
  104879. OBJECTSPACE_NORMALMAP: boolean;
  104880. PARALLAX: boolean;
  104881. PARALLAXOCCLUSION: boolean;
  104882. NORMALXYSCALE: boolean;
  104883. LIGHTMAP: boolean;
  104884. LIGHTMAPDIRECTUV: number;
  104885. USELIGHTMAPASSHADOWMAP: boolean;
  104886. GAMMALIGHTMAP: boolean;
  104887. REFLECTION: boolean;
  104888. REFLECTIONMAP_3D: boolean;
  104889. REFLECTIONMAP_SPHERICAL: boolean;
  104890. REFLECTIONMAP_PLANAR: boolean;
  104891. REFLECTIONMAP_CUBIC: boolean;
  104892. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104893. REFLECTIONMAP_PROJECTION: boolean;
  104894. REFLECTIONMAP_SKYBOX: boolean;
  104895. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104896. REFLECTIONMAP_EXPLICIT: boolean;
  104897. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104898. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104899. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104900. INVERTCUBICMAP: boolean;
  104901. USESPHERICALFROMREFLECTIONMAP: boolean;
  104902. SPHERICAL_HARMONICS: boolean;
  104903. USESPHERICALINVERTEX: boolean;
  104904. REFLECTIONMAP_OPPOSITEZ: boolean;
  104905. LODINREFLECTIONALPHA: boolean;
  104906. GAMMAREFLECTION: boolean;
  104907. RGBDREFLECTION: boolean;
  104908. RADIANCEOCCLUSION: boolean;
  104909. HORIZONOCCLUSION: boolean;
  104910. INSTANCES: boolean;
  104911. NUM_BONE_INFLUENCERS: number;
  104912. BonesPerMesh: number;
  104913. BONETEXTURE: boolean;
  104914. NONUNIFORMSCALING: boolean;
  104915. MORPHTARGETS: boolean;
  104916. MORPHTARGETS_NORMAL: boolean;
  104917. MORPHTARGETS_TANGENT: boolean;
  104918. NUM_MORPH_INFLUENCERS: number;
  104919. IMAGEPROCESSING: boolean;
  104920. VIGNETTE: boolean;
  104921. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104922. VIGNETTEBLENDMODEOPAQUE: boolean;
  104923. TONEMAPPING: boolean;
  104924. TONEMAPPING_ACES: boolean;
  104925. CONTRAST: boolean;
  104926. COLORCURVES: boolean;
  104927. COLORGRADING: boolean;
  104928. COLORGRADING3D: boolean;
  104929. SAMPLER3DGREENDEPTH: boolean;
  104930. SAMPLER3DBGRMAP: boolean;
  104931. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104932. EXPOSURE: boolean;
  104933. MULTIVIEW: boolean;
  104934. USEPHYSICALLIGHTFALLOFF: boolean;
  104935. USEGLTFLIGHTFALLOFF: boolean;
  104936. TWOSIDEDLIGHTING: boolean;
  104937. SHADOWFLOAT: boolean;
  104938. CLIPPLANE: boolean;
  104939. CLIPPLANE2: boolean;
  104940. CLIPPLANE3: boolean;
  104941. CLIPPLANE4: boolean;
  104942. POINTSIZE: boolean;
  104943. FOG: boolean;
  104944. LOGARITHMICDEPTH: boolean;
  104945. FORCENORMALFORWARD: boolean;
  104946. SPECULARAA: boolean;
  104947. CLEARCOAT: boolean;
  104948. CLEARCOAT_DEFAULTIOR: boolean;
  104949. CLEARCOAT_TEXTURE: boolean;
  104950. CLEARCOAT_TEXTUREDIRECTUV: number;
  104951. CLEARCOAT_BUMP: boolean;
  104952. CLEARCOAT_BUMPDIRECTUV: number;
  104953. CLEARCOAT_TINT: boolean;
  104954. CLEARCOAT_TINT_TEXTURE: boolean;
  104955. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104956. ANISOTROPIC: boolean;
  104957. ANISOTROPIC_TEXTURE: boolean;
  104958. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104959. BRDF_V_HEIGHT_CORRELATED: boolean;
  104960. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104961. SHEEN: boolean;
  104962. SHEEN_TEXTURE: boolean;
  104963. SHEEN_TEXTUREDIRECTUV: number;
  104964. SHEEN_LINKWITHALBEDO: boolean;
  104965. SUBSURFACE: boolean;
  104966. SS_REFRACTION: boolean;
  104967. SS_TRANSLUCENCY: boolean;
  104968. SS_SCATERRING: boolean;
  104969. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104970. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104971. SS_REFRACTIONMAP_3D: boolean;
  104972. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104973. SS_LODINREFRACTIONALPHA: boolean;
  104974. SS_GAMMAREFRACTION: boolean;
  104975. SS_RGBDREFRACTION: boolean;
  104976. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104977. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104978. UNLIT: boolean;
  104979. DEBUGMODE: number;
  104980. /**
  104981. * Initializes the PBR Material defines.
  104982. */
  104983. constructor();
  104984. /**
  104985. * Resets the PBR Material defines.
  104986. */
  104987. reset(): void;
  104988. }
  104989. /**
  104990. * The Physically based material base class of BJS.
  104991. *
  104992. * This offers the main features of a standard PBR material.
  104993. * For more information, please refer to the documentation :
  104994. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104995. */
  104996. export abstract class PBRBaseMaterial extends PushMaterial {
  104997. /**
  104998. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104999. */
  105000. static readonly PBRMATERIAL_OPAQUE: number;
  105001. /**
  105002. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105003. */
  105004. static readonly PBRMATERIAL_ALPHATEST: number;
  105005. /**
  105006. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105007. */
  105008. static readonly PBRMATERIAL_ALPHABLEND: number;
  105009. /**
  105010. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105011. * They are also discarded below the alpha cutoff threshold to improve performances.
  105012. */
  105013. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105014. /**
  105015. * Defines the default value of how much AO map is occluding the analytical lights
  105016. * (point spot...).
  105017. */
  105018. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105019. /**
  105020. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  105021. */
  105022. static readonly LIGHTFALLOFF_PHYSICAL: number;
  105023. /**
  105024. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  105025. * to enhance interoperability with other engines.
  105026. */
  105027. static readonly LIGHTFALLOFF_GLTF: number;
  105028. /**
  105029. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  105030. * to enhance interoperability with other materials.
  105031. */
  105032. static readonly LIGHTFALLOFF_STANDARD: number;
  105033. /**
  105034. * Intensity of the direct lights e.g. the four lights available in your scene.
  105035. * This impacts both the direct diffuse and specular highlights.
  105036. */
  105037. protected _directIntensity: number;
  105038. /**
  105039. * Intensity of the emissive part of the material.
  105040. * This helps controlling the emissive effect without modifying the emissive color.
  105041. */
  105042. protected _emissiveIntensity: number;
  105043. /**
  105044. * Intensity of the environment e.g. how much the environment will light the object
  105045. * either through harmonics for rough material or through the refelction for shiny ones.
  105046. */
  105047. protected _environmentIntensity: number;
  105048. /**
  105049. * This is a special control allowing the reduction of the specular highlights coming from the
  105050. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105051. */
  105052. protected _specularIntensity: number;
  105053. /**
  105054. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  105055. */
  105056. private _lightingInfos;
  105057. /**
  105058. * Debug Control allowing disabling the bump map on this material.
  105059. */
  105060. protected _disableBumpMap: boolean;
  105061. /**
  105062. * AKA Diffuse Texture in standard nomenclature.
  105063. */
  105064. protected _albedoTexture: Nullable<BaseTexture>;
  105065. /**
  105066. * AKA Occlusion Texture in other nomenclature.
  105067. */
  105068. protected _ambientTexture: Nullable<BaseTexture>;
  105069. /**
  105070. * AKA Occlusion Texture Intensity in other nomenclature.
  105071. */
  105072. protected _ambientTextureStrength: number;
  105073. /**
  105074. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105075. * 1 means it completely occludes it
  105076. * 0 mean it has no impact
  105077. */
  105078. protected _ambientTextureImpactOnAnalyticalLights: number;
  105079. /**
  105080. * Stores the alpha values in a texture.
  105081. */
  105082. protected _opacityTexture: Nullable<BaseTexture>;
  105083. /**
  105084. * Stores the reflection values in a texture.
  105085. */
  105086. protected _reflectionTexture: Nullable<BaseTexture>;
  105087. /**
  105088. * Stores the emissive values in a texture.
  105089. */
  105090. protected _emissiveTexture: Nullable<BaseTexture>;
  105091. /**
  105092. * AKA Specular texture in other nomenclature.
  105093. */
  105094. protected _reflectivityTexture: Nullable<BaseTexture>;
  105095. /**
  105096. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105097. */
  105098. protected _metallicTexture: Nullable<BaseTexture>;
  105099. /**
  105100. * Specifies the metallic scalar of the metallic/roughness workflow.
  105101. * Can also be used to scale the metalness values of the metallic texture.
  105102. */
  105103. protected _metallic: Nullable<number>;
  105104. /**
  105105. * Specifies the roughness scalar of the metallic/roughness workflow.
  105106. * Can also be used to scale the roughness values of the metallic texture.
  105107. */
  105108. protected _roughness: Nullable<number>;
  105109. /**
  105110. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105111. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105112. */
  105113. protected _microSurfaceTexture: Nullable<BaseTexture>;
  105114. /**
  105115. * Stores surface normal data used to displace a mesh in a texture.
  105116. */
  105117. protected _bumpTexture: Nullable<BaseTexture>;
  105118. /**
  105119. * Stores the pre-calculated light information of a mesh in a texture.
  105120. */
  105121. protected _lightmapTexture: Nullable<BaseTexture>;
  105122. /**
  105123. * The color of a material in ambient lighting.
  105124. */
  105125. protected _ambientColor: Color3;
  105126. /**
  105127. * AKA Diffuse Color in other nomenclature.
  105128. */
  105129. protected _albedoColor: Color3;
  105130. /**
  105131. * AKA Specular Color in other nomenclature.
  105132. */
  105133. protected _reflectivityColor: Color3;
  105134. /**
  105135. * The color applied when light is reflected from a material.
  105136. */
  105137. protected _reflectionColor: Color3;
  105138. /**
  105139. * The color applied when light is emitted from a material.
  105140. */
  105141. protected _emissiveColor: Color3;
  105142. /**
  105143. * AKA Glossiness in other nomenclature.
  105144. */
  105145. protected _microSurface: number;
  105146. /**
  105147. * Specifies that the material will use the light map as a show map.
  105148. */
  105149. protected _useLightmapAsShadowmap: boolean;
  105150. /**
  105151. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105152. * makes the reflect vector face the model (under horizon).
  105153. */
  105154. protected _useHorizonOcclusion: boolean;
  105155. /**
  105156. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105157. * too much the area relying on ambient texture to define their ambient occlusion.
  105158. */
  105159. protected _useRadianceOcclusion: boolean;
  105160. /**
  105161. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105162. */
  105163. protected _useAlphaFromAlbedoTexture: boolean;
  105164. /**
  105165. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  105166. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105167. */
  105168. protected _useSpecularOverAlpha: boolean;
  105169. /**
  105170. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105171. */
  105172. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105173. /**
  105174. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105175. */
  105176. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  105177. /**
  105178. * Specifies if the metallic texture contains the roughness information in its green channel.
  105179. */
  105180. protected _useRoughnessFromMetallicTextureGreen: boolean;
  105181. /**
  105182. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105183. */
  105184. protected _useMetallnessFromMetallicTextureBlue: boolean;
  105185. /**
  105186. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105187. */
  105188. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  105189. /**
  105190. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105191. */
  105192. protected _useAmbientInGrayScale: boolean;
  105193. /**
  105194. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105195. * The material will try to infer what glossiness each pixel should be.
  105196. */
  105197. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  105198. /**
  105199. * Defines the falloff type used in this material.
  105200. * It by default is Physical.
  105201. */
  105202. protected _lightFalloff: number;
  105203. /**
  105204. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105205. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105206. */
  105207. protected _useRadianceOverAlpha: boolean;
  105208. /**
  105209. * Allows using an object space normal map (instead of tangent space).
  105210. */
  105211. protected _useObjectSpaceNormalMap: boolean;
  105212. /**
  105213. * Allows using the bump map in parallax mode.
  105214. */
  105215. protected _useParallax: boolean;
  105216. /**
  105217. * Allows using the bump map in parallax occlusion mode.
  105218. */
  105219. protected _useParallaxOcclusion: boolean;
  105220. /**
  105221. * Controls the scale bias of the parallax mode.
  105222. */
  105223. protected _parallaxScaleBias: number;
  105224. /**
  105225. * If sets to true, disables all the lights affecting the material.
  105226. */
  105227. protected _disableLighting: boolean;
  105228. /**
  105229. * Number of Simultaneous lights allowed on the material.
  105230. */
  105231. protected _maxSimultaneousLights: number;
  105232. /**
  105233. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105234. */
  105235. protected _invertNormalMapX: boolean;
  105236. /**
  105237. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105238. */
  105239. protected _invertNormalMapY: boolean;
  105240. /**
  105241. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105242. */
  105243. protected _twoSidedLighting: boolean;
  105244. /**
  105245. * Defines the alpha limits in alpha test mode.
  105246. */
  105247. protected _alphaCutOff: number;
  105248. /**
  105249. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105250. */
  105251. protected _forceAlphaTest: boolean;
  105252. /**
  105253. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105254. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105255. */
  105256. protected _useAlphaFresnel: boolean;
  105257. /**
  105258. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105259. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105260. */
  105261. protected _useLinearAlphaFresnel: boolean;
  105262. /**
  105263. * The transparency mode of the material.
  105264. */
  105265. protected _transparencyMode: Nullable<number>;
  105266. /**
  105267. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  105268. * from cos thetav and roughness:
  105269. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  105270. */
  105271. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  105272. /**
  105273. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105274. */
  105275. protected _forceIrradianceInFragment: boolean;
  105276. /**
  105277. * Force normal to face away from face.
  105278. */
  105279. protected _forceNormalForward: boolean;
  105280. /**
  105281. * Enables specular anti aliasing in the PBR shader.
  105282. * It will both interacts on the Geometry for analytical and IBL lighting.
  105283. * It also prefilter the roughness map based on the bump values.
  105284. */
  105285. protected _enableSpecularAntiAliasing: boolean;
  105286. /**
  105287. * Default configuration related to image processing available in the PBR Material.
  105288. */
  105289. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105290. /**
  105291. * Keep track of the image processing observer to allow dispose and replace.
  105292. */
  105293. private _imageProcessingObserver;
  105294. /**
  105295. * Attaches a new image processing configuration to the PBR Material.
  105296. * @param configuration
  105297. */
  105298. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105299. /**
  105300. * Stores the available render targets.
  105301. */
  105302. private _renderTargets;
  105303. /**
  105304. * Sets the global ambient color for the material used in lighting calculations.
  105305. */
  105306. private _globalAmbientColor;
  105307. /**
  105308. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  105309. */
  105310. private _useLogarithmicDepth;
  105311. /**
  105312. * If set to true, no lighting calculations will be applied.
  105313. */
  105314. private _unlit;
  105315. private _debugMode;
  105316. /**
  105317. * @hidden
  105318. * This is reserved for the inspector.
  105319. * Defines the material debug mode.
  105320. * It helps seeing only some components of the material while troubleshooting.
  105321. */
  105322. debugMode: number;
  105323. /**
  105324. * @hidden
  105325. * This is reserved for the inspector.
  105326. * Specify from where on screen the debug mode should start.
  105327. * The value goes from -1 (full screen) to 1 (not visible)
  105328. * It helps with side by side comparison against the final render
  105329. * This defaults to -1
  105330. */
  105331. private debugLimit;
  105332. /**
  105333. * @hidden
  105334. * This is reserved for the inspector.
  105335. * As the default viewing range might not be enough (if the ambient is really small for instance)
  105336. * You can use the factor to better multiply the final value.
  105337. */
  105338. private debugFactor;
  105339. /**
  105340. * Defines the clear coat layer parameters for the material.
  105341. */
  105342. readonly clearCoat: PBRClearCoatConfiguration;
  105343. /**
  105344. * Defines the anisotropic parameters for the material.
  105345. */
  105346. readonly anisotropy: PBRAnisotropicConfiguration;
  105347. /**
  105348. * Defines the BRDF parameters for the material.
  105349. */
  105350. readonly brdf: PBRBRDFConfiguration;
  105351. /**
  105352. * Defines the Sheen parameters for the material.
  105353. */
  105354. readonly sheen: PBRSheenConfiguration;
  105355. /**
  105356. * Defines the SubSurface parameters for the material.
  105357. */
  105358. readonly subSurface: PBRSubSurfaceConfiguration;
  105359. /**
  105360. * Custom callback helping to override the default shader used in the material.
  105361. */
  105362. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  105363. /**
  105364. * Instantiates a new PBRMaterial instance.
  105365. *
  105366. * @param name The material name
  105367. * @param scene The scene the material will be use in.
  105368. */
  105369. constructor(name: string, scene: Scene);
  105370. /**
  105371. * Gets a boolean indicating that current material needs to register RTT
  105372. */
  105373. readonly hasRenderTargetTextures: boolean;
  105374. /**
  105375. * Gets the name of the material class.
  105376. */
  105377. getClassName(): string;
  105378. /**
  105379. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105380. */
  105381. /**
  105382. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105383. */
  105384. useLogarithmicDepth: boolean;
  105385. /**
  105386. * Gets the current transparency mode.
  105387. */
  105388. /**
  105389. * Sets the transparency mode of the material.
  105390. *
  105391. * | Value | Type | Description |
  105392. * | ----- | ----------------------------------- | ----------- |
  105393. * | 0 | OPAQUE | |
  105394. * | 1 | ALPHATEST | |
  105395. * | 2 | ALPHABLEND | |
  105396. * | 3 | ALPHATESTANDBLEND | |
  105397. *
  105398. */
  105399. transparencyMode: Nullable<number>;
  105400. /**
  105401. * Returns true if alpha blending should be disabled.
  105402. */
  105403. private readonly _disableAlphaBlending;
  105404. /**
  105405. * Specifies whether or not this material should be rendered in alpha blend mode.
  105406. */
  105407. needAlphaBlending(): boolean;
  105408. /**
  105409. * Specifies if the mesh will require alpha blending.
  105410. * @param mesh - BJS mesh.
  105411. */
  105412. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105413. /**
  105414. * Specifies whether or not this material should be rendered in alpha test mode.
  105415. */
  105416. needAlphaTesting(): boolean;
  105417. /**
  105418. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105419. */
  105420. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105421. /**
  105422. * Gets the texture used for the alpha test.
  105423. */
  105424. getAlphaTestTexture(): Nullable<BaseTexture>;
  105425. /**
  105426. * Specifies that the submesh is ready to be used.
  105427. * @param mesh - BJS mesh.
  105428. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105429. * @param useInstances - Specifies that instances should be used.
  105430. * @returns - boolean indicating that the submesh is ready or not.
  105431. */
  105432. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105433. /**
  105434. * Specifies if the material uses metallic roughness workflow.
  105435. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105436. */
  105437. isMetallicWorkflow(): boolean;
  105438. private _prepareEffect;
  105439. private _prepareDefines;
  105440. /**
  105441. * Force shader compilation
  105442. */
  105443. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105444. clipPlane: boolean;
  105445. }>): void;
  105446. /**
  105447. * Initializes the uniform buffer layout for the shader.
  105448. */
  105449. buildUniformLayout(): void;
  105450. /**
  105451. * Unbinds the material from the mesh
  105452. */
  105453. unbind(): void;
  105454. /**
  105455. * Binds the submesh data.
  105456. * @param world - The world matrix.
  105457. * @param mesh - The BJS mesh.
  105458. * @param subMesh - A submesh of the BJS mesh.
  105459. */
  105460. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105461. /**
  105462. * Returns the animatable textures.
  105463. * @returns - Array of animatable textures.
  105464. */
  105465. getAnimatables(): IAnimatable[];
  105466. /**
  105467. * Returns the texture used for reflections.
  105468. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105469. */
  105470. private _getReflectionTexture;
  105471. /**
  105472. * Returns an array of the actively used textures.
  105473. * @returns - Array of BaseTextures
  105474. */
  105475. getActiveTextures(): BaseTexture[];
  105476. /**
  105477. * Checks to see if a texture is used in the material.
  105478. * @param texture - Base texture to use.
  105479. * @returns - Boolean specifying if a texture is used in the material.
  105480. */
  105481. hasTexture(texture: BaseTexture): boolean;
  105482. /**
  105483. * Disposes the resources of the material.
  105484. * @param forceDisposeEffect - Forces the disposal of effects.
  105485. * @param forceDisposeTextures - Forces the disposal of all textures.
  105486. */
  105487. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105488. }
  105489. }
  105490. declare module BABYLON {
  105491. /**
  105492. * The Physically based material of BJS.
  105493. *
  105494. * This offers the main features of a standard PBR material.
  105495. * For more information, please refer to the documentation :
  105496. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105497. */
  105498. export class PBRMaterial extends PBRBaseMaterial {
  105499. /**
  105500. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105501. */
  105502. static readonly PBRMATERIAL_OPAQUE: number;
  105503. /**
  105504. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105505. */
  105506. static readonly PBRMATERIAL_ALPHATEST: number;
  105507. /**
  105508. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105509. */
  105510. static readonly PBRMATERIAL_ALPHABLEND: number;
  105511. /**
  105512. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105513. * They are also discarded below the alpha cutoff threshold to improve performances.
  105514. */
  105515. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105516. /**
  105517. * Defines the default value of how much AO map is occluding the analytical lights
  105518. * (point spot...).
  105519. */
  105520. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105521. /**
  105522. * Intensity of the direct lights e.g. the four lights available in your scene.
  105523. * This impacts both the direct diffuse and specular highlights.
  105524. */
  105525. directIntensity: number;
  105526. /**
  105527. * Intensity of the emissive part of the material.
  105528. * This helps controlling the emissive effect without modifying the emissive color.
  105529. */
  105530. emissiveIntensity: number;
  105531. /**
  105532. * Intensity of the environment e.g. how much the environment will light the object
  105533. * either through harmonics for rough material or through the refelction for shiny ones.
  105534. */
  105535. environmentIntensity: number;
  105536. /**
  105537. * This is a special control allowing the reduction of the specular highlights coming from the
  105538. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105539. */
  105540. specularIntensity: number;
  105541. /**
  105542. * Debug Control allowing disabling the bump map on this material.
  105543. */
  105544. disableBumpMap: boolean;
  105545. /**
  105546. * AKA Diffuse Texture in standard nomenclature.
  105547. */
  105548. albedoTexture: BaseTexture;
  105549. /**
  105550. * AKA Occlusion Texture in other nomenclature.
  105551. */
  105552. ambientTexture: BaseTexture;
  105553. /**
  105554. * AKA Occlusion Texture Intensity in other nomenclature.
  105555. */
  105556. ambientTextureStrength: number;
  105557. /**
  105558. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105559. * 1 means it completely occludes it
  105560. * 0 mean it has no impact
  105561. */
  105562. ambientTextureImpactOnAnalyticalLights: number;
  105563. /**
  105564. * Stores the alpha values in a texture.
  105565. */
  105566. opacityTexture: BaseTexture;
  105567. /**
  105568. * Stores the reflection values in a texture.
  105569. */
  105570. reflectionTexture: Nullable<BaseTexture>;
  105571. /**
  105572. * Stores the emissive values in a texture.
  105573. */
  105574. emissiveTexture: BaseTexture;
  105575. /**
  105576. * AKA Specular texture in other nomenclature.
  105577. */
  105578. reflectivityTexture: BaseTexture;
  105579. /**
  105580. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105581. */
  105582. metallicTexture: BaseTexture;
  105583. /**
  105584. * Specifies the metallic scalar of the metallic/roughness workflow.
  105585. * Can also be used to scale the metalness values of the metallic texture.
  105586. */
  105587. metallic: Nullable<number>;
  105588. /**
  105589. * Specifies the roughness scalar of the metallic/roughness workflow.
  105590. * Can also be used to scale the roughness values of the metallic texture.
  105591. */
  105592. roughness: Nullable<number>;
  105593. /**
  105594. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105595. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105596. */
  105597. microSurfaceTexture: BaseTexture;
  105598. /**
  105599. * Stores surface normal data used to displace a mesh in a texture.
  105600. */
  105601. bumpTexture: BaseTexture;
  105602. /**
  105603. * Stores the pre-calculated light information of a mesh in a texture.
  105604. */
  105605. lightmapTexture: BaseTexture;
  105606. /**
  105607. * Stores the refracted light information in a texture.
  105608. */
  105609. refractionTexture: Nullable<BaseTexture>;
  105610. /**
  105611. * The color of a material in ambient lighting.
  105612. */
  105613. ambientColor: Color3;
  105614. /**
  105615. * AKA Diffuse Color in other nomenclature.
  105616. */
  105617. albedoColor: Color3;
  105618. /**
  105619. * AKA Specular Color in other nomenclature.
  105620. */
  105621. reflectivityColor: Color3;
  105622. /**
  105623. * The color reflected from the material.
  105624. */
  105625. reflectionColor: Color3;
  105626. /**
  105627. * The color emitted from the material.
  105628. */
  105629. emissiveColor: Color3;
  105630. /**
  105631. * AKA Glossiness in other nomenclature.
  105632. */
  105633. microSurface: number;
  105634. /**
  105635. * source material index of refraction (IOR)' / 'destination material IOR.
  105636. */
  105637. indexOfRefraction: number;
  105638. /**
  105639. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105640. */
  105641. invertRefractionY: boolean;
  105642. /**
  105643. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105644. * Materials half opaque for instance using refraction could benefit from this control.
  105645. */
  105646. linkRefractionWithTransparency: boolean;
  105647. /**
  105648. * If true, the light map contains occlusion information instead of lighting info.
  105649. */
  105650. useLightmapAsShadowmap: boolean;
  105651. /**
  105652. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105653. */
  105654. useAlphaFromAlbedoTexture: boolean;
  105655. /**
  105656. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105657. */
  105658. forceAlphaTest: boolean;
  105659. /**
  105660. * Defines the alpha limits in alpha test mode.
  105661. */
  105662. alphaCutOff: number;
  105663. /**
  105664. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105665. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105666. */
  105667. useSpecularOverAlpha: boolean;
  105668. /**
  105669. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105670. */
  105671. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105672. /**
  105673. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105674. */
  105675. useRoughnessFromMetallicTextureAlpha: boolean;
  105676. /**
  105677. * Specifies if the metallic texture contains the roughness information in its green channel.
  105678. */
  105679. useRoughnessFromMetallicTextureGreen: boolean;
  105680. /**
  105681. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105682. */
  105683. useMetallnessFromMetallicTextureBlue: boolean;
  105684. /**
  105685. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105686. */
  105687. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105688. /**
  105689. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105690. */
  105691. useAmbientInGrayScale: boolean;
  105692. /**
  105693. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105694. * The material will try to infer what glossiness each pixel should be.
  105695. */
  105696. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105697. /**
  105698. * BJS is using an harcoded light falloff based on a manually sets up range.
  105699. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105700. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105701. */
  105702. /**
  105703. * BJS is using an harcoded light falloff based on a manually sets up range.
  105704. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105705. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105706. */
  105707. usePhysicalLightFalloff: boolean;
  105708. /**
  105709. * In order to support the falloff compatibility with gltf, a special mode has been added
  105710. * to reproduce the gltf light falloff.
  105711. */
  105712. /**
  105713. * In order to support the falloff compatibility with gltf, a special mode has been added
  105714. * to reproduce the gltf light falloff.
  105715. */
  105716. useGLTFLightFalloff: boolean;
  105717. /**
  105718. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105719. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105720. */
  105721. useRadianceOverAlpha: boolean;
  105722. /**
  105723. * Allows using an object space normal map (instead of tangent space).
  105724. */
  105725. useObjectSpaceNormalMap: boolean;
  105726. /**
  105727. * Allows using the bump map in parallax mode.
  105728. */
  105729. useParallax: boolean;
  105730. /**
  105731. * Allows using the bump map in parallax occlusion mode.
  105732. */
  105733. useParallaxOcclusion: boolean;
  105734. /**
  105735. * Controls the scale bias of the parallax mode.
  105736. */
  105737. parallaxScaleBias: number;
  105738. /**
  105739. * If sets to true, disables all the lights affecting the material.
  105740. */
  105741. disableLighting: boolean;
  105742. /**
  105743. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105744. */
  105745. forceIrradianceInFragment: boolean;
  105746. /**
  105747. * Number of Simultaneous lights allowed on the material.
  105748. */
  105749. maxSimultaneousLights: number;
  105750. /**
  105751. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105752. */
  105753. invertNormalMapX: boolean;
  105754. /**
  105755. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105756. */
  105757. invertNormalMapY: boolean;
  105758. /**
  105759. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105760. */
  105761. twoSidedLighting: boolean;
  105762. /**
  105763. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105764. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105765. */
  105766. useAlphaFresnel: boolean;
  105767. /**
  105768. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105769. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105770. */
  105771. useLinearAlphaFresnel: boolean;
  105772. /**
  105773. * Let user defines the brdf lookup texture used for IBL.
  105774. * A default 8bit version is embedded but you could point at :
  105775. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105776. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105777. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105778. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105779. */
  105780. environmentBRDFTexture: Nullable<BaseTexture>;
  105781. /**
  105782. * Force normal to face away from face.
  105783. */
  105784. forceNormalForward: boolean;
  105785. /**
  105786. * Enables specular anti aliasing in the PBR shader.
  105787. * It will both interacts on the Geometry for analytical and IBL lighting.
  105788. * It also prefilter the roughness map based on the bump values.
  105789. */
  105790. enableSpecularAntiAliasing: boolean;
  105791. /**
  105792. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105793. * makes the reflect vector face the model (under horizon).
  105794. */
  105795. useHorizonOcclusion: boolean;
  105796. /**
  105797. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105798. * too much the area relying on ambient texture to define their ambient occlusion.
  105799. */
  105800. useRadianceOcclusion: boolean;
  105801. /**
  105802. * If set to true, no lighting calculations will be applied.
  105803. */
  105804. unlit: boolean;
  105805. /**
  105806. * Gets the image processing configuration used either in this material.
  105807. */
  105808. /**
  105809. * Sets the Default image processing configuration used either in the this material.
  105810. *
  105811. * If sets to null, the scene one is in use.
  105812. */
  105813. imageProcessingConfiguration: ImageProcessingConfiguration;
  105814. /**
  105815. * Gets wether the color curves effect is enabled.
  105816. */
  105817. /**
  105818. * Sets wether the color curves effect is enabled.
  105819. */
  105820. cameraColorCurvesEnabled: boolean;
  105821. /**
  105822. * Gets wether the color grading effect is enabled.
  105823. */
  105824. /**
  105825. * Gets wether the color grading effect is enabled.
  105826. */
  105827. cameraColorGradingEnabled: boolean;
  105828. /**
  105829. * Gets wether tonemapping is enabled or not.
  105830. */
  105831. /**
  105832. * Sets wether tonemapping is enabled or not
  105833. */
  105834. cameraToneMappingEnabled: boolean;
  105835. /**
  105836. * The camera exposure used on this material.
  105837. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105838. * This corresponds to a photographic exposure.
  105839. */
  105840. /**
  105841. * The camera exposure used on this material.
  105842. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105843. * This corresponds to a photographic exposure.
  105844. */
  105845. cameraExposure: number;
  105846. /**
  105847. * Gets The camera contrast used on this material.
  105848. */
  105849. /**
  105850. * Sets The camera contrast used on this material.
  105851. */
  105852. cameraContrast: number;
  105853. /**
  105854. * Gets the Color Grading 2D Lookup Texture.
  105855. */
  105856. /**
  105857. * Sets the Color Grading 2D Lookup Texture.
  105858. */
  105859. cameraColorGradingTexture: Nullable<BaseTexture>;
  105860. /**
  105861. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105862. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105863. * 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;
  105864. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105865. */
  105866. /**
  105867. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105868. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105869. * 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;
  105870. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105871. */
  105872. cameraColorCurves: Nullable<ColorCurves>;
  105873. /**
  105874. * Instantiates a new PBRMaterial instance.
  105875. *
  105876. * @param name The material name
  105877. * @param scene The scene the material will be use in.
  105878. */
  105879. constructor(name: string, scene: Scene);
  105880. /**
  105881. * Returns the name of this material class.
  105882. */
  105883. getClassName(): string;
  105884. /**
  105885. * Makes a duplicate of the current material.
  105886. * @param name - name to use for the new material.
  105887. */
  105888. clone(name: string): PBRMaterial;
  105889. /**
  105890. * Serializes this PBR Material.
  105891. * @returns - An object with the serialized material.
  105892. */
  105893. serialize(): any;
  105894. /**
  105895. * Parses a PBR Material from a serialized object.
  105896. * @param source - Serialized object.
  105897. * @param scene - BJS scene instance.
  105898. * @param rootUrl - url for the scene object
  105899. * @returns - PBRMaterial
  105900. */
  105901. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105902. }
  105903. }
  105904. declare module BABYLON {
  105905. /**
  105906. * Direct draw surface info
  105907. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105908. */
  105909. export interface DDSInfo {
  105910. /**
  105911. * Width of the texture
  105912. */
  105913. width: number;
  105914. /**
  105915. * Width of the texture
  105916. */
  105917. height: number;
  105918. /**
  105919. * Number of Mipmaps for the texture
  105920. * @see https://en.wikipedia.org/wiki/Mipmap
  105921. */
  105922. mipmapCount: number;
  105923. /**
  105924. * If the textures format is a known fourCC format
  105925. * @see https://www.fourcc.org/
  105926. */
  105927. isFourCC: boolean;
  105928. /**
  105929. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105930. */
  105931. isRGB: boolean;
  105932. /**
  105933. * If the texture is a lumincance format
  105934. */
  105935. isLuminance: boolean;
  105936. /**
  105937. * If this is a cube texture
  105938. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105939. */
  105940. isCube: boolean;
  105941. /**
  105942. * If the texture is a compressed format eg. FOURCC_DXT1
  105943. */
  105944. isCompressed: boolean;
  105945. /**
  105946. * The dxgiFormat of the texture
  105947. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105948. */
  105949. dxgiFormat: number;
  105950. /**
  105951. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105952. */
  105953. textureType: number;
  105954. /**
  105955. * Sphericle polynomial created for the dds texture
  105956. */
  105957. sphericalPolynomial?: SphericalPolynomial;
  105958. }
  105959. /**
  105960. * Class used to provide DDS decompression tools
  105961. */
  105962. export class DDSTools {
  105963. /**
  105964. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105965. */
  105966. static StoreLODInAlphaChannel: boolean;
  105967. /**
  105968. * Gets DDS information from an array buffer
  105969. * @param arrayBuffer defines the array buffer to read data from
  105970. * @returns the DDS information
  105971. */
  105972. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105973. private static _FloatView;
  105974. private static _Int32View;
  105975. private static _ToHalfFloat;
  105976. private static _FromHalfFloat;
  105977. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105978. private static _GetHalfFloatRGBAArrayBuffer;
  105979. private static _GetFloatRGBAArrayBuffer;
  105980. private static _GetFloatAsUIntRGBAArrayBuffer;
  105981. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105982. private static _GetRGBAArrayBuffer;
  105983. private static _ExtractLongWordOrder;
  105984. private static _GetRGBArrayBuffer;
  105985. private static _GetLuminanceArrayBuffer;
  105986. /**
  105987. * Uploads DDS Levels to a Babylon Texture
  105988. * @hidden
  105989. */
  105990. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105991. }
  105992. interface Engine {
  105993. /**
  105994. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105995. * @param rootUrl defines the url where the file to load is located
  105996. * @param scene defines the current scene
  105997. * @param lodScale defines scale to apply to the mip map selection
  105998. * @param lodOffset defines offset to apply to the mip map selection
  105999. * @param onLoad defines an optional callback raised when the texture is loaded
  106000. * @param onError defines an optional callback raised if there is an issue to load the texture
  106001. * @param format defines the format of the data
  106002. * @param forcedExtension defines the extension to use to pick the right loader
  106003. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  106004. * @returns the cube texture as an InternalTexture
  106005. */
  106006. 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;
  106007. }
  106008. }
  106009. declare module BABYLON {
  106010. /**
  106011. * Implementation of the DDS Texture Loader.
  106012. * @hidden
  106013. */
  106014. export class _DDSTextureLoader implements IInternalTextureLoader {
  106015. /**
  106016. * Defines wether the loader supports cascade loading the different faces.
  106017. */
  106018. readonly supportCascades: boolean;
  106019. /**
  106020. * This returns if the loader support the current file information.
  106021. * @param extension defines the file extension of the file being loaded
  106022. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106023. * @param fallback defines the fallback internal texture if any
  106024. * @param isBase64 defines whether the texture is encoded as a base64
  106025. * @param isBuffer defines whether the texture data are stored as a buffer
  106026. * @returns true if the loader can load the specified file
  106027. */
  106028. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106029. /**
  106030. * Transform the url before loading if required.
  106031. * @param rootUrl the url of the texture
  106032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106033. * @returns the transformed texture
  106034. */
  106035. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106036. /**
  106037. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106038. * @param rootUrl the url of the texture
  106039. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106040. * @returns the fallback texture
  106041. */
  106042. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106043. /**
  106044. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106045. * @param data contains the texture data
  106046. * @param texture defines the BabylonJS internal texture
  106047. * @param createPolynomials will be true if polynomials have been requested
  106048. * @param onLoad defines the callback to trigger once the texture is ready
  106049. * @param onError defines the callback to trigger in case of error
  106050. */
  106051. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106052. /**
  106053. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106054. * @param data contains the texture data
  106055. * @param texture defines the BabylonJS internal texture
  106056. * @param callback defines the method to call once ready to upload
  106057. */
  106058. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106059. }
  106060. }
  106061. declare module BABYLON {
  106062. /** @hidden */
  106063. export var rgbdEncodePixelShader: {
  106064. name: string;
  106065. shader: string;
  106066. };
  106067. }
  106068. declare module BABYLON {
  106069. /**
  106070. * Raw texture data and descriptor sufficient for WebGL texture upload
  106071. */
  106072. export interface EnvironmentTextureInfo {
  106073. /**
  106074. * Version of the environment map
  106075. */
  106076. version: number;
  106077. /**
  106078. * Width of image
  106079. */
  106080. width: number;
  106081. /**
  106082. * Irradiance information stored in the file.
  106083. */
  106084. irradiance: any;
  106085. /**
  106086. * Specular information stored in the file.
  106087. */
  106088. specular: any;
  106089. }
  106090. /**
  106091. * Sets of helpers addressing the serialization and deserialization of environment texture
  106092. * stored in a BabylonJS env file.
  106093. * Those files are usually stored as .env files.
  106094. */
  106095. export class EnvironmentTextureTools {
  106096. /**
  106097. * Magic number identifying the env file.
  106098. */
  106099. private static _MagicBytes;
  106100. /**
  106101. * Gets the environment info from an env file.
  106102. * @param data The array buffer containing the .env bytes.
  106103. * @returns the environment file info (the json header) if successfully parsed.
  106104. */
  106105. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  106106. /**
  106107. * Creates an environment texture from a loaded cube texture.
  106108. * @param texture defines the cube texture to convert in env file
  106109. * @return a promise containing the environment data if succesfull.
  106110. */
  106111. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  106112. /**
  106113. * Creates a JSON representation of the spherical data.
  106114. * @param texture defines the texture containing the polynomials
  106115. * @return the JSON representation of the spherical info
  106116. */
  106117. private static _CreateEnvTextureIrradiance;
  106118. /**
  106119. * Uploads the texture info contained in the env file to the GPU.
  106120. * @param texture defines the internal texture to upload to
  106121. * @param arrayBuffer defines the buffer cotaining the data to load
  106122. * @param info defines the texture info retrieved through the GetEnvInfo method
  106123. * @returns a promise
  106124. */
  106125. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  106126. /**
  106127. * Uploads the levels of image data to the GPU.
  106128. * @param texture defines the internal texture to upload to
  106129. * @param imageData defines the array buffer views of image data [mipmap][face]
  106130. * @returns a promise
  106131. */
  106132. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  106133. /**
  106134. * Uploads spherical polynomials information to the texture.
  106135. * @param texture defines the texture we are trying to upload the information to
  106136. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  106137. */
  106138. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  106139. /** @hidden */
  106140. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106141. }
  106142. }
  106143. declare module BABYLON {
  106144. /**
  106145. * Implementation of the ENV Texture Loader.
  106146. * @hidden
  106147. */
  106148. export class _ENVTextureLoader implements IInternalTextureLoader {
  106149. /**
  106150. * Defines wether the loader supports cascade loading the different faces.
  106151. */
  106152. readonly supportCascades: boolean;
  106153. /**
  106154. * This returns if the loader support the current file information.
  106155. * @param extension defines the file extension of the file being loaded
  106156. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106157. * @param fallback defines the fallback internal texture if any
  106158. * @param isBase64 defines whether the texture is encoded as a base64
  106159. * @param isBuffer defines whether the texture data are stored as a buffer
  106160. * @returns true if the loader can load the specified file
  106161. */
  106162. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106163. /**
  106164. * Transform the url before loading if required.
  106165. * @param rootUrl the url of the texture
  106166. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106167. * @returns the transformed texture
  106168. */
  106169. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106170. /**
  106171. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106172. * @param rootUrl the url of the texture
  106173. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106174. * @returns the fallback texture
  106175. */
  106176. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106177. /**
  106178. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106179. * @param data contains the texture data
  106180. * @param texture defines the BabylonJS internal texture
  106181. * @param createPolynomials will be true if polynomials have been requested
  106182. * @param onLoad defines the callback to trigger once the texture is ready
  106183. * @param onError defines the callback to trigger in case of error
  106184. */
  106185. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106186. /**
  106187. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106188. * @param data contains the texture data
  106189. * @param texture defines the BabylonJS internal texture
  106190. * @param callback defines the method to call once ready to upload
  106191. */
  106192. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106193. }
  106194. }
  106195. declare module BABYLON {
  106196. /**
  106197. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106198. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106199. */
  106200. export class KhronosTextureContainer {
  106201. /** contents of the KTX container file */
  106202. arrayBuffer: any;
  106203. private static HEADER_LEN;
  106204. private static COMPRESSED_2D;
  106205. private static COMPRESSED_3D;
  106206. private static TEX_2D;
  106207. private static TEX_3D;
  106208. /**
  106209. * Gets the openGL type
  106210. */
  106211. glType: number;
  106212. /**
  106213. * Gets the openGL type size
  106214. */
  106215. glTypeSize: number;
  106216. /**
  106217. * Gets the openGL format
  106218. */
  106219. glFormat: number;
  106220. /**
  106221. * Gets the openGL internal format
  106222. */
  106223. glInternalFormat: number;
  106224. /**
  106225. * Gets the base internal format
  106226. */
  106227. glBaseInternalFormat: number;
  106228. /**
  106229. * Gets image width in pixel
  106230. */
  106231. pixelWidth: number;
  106232. /**
  106233. * Gets image height in pixel
  106234. */
  106235. pixelHeight: number;
  106236. /**
  106237. * Gets image depth in pixels
  106238. */
  106239. pixelDepth: number;
  106240. /**
  106241. * Gets the number of array elements
  106242. */
  106243. numberOfArrayElements: number;
  106244. /**
  106245. * Gets the number of faces
  106246. */
  106247. numberOfFaces: number;
  106248. /**
  106249. * Gets the number of mipmap levels
  106250. */
  106251. numberOfMipmapLevels: number;
  106252. /**
  106253. * Gets the bytes of key value data
  106254. */
  106255. bytesOfKeyValueData: number;
  106256. /**
  106257. * Gets the load type
  106258. */
  106259. loadType: number;
  106260. /**
  106261. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  106262. */
  106263. isInvalid: boolean;
  106264. /**
  106265. * Creates a new KhronosTextureContainer
  106266. * @param arrayBuffer contents of the KTX container file
  106267. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  106268. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  106269. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  106270. */
  106271. constructor(
  106272. /** contents of the KTX container file */
  106273. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  106274. /**
  106275. * Uploads KTX content to a Babylon Texture.
  106276. * It is assumed that the texture has already been created & is currently bound
  106277. * @hidden
  106278. */
  106279. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  106280. private _upload2DCompressedLevels;
  106281. }
  106282. }
  106283. declare module BABYLON {
  106284. /**
  106285. * Implementation of the KTX Texture Loader.
  106286. * @hidden
  106287. */
  106288. export class _KTXTextureLoader implements IInternalTextureLoader {
  106289. /**
  106290. * Defines wether the loader supports cascade loading the different faces.
  106291. */
  106292. readonly supportCascades: boolean;
  106293. /**
  106294. * This returns if the loader support the current file information.
  106295. * @param extension defines the file extension of the file being loaded
  106296. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106297. * @param fallback defines the fallback internal texture if any
  106298. * @param isBase64 defines whether the texture is encoded as a base64
  106299. * @param isBuffer defines whether the texture data are stored as a buffer
  106300. * @returns true if the loader can load the specified file
  106301. */
  106302. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106303. /**
  106304. * Transform the url before loading if required.
  106305. * @param rootUrl the url of the texture
  106306. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106307. * @returns the transformed texture
  106308. */
  106309. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106310. /**
  106311. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106312. * @param rootUrl the url of the texture
  106313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106314. * @returns the fallback texture
  106315. */
  106316. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106317. /**
  106318. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106319. * @param data contains the texture data
  106320. * @param texture defines the BabylonJS internal texture
  106321. * @param createPolynomials will be true if polynomials have been requested
  106322. * @param onLoad defines the callback to trigger once the texture is ready
  106323. * @param onError defines the callback to trigger in case of error
  106324. */
  106325. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106326. /**
  106327. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106328. * @param data contains the texture data
  106329. * @param texture defines the BabylonJS internal texture
  106330. * @param callback defines the method to call once ready to upload
  106331. */
  106332. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  106333. }
  106334. }
  106335. declare module BABYLON {
  106336. /** @hidden */
  106337. export var _forceSceneHelpersToBundle: boolean;
  106338. interface Scene {
  106339. /**
  106340. * Creates a default light for the scene.
  106341. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  106342. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  106343. */
  106344. createDefaultLight(replace?: boolean): void;
  106345. /**
  106346. * Creates a default camera for the scene.
  106347. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  106348. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106349. * @param replace has default false, when true replaces the active camera in the scene
  106350. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  106351. */
  106352. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106353. /**
  106354. * Creates a default camera and a default light.
  106355. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  106356. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106357. * @param replace has the default false, when true replaces the active camera/light in the scene
  106358. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  106359. */
  106360. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106361. /**
  106362. * Creates a new sky box
  106363. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  106364. * @param environmentTexture defines the texture to use as environment texture
  106365. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  106366. * @param scale defines the overall scale of the skybox
  106367. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  106368. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  106369. * @returns a new mesh holding the sky box
  106370. */
  106371. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  106372. /**
  106373. * Creates a new environment
  106374. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  106375. * @param options defines the options you can use to configure the environment
  106376. * @returns the new EnvironmentHelper
  106377. */
  106378. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  106379. /**
  106380. * Creates a new VREXperienceHelper
  106381. * @see http://doc.babylonjs.com/how_to/webvr_helper
  106382. * @param webVROptions defines the options used to create the new VREXperienceHelper
  106383. * @returns a new VREXperienceHelper
  106384. */
  106385. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  106386. /**
  106387. * Creates a new XREXperienceHelper
  106388. * @see http://doc.babylonjs.com/how_to/webxr
  106389. * @returns a promise for a new XREXperienceHelper
  106390. */
  106391. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106392. }
  106393. }
  106394. declare module BABYLON {
  106395. /**
  106396. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106397. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106398. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106399. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106400. */
  106401. export class VideoDome extends TransformNode {
  106402. /**
  106403. * Define the video source as a Monoscopic panoramic 360 video.
  106404. */
  106405. static readonly MODE_MONOSCOPIC: number;
  106406. /**
  106407. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106408. */
  106409. static readonly MODE_TOPBOTTOM: number;
  106410. /**
  106411. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106412. */
  106413. static readonly MODE_SIDEBYSIDE: number;
  106414. private _useDirectMapping;
  106415. /**
  106416. * The video texture being displayed on the sphere
  106417. */
  106418. protected _videoTexture: VideoTexture;
  106419. /**
  106420. * Gets the video texture being displayed on the sphere
  106421. */
  106422. readonly videoTexture: VideoTexture;
  106423. /**
  106424. * The skybox material
  106425. */
  106426. protected _material: BackgroundMaterial;
  106427. /**
  106428. * The surface used for the skybox
  106429. */
  106430. protected _mesh: Mesh;
  106431. /**
  106432. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106433. * Also see the options.resolution property.
  106434. */
  106435. fovMultiplier: number;
  106436. private _videoMode;
  106437. /**
  106438. * Gets or set the current video mode for the video. It can be:
  106439. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106440. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106441. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106442. */
  106443. videoMode: number;
  106444. /**
  106445. * Oberserver used in Stereoscopic VR Mode.
  106446. */
  106447. private _onBeforeCameraRenderObserver;
  106448. /**
  106449. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106450. * @param name Element's name, child elements will append suffixes for their own names.
  106451. * @param urlsOrVideo defines the url(s) or the video element to use
  106452. * @param options An object containing optional or exposed sub element properties
  106453. */
  106454. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106455. resolution?: number;
  106456. clickToPlay?: boolean;
  106457. autoPlay?: boolean;
  106458. loop?: boolean;
  106459. size?: number;
  106460. poster?: string;
  106461. faceForward?: boolean;
  106462. useDirectMapping?: boolean;
  106463. }, scene: Scene);
  106464. private _changeVideoMode;
  106465. /**
  106466. * Releases resources associated with this node.
  106467. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106468. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106469. */
  106470. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106471. }
  106472. }
  106473. declare module BABYLON {
  106474. /**
  106475. * This class can be used to get instrumentation data from a Babylon engine
  106476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106477. */
  106478. export class EngineInstrumentation implements IDisposable {
  106479. /**
  106480. * Define the instrumented engine.
  106481. */
  106482. engine: Engine;
  106483. private _captureGPUFrameTime;
  106484. private _gpuFrameTimeToken;
  106485. private _gpuFrameTime;
  106486. private _captureShaderCompilationTime;
  106487. private _shaderCompilationTime;
  106488. private _onBeginFrameObserver;
  106489. private _onEndFrameObserver;
  106490. private _onBeforeShaderCompilationObserver;
  106491. private _onAfterShaderCompilationObserver;
  106492. /**
  106493. * Gets the perf counter used for GPU frame time
  106494. */
  106495. readonly gpuFrameTimeCounter: PerfCounter;
  106496. /**
  106497. * Gets the GPU frame time capture status
  106498. */
  106499. /**
  106500. * Enable or disable the GPU frame time capture
  106501. */
  106502. captureGPUFrameTime: boolean;
  106503. /**
  106504. * Gets the perf counter used for shader compilation time
  106505. */
  106506. readonly shaderCompilationTimeCounter: PerfCounter;
  106507. /**
  106508. * Gets the shader compilation time capture status
  106509. */
  106510. /**
  106511. * Enable or disable the shader compilation time capture
  106512. */
  106513. captureShaderCompilationTime: boolean;
  106514. /**
  106515. * Instantiates a new engine instrumentation.
  106516. * This class can be used to get instrumentation data from a Babylon engine
  106517. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106518. * @param engine Defines the engine to instrument
  106519. */
  106520. constructor(
  106521. /**
  106522. * Define the instrumented engine.
  106523. */
  106524. engine: Engine);
  106525. /**
  106526. * Dispose and release associated resources.
  106527. */
  106528. dispose(): void;
  106529. }
  106530. }
  106531. declare module BABYLON {
  106532. /**
  106533. * This class can be used to get instrumentation data from a Babylon engine
  106534. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106535. */
  106536. export class SceneInstrumentation implements IDisposable {
  106537. /**
  106538. * Defines the scene to instrument
  106539. */
  106540. scene: Scene;
  106541. private _captureActiveMeshesEvaluationTime;
  106542. private _activeMeshesEvaluationTime;
  106543. private _captureRenderTargetsRenderTime;
  106544. private _renderTargetsRenderTime;
  106545. private _captureFrameTime;
  106546. private _frameTime;
  106547. private _captureRenderTime;
  106548. private _renderTime;
  106549. private _captureInterFrameTime;
  106550. private _interFrameTime;
  106551. private _captureParticlesRenderTime;
  106552. private _particlesRenderTime;
  106553. private _captureSpritesRenderTime;
  106554. private _spritesRenderTime;
  106555. private _capturePhysicsTime;
  106556. private _physicsTime;
  106557. private _captureAnimationsTime;
  106558. private _animationsTime;
  106559. private _captureCameraRenderTime;
  106560. private _cameraRenderTime;
  106561. private _onBeforeActiveMeshesEvaluationObserver;
  106562. private _onAfterActiveMeshesEvaluationObserver;
  106563. private _onBeforeRenderTargetsRenderObserver;
  106564. private _onAfterRenderTargetsRenderObserver;
  106565. private _onAfterRenderObserver;
  106566. private _onBeforeDrawPhaseObserver;
  106567. private _onAfterDrawPhaseObserver;
  106568. private _onBeforeAnimationsObserver;
  106569. private _onBeforeParticlesRenderingObserver;
  106570. private _onAfterParticlesRenderingObserver;
  106571. private _onBeforeSpritesRenderingObserver;
  106572. private _onAfterSpritesRenderingObserver;
  106573. private _onBeforePhysicsObserver;
  106574. private _onAfterPhysicsObserver;
  106575. private _onAfterAnimationsObserver;
  106576. private _onBeforeCameraRenderObserver;
  106577. private _onAfterCameraRenderObserver;
  106578. /**
  106579. * Gets the perf counter used for active meshes evaluation time
  106580. */
  106581. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106582. /**
  106583. * Gets the active meshes evaluation time capture status
  106584. */
  106585. /**
  106586. * Enable or disable the active meshes evaluation time capture
  106587. */
  106588. captureActiveMeshesEvaluationTime: boolean;
  106589. /**
  106590. * Gets the perf counter used for render targets render time
  106591. */
  106592. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106593. /**
  106594. * Gets the render targets render time capture status
  106595. */
  106596. /**
  106597. * Enable or disable the render targets render time capture
  106598. */
  106599. captureRenderTargetsRenderTime: boolean;
  106600. /**
  106601. * Gets the perf counter used for particles render time
  106602. */
  106603. readonly particlesRenderTimeCounter: PerfCounter;
  106604. /**
  106605. * Gets the particles render time capture status
  106606. */
  106607. /**
  106608. * Enable or disable the particles render time capture
  106609. */
  106610. captureParticlesRenderTime: boolean;
  106611. /**
  106612. * Gets the perf counter used for sprites render time
  106613. */
  106614. readonly spritesRenderTimeCounter: PerfCounter;
  106615. /**
  106616. * Gets the sprites render time capture status
  106617. */
  106618. /**
  106619. * Enable or disable the sprites render time capture
  106620. */
  106621. captureSpritesRenderTime: boolean;
  106622. /**
  106623. * Gets the perf counter used for physics time
  106624. */
  106625. readonly physicsTimeCounter: PerfCounter;
  106626. /**
  106627. * Gets the physics time capture status
  106628. */
  106629. /**
  106630. * Enable or disable the physics time capture
  106631. */
  106632. capturePhysicsTime: boolean;
  106633. /**
  106634. * Gets the perf counter used for animations time
  106635. */
  106636. readonly animationsTimeCounter: PerfCounter;
  106637. /**
  106638. * Gets the animations time capture status
  106639. */
  106640. /**
  106641. * Enable or disable the animations time capture
  106642. */
  106643. captureAnimationsTime: boolean;
  106644. /**
  106645. * Gets the perf counter used for frame time capture
  106646. */
  106647. readonly frameTimeCounter: PerfCounter;
  106648. /**
  106649. * Gets the frame time capture status
  106650. */
  106651. /**
  106652. * Enable or disable the frame time capture
  106653. */
  106654. captureFrameTime: boolean;
  106655. /**
  106656. * Gets the perf counter used for inter-frames time capture
  106657. */
  106658. readonly interFrameTimeCounter: PerfCounter;
  106659. /**
  106660. * Gets the inter-frames time capture status
  106661. */
  106662. /**
  106663. * Enable or disable the inter-frames time capture
  106664. */
  106665. captureInterFrameTime: boolean;
  106666. /**
  106667. * Gets the perf counter used for render time capture
  106668. */
  106669. readonly renderTimeCounter: PerfCounter;
  106670. /**
  106671. * Gets the render time capture status
  106672. */
  106673. /**
  106674. * Enable or disable the render time capture
  106675. */
  106676. captureRenderTime: boolean;
  106677. /**
  106678. * Gets the perf counter used for camera render time capture
  106679. */
  106680. readonly cameraRenderTimeCounter: PerfCounter;
  106681. /**
  106682. * Gets the camera render time capture status
  106683. */
  106684. /**
  106685. * Enable or disable the camera render time capture
  106686. */
  106687. captureCameraRenderTime: boolean;
  106688. /**
  106689. * Gets the perf counter used for draw calls
  106690. */
  106691. readonly drawCallsCounter: PerfCounter;
  106692. /**
  106693. * Instantiates a new scene instrumentation.
  106694. * This class can be used to get instrumentation data from a Babylon engine
  106695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106696. * @param scene Defines the scene to instrument
  106697. */
  106698. constructor(
  106699. /**
  106700. * Defines the scene to instrument
  106701. */
  106702. scene: Scene);
  106703. /**
  106704. * Dispose and release associated resources.
  106705. */
  106706. dispose(): void;
  106707. }
  106708. }
  106709. declare module BABYLON {
  106710. /** @hidden */
  106711. export var glowMapGenerationPixelShader: {
  106712. name: string;
  106713. shader: string;
  106714. };
  106715. }
  106716. declare module BABYLON {
  106717. /** @hidden */
  106718. export var glowMapGenerationVertexShader: {
  106719. name: string;
  106720. shader: string;
  106721. };
  106722. }
  106723. declare module BABYLON {
  106724. /**
  106725. * Effect layer options. This helps customizing the behaviour
  106726. * of the effect layer.
  106727. */
  106728. export interface IEffectLayerOptions {
  106729. /**
  106730. * Multiplication factor apply to the canvas size to compute the render target size
  106731. * used to generated the objects (the smaller the faster).
  106732. */
  106733. mainTextureRatio: number;
  106734. /**
  106735. * Enforces a fixed size texture to ensure effect stability across devices.
  106736. */
  106737. mainTextureFixedSize?: number;
  106738. /**
  106739. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106740. */
  106741. alphaBlendingMode: number;
  106742. /**
  106743. * The camera attached to the layer.
  106744. */
  106745. camera: Nullable<Camera>;
  106746. /**
  106747. * The rendering group to draw the layer in.
  106748. */
  106749. renderingGroupId: number;
  106750. }
  106751. /**
  106752. * The effect layer Helps adding post process effect blended with the main pass.
  106753. *
  106754. * This can be for instance use to generate glow or higlight effects on the scene.
  106755. *
  106756. * The effect layer class can not be used directly and is intented to inherited from to be
  106757. * customized per effects.
  106758. */
  106759. export abstract class EffectLayer {
  106760. private _vertexBuffers;
  106761. private _indexBuffer;
  106762. private _cachedDefines;
  106763. private _effectLayerMapGenerationEffect;
  106764. private _effectLayerOptions;
  106765. private _mergeEffect;
  106766. protected _scene: Scene;
  106767. protected _engine: Engine;
  106768. protected _maxSize: number;
  106769. protected _mainTextureDesiredSize: ISize;
  106770. protected _mainTexture: RenderTargetTexture;
  106771. protected _shouldRender: boolean;
  106772. protected _postProcesses: PostProcess[];
  106773. protected _textures: BaseTexture[];
  106774. protected _emissiveTextureAndColor: {
  106775. texture: Nullable<BaseTexture>;
  106776. color: Color4;
  106777. };
  106778. /**
  106779. * The name of the layer
  106780. */
  106781. name: string;
  106782. /**
  106783. * The clear color of the texture used to generate the glow map.
  106784. */
  106785. neutralColor: Color4;
  106786. /**
  106787. * Specifies wether the highlight layer is enabled or not.
  106788. */
  106789. isEnabled: boolean;
  106790. /**
  106791. * Gets the camera attached to the layer.
  106792. */
  106793. readonly camera: Nullable<Camera>;
  106794. /**
  106795. * Gets the rendering group id the layer should render in.
  106796. */
  106797. readonly renderingGroupId: number;
  106798. /**
  106799. * An event triggered when the effect layer has been disposed.
  106800. */
  106801. onDisposeObservable: Observable<EffectLayer>;
  106802. /**
  106803. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106804. */
  106805. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106806. /**
  106807. * An event triggered when the generated texture is being merged in the scene.
  106808. */
  106809. onBeforeComposeObservable: Observable<EffectLayer>;
  106810. /**
  106811. * An event triggered when the generated texture has been merged in the scene.
  106812. */
  106813. onAfterComposeObservable: Observable<EffectLayer>;
  106814. /**
  106815. * An event triggered when the efffect layer changes its size.
  106816. */
  106817. onSizeChangedObservable: Observable<EffectLayer>;
  106818. /** @hidden */
  106819. static _SceneComponentInitialization: (scene: Scene) => void;
  106820. /**
  106821. * Instantiates a new effect Layer and references it in the scene.
  106822. * @param name The name of the layer
  106823. * @param scene The scene to use the layer in
  106824. */
  106825. constructor(
  106826. /** The Friendly of the effect in the scene */
  106827. name: string, scene: Scene);
  106828. /**
  106829. * Get the effect name of the layer.
  106830. * @return The effect name
  106831. */
  106832. abstract getEffectName(): string;
  106833. /**
  106834. * Checks for the readiness of the element composing the layer.
  106835. * @param subMesh the mesh to check for
  106836. * @param useInstances specify wether or not to use instances to render the mesh
  106837. * @return true if ready otherwise, false
  106838. */
  106839. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106840. /**
  106841. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106842. * @returns true if the effect requires stencil during the main canvas render pass.
  106843. */
  106844. abstract needStencil(): boolean;
  106845. /**
  106846. * Create the merge effect. This is the shader use to blit the information back
  106847. * to the main canvas at the end of the scene rendering.
  106848. * @returns The effect containing the shader used to merge the effect on the main canvas
  106849. */
  106850. protected abstract _createMergeEffect(): Effect;
  106851. /**
  106852. * Creates the render target textures and post processes used in the effect layer.
  106853. */
  106854. protected abstract _createTextureAndPostProcesses(): void;
  106855. /**
  106856. * Implementation specific of rendering the generating effect on the main canvas.
  106857. * @param effect The effect used to render through
  106858. */
  106859. protected abstract _internalRender(effect: Effect): void;
  106860. /**
  106861. * Sets the required values for both the emissive texture and and the main color.
  106862. */
  106863. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106864. /**
  106865. * Free any resources and references associated to a mesh.
  106866. * Internal use
  106867. * @param mesh The mesh to free.
  106868. */
  106869. abstract _disposeMesh(mesh: Mesh): void;
  106870. /**
  106871. * Serializes this layer (Glow or Highlight for example)
  106872. * @returns a serialized layer object
  106873. */
  106874. abstract serialize?(): any;
  106875. /**
  106876. * Initializes the effect layer with the required options.
  106877. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106878. */
  106879. protected _init(options: Partial<IEffectLayerOptions>): void;
  106880. /**
  106881. * Generates the index buffer of the full screen quad blending to the main canvas.
  106882. */
  106883. private _generateIndexBuffer;
  106884. /**
  106885. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106886. */
  106887. private _generateVertexBuffer;
  106888. /**
  106889. * Sets the main texture desired size which is the closest power of two
  106890. * of the engine canvas size.
  106891. */
  106892. private _setMainTextureSize;
  106893. /**
  106894. * Creates the main texture for the effect layer.
  106895. */
  106896. protected _createMainTexture(): void;
  106897. /**
  106898. * Adds specific effects defines.
  106899. * @param defines The defines to add specifics to.
  106900. */
  106901. protected _addCustomEffectDefines(defines: string[]): void;
  106902. /**
  106903. * Checks for the readiness of the element composing the layer.
  106904. * @param subMesh the mesh to check for
  106905. * @param useInstances specify wether or not to use instances to render the mesh
  106906. * @param emissiveTexture the associated emissive texture used to generate the glow
  106907. * @return true if ready otherwise, false
  106908. */
  106909. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106910. /**
  106911. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106912. */
  106913. render(): void;
  106914. /**
  106915. * Determine if a given mesh will be used in the current effect.
  106916. * @param mesh mesh to test
  106917. * @returns true if the mesh will be used
  106918. */
  106919. hasMesh(mesh: AbstractMesh): boolean;
  106920. /**
  106921. * Returns true if the layer contains information to display, otherwise false.
  106922. * @returns true if the glow layer should be rendered
  106923. */
  106924. shouldRender(): boolean;
  106925. /**
  106926. * Returns true if the mesh should render, otherwise false.
  106927. * @param mesh The mesh to render
  106928. * @returns true if it should render otherwise false
  106929. */
  106930. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106931. /**
  106932. * Returns true if the mesh can be rendered, otherwise false.
  106933. * @param mesh The mesh to render
  106934. * @param material The material used on the mesh
  106935. * @returns true if it can be rendered otherwise false
  106936. */
  106937. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106938. /**
  106939. * Returns true if the mesh should render, otherwise false.
  106940. * @param mesh The mesh to render
  106941. * @returns true if it should render otherwise false
  106942. */
  106943. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106944. /**
  106945. * Renders the submesh passed in parameter to the generation map.
  106946. */
  106947. protected _renderSubMesh(subMesh: SubMesh): void;
  106948. /**
  106949. * Rebuild the required buffers.
  106950. * @hidden Internal use only.
  106951. */
  106952. _rebuild(): void;
  106953. /**
  106954. * Dispose only the render target textures and post process.
  106955. */
  106956. private _disposeTextureAndPostProcesses;
  106957. /**
  106958. * Dispose the highlight layer and free resources.
  106959. */
  106960. dispose(): void;
  106961. /**
  106962. * Gets the class name of the effect layer
  106963. * @returns the string with the class name of the effect layer
  106964. */
  106965. getClassName(): string;
  106966. /**
  106967. * Creates an effect layer from parsed effect layer data
  106968. * @param parsedEffectLayer defines effect layer data
  106969. * @param scene defines the current scene
  106970. * @param rootUrl defines the root URL containing the effect layer information
  106971. * @returns a parsed effect Layer
  106972. */
  106973. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106974. }
  106975. }
  106976. declare module BABYLON {
  106977. interface AbstractScene {
  106978. /**
  106979. * The list of effect layers (highlights/glow) added to the scene
  106980. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106981. * @see http://doc.babylonjs.com/how_to/glow_layer
  106982. */
  106983. effectLayers: Array<EffectLayer>;
  106984. /**
  106985. * Removes the given effect layer from this scene.
  106986. * @param toRemove defines the effect layer to remove
  106987. * @returns the index of the removed effect layer
  106988. */
  106989. removeEffectLayer(toRemove: EffectLayer): number;
  106990. /**
  106991. * Adds the given effect layer to this scene
  106992. * @param newEffectLayer defines the effect layer to add
  106993. */
  106994. addEffectLayer(newEffectLayer: EffectLayer): void;
  106995. }
  106996. /**
  106997. * Defines the layer scene component responsible to manage any effect layers
  106998. * in a given scene.
  106999. */
  107000. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  107001. /**
  107002. * The component name helpfull to identify the component in the list of scene components.
  107003. */
  107004. readonly name: string;
  107005. /**
  107006. * The scene the component belongs to.
  107007. */
  107008. scene: Scene;
  107009. private _engine;
  107010. private _renderEffects;
  107011. private _needStencil;
  107012. private _previousStencilState;
  107013. /**
  107014. * Creates a new instance of the component for the given scene
  107015. * @param scene Defines the scene to register the component in
  107016. */
  107017. constructor(scene: Scene);
  107018. /**
  107019. * Registers the component in a given scene
  107020. */
  107021. register(): void;
  107022. /**
  107023. * Rebuilds the elements related to this component in case of
  107024. * context lost for instance.
  107025. */
  107026. rebuild(): void;
  107027. /**
  107028. * Serializes the component data to the specified json object
  107029. * @param serializationObject The object to serialize to
  107030. */
  107031. serialize(serializationObject: any): void;
  107032. /**
  107033. * Adds all the element from the container to the scene
  107034. * @param container the container holding the elements
  107035. */
  107036. addFromContainer(container: AbstractScene): void;
  107037. /**
  107038. * Removes all the elements in the container from the scene
  107039. * @param container contains the elements to remove
  107040. * @param dispose if the removed element should be disposed (default: false)
  107041. */
  107042. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107043. /**
  107044. * Disposes the component and the associated ressources.
  107045. */
  107046. dispose(): void;
  107047. private _isReadyForMesh;
  107048. private _renderMainTexture;
  107049. private _setStencil;
  107050. private _setStencilBack;
  107051. private _draw;
  107052. private _drawCamera;
  107053. private _drawRenderingGroup;
  107054. }
  107055. }
  107056. declare module BABYLON {
  107057. /** @hidden */
  107058. export var glowMapMergePixelShader: {
  107059. name: string;
  107060. shader: string;
  107061. };
  107062. }
  107063. declare module BABYLON {
  107064. /** @hidden */
  107065. export var glowMapMergeVertexShader: {
  107066. name: string;
  107067. shader: string;
  107068. };
  107069. }
  107070. declare module BABYLON {
  107071. interface AbstractScene {
  107072. /**
  107073. * Return a the first highlight layer of the scene with a given name.
  107074. * @param name The name of the highlight layer to look for.
  107075. * @return The highlight layer if found otherwise null.
  107076. */
  107077. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  107078. }
  107079. /**
  107080. * Glow layer options. This helps customizing the behaviour
  107081. * of the glow layer.
  107082. */
  107083. export interface IGlowLayerOptions {
  107084. /**
  107085. * Multiplication factor apply to the canvas size to compute the render target size
  107086. * used to generated the glowing objects (the smaller the faster).
  107087. */
  107088. mainTextureRatio: number;
  107089. /**
  107090. * Enforces a fixed size texture to ensure resize independant blur.
  107091. */
  107092. mainTextureFixedSize?: number;
  107093. /**
  107094. * How big is the kernel of the blur texture.
  107095. */
  107096. blurKernelSize: number;
  107097. /**
  107098. * The camera attached to the layer.
  107099. */
  107100. camera: Nullable<Camera>;
  107101. /**
  107102. * Enable MSAA by chosing the number of samples.
  107103. */
  107104. mainTextureSamples?: number;
  107105. /**
  107106. * The rendering group to draw the layer in.
  107107. */
  107108. renderingGroupId: number;
  107109. }
  107110. /**
  107111. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  107112. *
  107113. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107114. * glowy meshes to your scene.
  107115. *
  107116. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  107117. */
  107118. export class GlowLayer extends EffectLayer {
  107119. /**
  107120. * Effect Name of the layer.
  107121. */
  107122. static readonly EffectName: string;
  107123. /**
  107124. * The default blur kernel size used for the glow.
  107125. */
  107126. static DefaultBlurKernelSize: number;
  107127. /**
  107128. * The default texture size ratio used for the glow.
  107129. */
  107130. static DefaultTextureRatio: number;
  107131. /**
  107132. * Sets the kernel size of the blur.
  107133. */
  107134. /**
  107135. * Gets the kernel size of the blur.
  107136. */
  107137. blurKernelSize: number;
  107138. /**
  107139. * Sets the glow intensity.
  107140. */
  107141. /**
  107142. * Gets the glow intensity.
  107143. */
  107144. intensity: number;
  107145. private _options;
  107146. private _intensity;
  107147. private _horizontalBlurPostprocess1;
  107148. private _verticalBlurPostprocess1;
  107149. private _horizontalBlurPostprocess2;
  107150. private _verticalBlurPostprocess2;
  107151. private _blurTexture1;
  107152. private _blurTexture2;
  107153. private _postProcesses1;
  107154. private _postProcesses2;
  107155. private _includedOnlyMeshes;
  107156. private _excludedMeshes;
  107157. /**
  107158. * Callback used to let the user override the color selection on a per mesh basis
  107159. */
  107160. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  107161. /**
  107162. * Callback used to let the user override the texture selection on a per mesh basis
  107163. */
  107164. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  107165. /**
  107166. * Instantiates a new glow Layer and references it to the scene.
  107167. * @param name The name of the layer
  107168. * @param scene The scene to use the layer in
  107169. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  107170. */
  107171. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  107172. /**
  107173. * Get the effect name of the layer.
  107174. * @return The effect name
  107175. */
  107176. getEffectName(): string;
  107177. /**
  107178. * Create the merge effect. This is the shader use to blit the information back
  107179. * to the main canvas at the end of the scene rendering.
  107180. */
  107181. protected _createMergeEffect(): Effect;
  107182. /**
  107183. * Creates the render target textures and post processes used in the glow layer.
  107184. */
  107185. protected _createTextureAndPostProcesses(): void;
  107186. /**
  107187. * Checks for the readiness of the element composing the layer.
  107188. * @param subMesh the mesh to check for
  107189. * @param useInstances specify wether or not to use instances to render the mesh
  107190. * @param emissiveTexture the associated emissive texture used to generate the glow
  107191. * @return true if ready otherwise, false
  107192. */
  107193. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107194. /**
  107195. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107196. */
  107197. needStencil(): boolean;
  107198. /**
  107199. * Returns true if the mesh can be rendered, otherwise false.
  107200. * @param mesh The mesh to render
  107201. * @param material The material used on the mesh
  107202. * @returns true if it can be rendered otherwise false
  107203. */
  107204. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107205. /**
  107206. * Implementation specific of rendering the generating effect on the main canvas.
  107207. * @param effect The effect used to render through
  107208. */
  107209. protected _internalRender(effect: Effect): void;
  107210. /**
  107211. * Sets the required values for both the emissive texture and and the main color.
  107212. */
  107213. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107214. /**
  107215. * Returns true if the mesh should render, otherwise false.
  107216. * @param mesh The mesh to render
  107217. * @returns true if it should render otherwise false
  107218. */
  107219. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107220. /**
  107221. * Adds specific effects defines.
  107222. * @param defines The defines to add specifics to.
  107223. */
  107224. protected _addCustomEffectDefines(defines: string[]): void;
  107225. /**
  107226. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  107227. * @param mesh The mesh to exclude from the glow layer
  107228. */
  107229. addExcludedMesh(mesh: Mesh): void;
  107230. /**
  107231. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  107232. * @param mesh The mesh to remove
  107233. */
  107234. removeExcludedMesh(mesh: Mesh): void;
  107235. /**
  107236. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  107237. * @param mesh The mesh to include in the glow layer
  107238. */
  107239. addIncludedOnlyMesh(mesh: Mesh): void;
  107240. /**
  107241. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  107242. * @param mesh The mesh to remove
  107243. */
  107244. removeIncludedOnlyMesh(mesh: Mesh): void;
  107245. /**
  107246. * Determine if a given mesh will be used in the glow layer
  107247. * @param mesh The mesh to test
  107248. * @returns true if the mesh will be highlighted by the current glow layer
  107249. */
  107250. hasMesh(mesh: AbstractMesh): boolean;
  107251. /**
  107252. * Free any resources and references associated to a mesh.
  107253. * Internal use
  107254. * @param mesh The mesh to free.
  107255. * @hidden
  107256. */
  107257. _disposeMesh(mesh: Mesh): void;
  107258. /**
  107259. * Gets the class name of the effect layer
  107260. * @returns the string with the class name of the effect layer
  107261. */
  107262. getClassName(): string;
  107263. /**
  107264. * Serializes this glow layer
  107265. * @returns a serialized glow layer object
  107266. */
  107267. serialize(): any;
  107268. /**
  107269. * Creates a Glow Layer from parsed glow layer data
  107270. * @param parsedGlowLayer defines glow layer data
  107271. * @param scene defines the current scene
  107272. * @param rootUrl defines the root URL containing the glow layer information
  107273. * @returns a parsed Glow Layer
  107274. */
  107275. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  107276. }
  107277. }
  107278. declare module BABYLON {
  107279. /** @hidden */
  107280. export var glowBlurPostProcessPixelShader: {
  107281. name: string;
  107282. shader: string;
  107283. };
  107284. }
  107285. declare module BABYLON {
  107286. interface AbstractScene {
  107287. /**
  107288. * Return a the first highlight layer of the scene with a given name.
  107289. * @param name The name of the highlight layer to look for.
  107290. * @return The highlight layer if found otherwise null.
  107291. */
  107292. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  107293. }
  107294. /**
  107295. * Highlight layer options. This helps customizing the behaviour
  107296. * of the highlight layer.
  107297. */
  107298. export interface IHighlightLayerOptions {
  107299. /**
  107300. * Multiplication factor apply to the canvas size to compute the render target size
  107301. * used to generated the glowing objects (the smaller the faster).
  107302. */
  107303. mainTextureRatio: number;
  107304. /**
  107305. * Enforces a fixed size texture to ensure resize independant blur.
  107306. */
  107307. mainTextureFixedSize?: number;
  107308. /**
  107309. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  107310. * of the picture to blur (the smaller the faster).
  107311. */
  107312. blurTextureSizeRatio: number;
  107313. /**
  107314. * How big in texel of the blur texture is the vertical blur.
  107315. */
  107316. blurVerticalSize: number;
  107317. /**
  107318. * How big in texel of the blur texture is the horizontal blur.
  107319. */
  107320. blurHorizontalSize: number;
  107321. /**
  107322. * Alpha blending mode used to apply the blur. Default is combine.
  107323. */
  107324. alphaBlendingMode: number;
  107325. /**
  107326. * The camera attached to the layer.
  107327. */
  107328. camera: Nullable<Camera>;
  107329. /**
  107330. * Should we display highlight as a solid stroke?
  107331. */
  107332. isStroke?: boolean;
  107333. /**
  107334. * The rendering group to draw the layer in.
  107335. */
  107336. renderingGroupId: number;
  107337. }
  107338. /**
  107339. * The highlight layer Helps adding a glow effect around a mesh.
  107340. *
  107341. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107342. * glowy meshes to your scene.
  107343. *
  107344. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  107345. */
  107346. export class HighlightLayer extends EffectLayer {
  107347. name: string;
  107348. /**
  107349. * Effect Name of the highlight layer.
  107350. */
  107351. static readonly EffectName: string;
  107352. /**
  107353. * The neutral color used during the preparation of the glow effect.
  107354. * This is black by default as the blend operation is a blend operation.
  107355. */
  107356. static NeutralColor: Color4;
  107357. /**
  107358. * Stencil value used for glowing meshes.
  107359. */
  107360. static GlowingMeshStencilReference: number;
  107361. /**
  107362. * Stencil value used for the other meshes in the scene.
  107363. */
  107364. static NormalMeshStencilReference: number;
  107365. /**
  107366. * Specifies whether or not the inner glow is ACTIVE in the layer.
  107367. */
  107368. innerGlow: boolean;
  107369. /**
  107370. * Specifies whether or not the outer glow is ACTIVE in the layer.
  107371. */
  107372. outerGlow: boolean;
  107373. /**
  107374. * Specifies the horizontal size of the blur.
  107375. */
  107376. /**
  107377. * Gets the horizontal size of the blur.
  107378. */
  107379. blurHorizontalSize: number;
  107380. /**
  107381. * Specifies the vertical size of the blur.
  107382. */
  107383. /**
  107384. * Gets the vertical size of the blur.
  107385. */
  107386. blurVerticalSize: number;
  107387. /**
  107388. * An event triggered when the highlight layer is being blurred.
  107389. */
  107390. onBeforeBlurObservable: Observable<HighlightLayer>;
  107391. /**
  107392. * An event triggered when the highlight layer has been blurred.
  107393. */
  107394. onAfterBlurObservable: Observable<HighlightLayer>;
  107395. private _instanceGlowingMeshStencilReference;
  107396. private _options;
  107397. private _downSamplePostprocess;
  107398. private _horizontalBlurPostprocess;
  107399. private _verticalBlurPostprocess;
  107400. private _blurTexture;
  107401. private _meshes;
  107402. private _excludedMeshes;
  107403. /**
  107404. * Instantiates a new highlight Layer and references it to the scene..
  107405. * @param name The name of the layer
  107406. * @param scene The scene to use the layer in
  107407. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107408. */
  107409. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107410. /**
  107411. * Get the effect name of the layer.
  107412. * @return The effect name
  107413. */
  107414. getEffectName(): string;
  107415. /**
  107416. * Create the merge effect. This is the shader use to blit the information back
  107417. * to the main canvas at the end of the scene rendering.
  107418. */
  107419. protected _createMergeEffect(): Effect;
  107420. /**
  107421. * Creates the render target textures and post processes used in the highlight layer.
  107422. */
  107423. protected _createTextureAndPostProcesses(): void;
  107424. /**
  107425. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107426. */
  107427. needStencil(): boolean;
  107428. /**
  107429. * Checks for the readiness of the element composing the layer.
  107430. * @param subMesh the mesh to check for
  107431. * @param useInstances specify wether or not to use instances to render the mesh
  107432. * @param emissiveTexture the associated emissive texture used to generate the glow
  107433. * @return true if ready otherwise, false
  107434. */
  107435. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107436. /**
  107437. * Implementation specific of rendering the generating effect on the main canvas.
  107438. * @param effect The effect used to render through
  107439. */
  107440. protected _internalRender(effect: Effect): void;
  107441. /**
  107442. * Returns true if the layer contains information to display, otherwise false.
  107443. */
  107444. shouldRender(): boolean;
  107445. /**
  107446. * Returns true if the mesh should render, otherwise false.
  107447. * @param mesh The mesh to render
  107448. * @returns true if it should render otherwise false
  107449. */
  107450. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107451. /**
  107452. * Sets the required values for both the emissive texture and and the main color.
  107453. */
  107454. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107455. /**
  107456. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107457. * @param mesh The mesh to exclude from the highlight layer
  107458. */
  107459. addExcludedMesh(mesh: Mesh): void;
  107460. /**
  107461. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107462. * @param mesh The mesh to highlight
  107463. */
  107464. removeExcludedMesh(mesh: Mesh): void;
  107465. /**
  107466. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107467. * @param mesh mesh to test
  107468. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107469. */
  107470. hasMesh(mesh: AbstractMesh): boolean;
  107471. /**
  107472. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107473. * @param mesh The mesh to highlight
  107474. * @param color The color of the highlight
  107475. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107476. */
  107477. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107478. /**
  107479. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107480. * @param mesh The mesh to highlight
  107481. */
  107482. removeMesh(mesh: Mesh): void;
  107483. /**
  107484. * Force the stencil to the normal expected value for none glowing parts
  107485. */
  107486. private _defaultStencilReference;
  107487. /**
  107488. * Free any resources and references associated to a mesh.
  107489. * Internal use
  107490. * @param mesh The mesh to free.
  107491. * @hidden
  107492. */
  107493. _disposeMesh(mesh: Mesh): void;
  107494. /**
  107495. * Dispose the highlight layer and free resources.
  107496. */
  107497. dispose(): void;
  107498. /**
  107499. * Gets the class name of the effect layer
  107500. * @returns the string with the class name of the effect layer
  107501. */
  107502. getClassName(): string;
  107503. /**
  107504. * Serializes this Highlight layer
  107505. * @returns a serialized Highlight layer object
  107506. */
  107507. serialize(): any;
  107508. /**
  107509. * Creates a Highlight layer from parsed Highlight layer data
  107510. * @param parsedHightlightLayer defines the Highlight layer data
  107511. * @param scene defines the current scene
  107512. * @param rootUrl defines the root URL containing the Highlight layer information
  107513. * @returns a parsed Highlight layer
  107514. */
  107515. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107516. }
  107517. }
  107518. declare module BABYLON {
  107519. /** @hidden */
  107520. export var lensFlarePixelShader: {
  107521. name: string;
  107522. shader: string;
  107523. };
  107524. }
  107525. declare module BABYLON {
  107526. /** @hidden */
  107527. export var lensFlareVertexShader: {
  107528. name: string;
  107529. shader: string;
  107530. };
  107531. }
  107532. declare module BABYLON {
  107533. /**
  107534. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107535. * It is usually composed of several `lensFlare`.
  107536. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107537. */
  107538. export class LensFlareSystem {
  107539. /**
  107540. * Define the name of the lens flare system
  107541. */
  107542. name: string;
  107543. /**
  107544. * List of lens flares used in this system.
  107545. */
  107546. lensFlares: LensFlare[];
  107547. /**
  107548. * Define a limit from the border the lens flare can be visible.
  107549. */
  107550. borderLimit: number;
  107551. /**
  107552. * Define a viewport border we do not want to see the lens flare in.
  107553. */
  107554. viewportBorder: number;
  107555. /**
  107556. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107557. */
  107558. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107559. /**
  107560. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107561. */
  107562. layerMask: number;
  107563. /**
  107564. * Define the id of the lens flare system in the scene.
  107565. * (equal to name by default)
  107566. */
  107567. id: string;
  107568. private _scene;
  107569. private _emitter;
  107570. private _vertexBuffers;
  107571. private _indexBuffer;
  107572. private _effect;
  107573. private _positionX;
  107574. private _positionY;
  107575. private _isEnabled;
  107576. /** @hidden */
  107577. static _SceneComponentInitialization: (scene: Scene) => void;
  107578. /**
  107579. * Instantiates a lens flare system.
  107580. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107581. * It is usually composed of several `lensFlare`.
  107582. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107583. * @param name Define the name of the lens flare system in the scene
  107584. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107585. * @param scene Define the scene the lens flare system belongs to
  107586. */
  107587. constructor(
  107588. /**
  107589. * Define the name of the lens flare system
  107590. */
  107591. name: string, emitter: any, scene: Scene);
  107592. /**
  107593. * Define if the lens flare system is enabled.
  107594. */
  107595. isEnabled: boolean;
  107596. /**
  107597. * Get the scene the effects belongs to.
  107598. * @returns the scene holding the lens flare system
  107599. */
  107600. getScene(): Scene;
  107601. /**
  107602. * Get the emitter of the lens flare system.
  107603. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107604. * @returns the emitter of the lens flare system
  107605. */
  107606. getEmitter(): any;
  107607. /**
  107608. * Set the emitter of the lens flare system.
  107609. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107610. * @param newEmitter Define the new emitter of the system
  107611. */
  107612. setEmitter(newEmitter: any): void;
  107613. /**
  107614. * Get the lens flare system emitter position.
  107615. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107616. * @returns the position
  107617. */
  107618. getEmitterPosition(): Vector3;
  107619. /**
  107620. * @hidden
  107621. */
  107622. computeEffectivePosition(globalViewport: Viewport): boolean;
  107623. /** @hidden */
  107624. _isVisible(): boolean;
  107625. /**
  107626. * @hidden
  107627. */
  107628. render(): boolean;
  107629. /**
  107630. * Dispose and release the lens flare with its associated resources.
  107631. */
  107632. dispose(): void;
  107633. /**
  107634. * Parse a lens flare system from a JSON repressentation
  107635. * @param parsedLensFlareSystem Define the JSON to parse
  107636. * @param scene Define the scene the parsed system should be instantiated in
  107637. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107638. * @returns the parsed system
  107639. */
  107640. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107641. /**
  107642. * Serialize the current Lens Flare System into a JSON representation.
  107643. * @returns the serialized JSON
  107644. */
  107645. serialize(): any;
  107646. }
  107647. }
  107648. declare module BABYLON {
  107649. /**
  107650. * This represents one of the lens effect in a `lensFlareSystem`.
  107651. * It controls one of the indiviual texture used in the effect.
  107652. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107653. */
  107654. export class LensFlare {
  107655. /**
  107656. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107657. */
  107658. size: number;
  107659. /**
  107660. * 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.
  107661. */
  107662. position: number;
  107663. /**
  107664. * Define the lens color.
  107665. */
  107666. color: Color3;
  107667. /**
  107668. * Define the lens texture.
  107669. */
  107670. texture: Nullable<Texture>;
  107671. /**
  107672. * Define the alpha mode to render this particular lens.
  107673. */
  107674. alphaMode: number;
  107675. private _system;
  107676. /**
  107677. * Creates a new Lens Flare.
  107678. * This represents one of the lens effect in a `lensFlareSystem`.
  107679. * It controls one of the indiviual texture used in the effect.
  107680. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107681. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107682. * @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.
  107683. * @param color Define the lens color
  107684. * @param imgUrl Define the lens texture url
  107685. * @param system Define the `lensFlareSystem` this flare is part of
  107686. * @returns The newly created Lens Flare
  107687. */
  107688. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107689. /**
  107690. * Instantiates a new Lens Flare.
  107691. * This represents one of the lens effect in a `lensFlareSystem`.
  107692. * It controls one of the indiviual texture used in the effect.
  107693. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107694. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107695. * @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.
  107696. * @param color Define the lens color
  107697. * @param imgUrl Define the lens texture url
  107698. * @param system Define the `lensFlareSystem` this flare is part of
  107699. */
  107700. constructor(
  107701. /**
  107702. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107703. */
  107704. size: number,
  107705. /**
  107706. * 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.
  107707. */
  107708. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107709. /**
  107710. * Dispose and release the lens flare with its associated resources.
  107711. */
  107712. dispose(): void;
  107713. }
  107714. }
  107715. declare module BABYLON {
  107716. interface AbstractScene {
  107717. /**
  107718. * The list of lens flare system added to the scene
  107719. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107720. */
  107721. lensFlareSystems: Array<LensFlareSystem>;
  107722. /**
  107723. * Removes the given lens flare system from this scene.
  107724. * @param toRemove The lens flare system to remove
  107725. * @returns The index of the removed lens flare system
  107726. */
  107727. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107728. /**
  107729. * Adds the given lens flare system to this scene
  107730. * @param newLensFlareSystem The lens flare system to add
  107731. */
  107732. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107733. /**
  107734. * Gets a lens flare system using its name
  107735. * @param name defines the name to look for
  107736. * @returns the lens flare system or null if not found
  107737. */
  107738. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107739. /**
  107740. * Gets a lens flare system using its id
  107741. * @param id defines the id to look for
  107742. * @returns the lens flare system or null if not found
  107743. */
  107744. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107745. }
  107746. /**
  107747. * Defines the lens flare scene component responsible to manage any lens flares
  107748. * in a given scene.
  107749. */
  107750. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107751. /**
  107752. * The component name helpfull to identify the component in the list of scene components.
  107753. */
  107754. readonly name: string;
  107755. /**
  107756. * The scene the component belongs to.
  107757. */
  107758. scene: Scene;
  107759. /**
  107760. * Creates a new instance of the component for the given scene
  107761. * @param scene Defines the scene to register the component in
  107762. */
  107763. constructor(scene: Scene);
  107764. /**
  107765. * Registers the component in a given scene
  107766. */
  107767. register(): void;
  107768. /**
  107769. * Rebuilds the elements related to this component in case of
  107770. * context lost for instance.
  107771. */
  107772. rebuild(): void;
  107773. /**
  107774. * Adds all the element from the container to the scene
  107775. * @param container the container holding the elements
  107776. */
  107777. addFromContainer(container: AbstractScene): void;
  107778. /**
  107779. * Removes all the elements in the container from the scene
  107780. * @param container contains the elements to remove
  107781. * @param dispose if the removed element should be disposed (default: false)
  107782. */
  107783. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107784. /**
  107785. * Serializes the component data to the specified json object
  107786. * @param serializationObject The object to serialize to
  107787. */
  107788. serialize(serializationObject: any): void;
  107789. /**
  107790. * Disposes the component and the associated ressources.
  107791. */
  107792. dispose(): void;
  107793. private _draw;
  107794. }
  107795. }
  107796. declare module BABYLON {
  107797. /**
  107798. * Defines the shadow generator component responsible to manage any shadow generators
  107799. * in a given scene.
  107800. */
  107801. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107802. /**
  107803. * The component name helpfull to identify the component in the list of scene components.
  107804. */
  107805. readonly name: string;
  107806. /**
  107807. * The scene the component belongs to.
  107808. */
  107809. scene: Scene;
  107810. /**
  107811. * Creates a new instance of the component for the given scene
  107812. * @param scene Defines the scene to register the component in
  107813. */
  107814. constructor(scene: Scene);
  107815. /**
  107816. * Registers the component in a given scene
  107817. */
  107818. register(): void;
  107819. /**
  107820. * Rebuilds the elements related to this component in case of
  107821. * context lost for instance.
  107822. */
  107823. rebuild(): void;
  107824. /**
  107825. * Serializes the component data to the specified json object
  107826. * @param serializationObject The object to serialize to
  107827. */
  107828. serialize(serializationObject: any): void;
  107829. /**
  107830. * Adds all the element from the container to the scene
  107831. * @param container the container holding the elements
  107832. */
  107833. addFromContainer(container: AbstractScene): void;
  107834. /**
  107835. * Removes all the elements in the container from the scene
  107836. * @param container contains the elements to remove
  107837. * @param dispose if the removed element should be disposed (default: false)
  107838. */
  107839. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107840. /**
  107841. * Rebuilds the elements related to this component in case of
  107842. * context lost for instance.
  107843. */
  107844. dispose(): void;
  107845. private _gatherRenderTargets;
  107846. }
  107847. }
  107848. declare module BABYLON {
  107849. /**
  107850. * A point light is a light defined by an unique point in world space.
  107851. * The light is emitted in every direction from this point.
  107852. * A good example of a point light is a standard light bulb.
  107853. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107854. */
  107855. export class PointLight extends ShadowLight {
  107856. private _shadowAngle;
  107857. /**
  107858. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107859. * This specifies what angle the shadow will use to be created.
  107860. *
  107861. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107862. */
  107863. /**
  107864. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107865. * This specifies what angle the shadow will use to be created.
  107866. *
  107867. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107868. */
  107869. shadowAngle: number;
  107870. /**
  107871. * Gets the direction if it has been set.
  107872. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107873. */
  107874. /**
  107875. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107876. */
  107877. direction: Vector3;
  107878. /**
  107879. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107880. * A PointLight emits the light in every direction.
  107881. * It can cast shadows.
  107882. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107883. * ```javascript
  107884. * var pointLight = new PointLight("pl", camera.position, scene);
  107885. * ```
  107886. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107887. * @param name The light friendly name
  107888. * @param position The position of the point light in the scene
  107889. * @param scene The scene the lights belongs to
  107890. */
  107891. constructor(name: string, position: Vector3, scene: Scene);
  107892. /**
  107893. * Returns the string "PointLight"
  107894. * @returns the class name
  107895. */
  107896. getClassName(): string;
  107897. /**
  107898. * Returns the integer 0.
  107899. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107900. */
  107901. getTypeID(): number;
  107902. /**
  107903. * Specifies wether or not the shadowmap should be a cube texture.
  107904. * @returns true if the shadowmap needs to be a cube texture.
  107905. */
  107906. needCube(): boolean;
  107907. /**
  107908. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107909. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107910. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107911. */
  107912. getShadowDirection(faceIndex?: number): Vector3;
  107913. /**
  107914. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107915. * - fov = PI / 2
  107916. * - aspect ratio : 1.0
  107917. * - z-near and far equal to the active camera minZ and maxZ.
  107918. * Returns the PointLight.
  107919. */
  107920. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107921. protected _buildUniformLayout(): void;
  107922. /**
  107923. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107924. * @param effect The effect to update
  107925. * @param lightIndex The index of the light in the effect to update
  107926. * @returns The point light
  107927. */
  107928. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107929. /**
  107930. * Prepares the list of defines specific to the light type.
  107931. * @param defines the list of defines
  107932. * @param lightIndex defines the index of the light for the effect
  107933. */
  107934. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107935. }
  107936. }
  107937. declare module BABYLON {
  107938. /**
  107939. * Header information of HDR texture files.
  107940. */
  107941. export interface HDRInfo {
  107942. /**
  107943. * The height of the texture in pixels.
  107944. */
  107945. height: number;
  107946. /**
  107947. * The width of the texture in pixels.
  107948. */
  107949. width: number;
  107950. /**
  107951. * The index of the beginning of the data in the binary file.
  107952. */
  107953. dataPosition: number;
  107954. }
  107955. /**
  107956. * This groups tools to convert HDR texture to native colors array.
  107957. */
  107958. export class HDRTools {
  107959. private static Ldexp;
  107960. private static Rgbe2float;
  107961. private static readStringLine;
  107962. /**
  107963. * Reads header information from an RGBE texture stored in a native array.
  107964. * More information on this format are available here:
  107965. * https://en.wikipedia.org/wiki/RGBE_image_format
  107966. *
  107967. * @param uint8array The binary file stored in native array.
  107968. * @return The header information.
  107969. */
  107970. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107971. /**
  107972. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107973. * This RGBE texture needs to store the information as a panorama.
  107974. *
  107975. * More information on this format are available here:
  107976. * https://en.wikipedia.org/wiki/RGBE_image_format
  107977. *
  107978. * @param buffer The binary file stored in an array buffer.
  107979. * @param size The expected size of the extracted cubemap.
  107980. * @return The Cube Map information.
  107981. */
  107982. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107983. /**
  107984. * Returns the pixels data extracted from an RGBE texture.
  107985. * This pixels will be stored left to right up to down in the R G B order in one array.
  107986. *
  107987. * More information on this format are available here:
  107988. * https://en.wikipedia.org/wiki/RGBE_image_format
  107989. *
  107990. * @param uint8array The binary file stored in an array buffer.
  107991. * @param hdrInfo The header information of the file.
  107992. * @return The pixels data in RGB right to left up to down order.
  107993. */
  107994. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107995. private static RGBE_ReadPixels_RLE;
  107996. }
  107997. }
  107998. declare module BABYLON {
  107999. /**
  108000. * This represents a texture coming from an HDR input.
  108001. *
  108002. * The only supported format is currently panorama picture stored in RGBE format.
  108003. * Example of such files can be found on HDRLib: http://hdrlib.com/
  108004. */
  108005. export class HDRCubeTexture extends BaseTexture {
  108006. private static _facesMapping;
  108007. private _generateHarmonics;
  108008. private _noMipmap;
  108009. private _textureMatrix;
  108010. private _size;
  108011. private _onLoad;
  108012. private _onError;
  108013. /**
  108014. * The texture URL.
  108015. */
  108016. url: string;
  108017. /**
  108018. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  108019. */
  108020. coordinatesMode: number;
  108021. protected _isBlocking: boolean;
  108022. /**
  108023. * Sets wether or not the texture is blocking during loading.
  108024. */
  108025. /**
  108026. * Gets wether or not the texture is blocking during loading.
  108027. */
  108028. isBlocking: boolean;
  108029. protected _rotationY: number;
  108030. /**
  108031. * Sets texture matrix rotation angle around Y axis in radians.
  108032. */
  108033. /**
  108034. * Gets texture matrix rotation angle around Y axis radians.
  108035. */
  108036. rotationY: number;
  108037. /**
  108038. * Gets or sets the center of the bounding box associated with the cube texture
  108039. * It must define where the camera used to render the texture was set
  108040. */
  108041. boundingBoxPosition: Vector3;
  108042. private _boundingBoxSize;
  108043. /**
  108044. * Gets or sets the size of the bounding box associated with the cube texture
  108045. * When defined, the cubemap will switch to local mode
  108046. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  108047. * @example https://www.babylonjs-playground.com/#RNASML
  108048. */
  108049. boundingBoxSize: Vector3;
  108050. /**
  108051. * Instantiates an HDRTexture from the following parameters.
  108052. *
  108053. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  108054. * @param scene The scene the texture will be used in
  108055. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108056. * @param noMipmap Forces to not generate the mipmap if true
  108057. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  108058. * @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)
  108059. * @param reserved Reserved flag for internal use.
  108060. */
  108061. 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>);
  108062. /**
  108063. * Get the current class name of the texture useful for serialization or dynamic coding.
  108064. * @returns "HDRCubeTexture"
  108065. */
  108066. getClassName(): string;
  108067. /**
  108068. * Occurs when the file is raw .hdr file.
  108069. */
  108070. private loadTexture;
  108071. clone(): HDRCubeTexture;
  108072. delayLoad(): void;
  108073. /**
  108074. * Get the texture reflection matrix used to rotate/transform the reflection.
  108075. * @returns the reflection matrix
  108076. */
  108077. getReflectionTextureMatrix(): Matrix;
  108078. /**
  108079. * Set the texture reflection matrix used to rotate/transform the reflection.
  108080. * @param value Define the reflection matrix to set
  108081. */
  108082. setReflectionTextureMatrix(value: Matrix): void;
  108083. /**
  108084. * Parses a JSON representation of an HDR Texture in order to create the texture
  108085. * @param parsedTexture Define the JSON representation
  108086. * @param scene Define the scene the texture should be created in
  108087. * @param rootUrl Define the root url in case we need to load relative dependencies
  108088. * @returns the newly created texture after parsing
  108089. */
  108090. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  108091. serialize(): any;
  108092. }
  108093. }
  108094. declare module BABYLON {
  108095. /**
  108096. * Class used to control physics engine
  108097. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108098. */
  108099. export class PhysicsEngine implements IPhysicsEngine {
  108100. private _physicsPlugin;
  108101. /**
  108102. * Global value used to control the smallest number supported by the simulation
  108103. */
  108104. static Epsilon: number;
  108105. private _impostors;
  108106. private _joints;
  108107. /**
  108108. * Gets the gravity vector used by the simulation
  108109. */
  108110. gravity: Vector3;
  108111. /**
  108112. * Factory used to create the default physics plugin.
  108113. * @returns The default physics plugin
  108114. */
  108115. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  108116. /**
  108117. * Creates a new Physics Engine
  108118. * @param gravity defines the gravity vector used by the simulation
  108119. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  108120. */
  108121. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  108122. /**
  108123. * Sets the gravity vector used by the simulation
  108124. * @param gravity defines the gravity vector to use
  108125. */
  108126. setGravity(gravity: Vector3): void;
  108127. /**
  108128. * Set the time step of the physics engine.
  108129. * Default is 1/60.
  108130. * To slow it down, enter 1/600 for example.
  108131. * To speed it up, 1/30
  108132. * @param newTimeStep defines the new timestep to apply to this world.
  108133. */
  108134. setTimeStep(newTimeStep?: number): void;
  108135. /**
  108136. * Get the time step of the physics engine.
  108137. * @returns the current time step
  108138. */
  108139. getTimeStep(): number;
  108140. /**
  108141. * Release all resources
  108142. */
  108143. dispose(): void;
  108144. /**
  108145. * Gets the name of the current physics plugin
  108146. * @returns the name of the plugin
  108147. */
  108148. getPhysicsPluginName(): string;
  108149. /**
  108150. * Adding a new impostor for the impostor tracking.
  108151. * This will be done by the impostor itself.
  108152. * @param impostor the impostor to add
  108153. */
  108154. addImpostor(impostor: PhysicsImpostor): void;
  108155. /**
  108156. * Remove an impostor from the engine.
  108157. * This impostor and its mesh will not longer be updated by the physics engine.
  108158. * @param impostor the impostor to remove
  108159. */
  108160. removeImpostor(impostor: PhysicsImpostor): void;
  108161. /**
  108162. * Add a joint to the physics engine
  108163. * @param mainImpostor defines the main impostor to which the joint is added.
  108164. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108165. * @param joint defines the joint that will connect both impostors.
  108166. */
  108167. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108168. /**
  108169. * Removes a joint from the simulation
  108170. * @param mainImpostor defines the impostor used with the joint
  108171. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108172. * @param joint defines the joint to remove
  108173. */
  108174. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108175. /**
  108176. * Called by the scene. No need to call it.
  108177. * @param delta defines the timespam between frames
  108178. */
  108179. _step(delta: number): void;
  108180. /**
  108181. * Gets the current plugin used to run the simulation
  108182. * @returns current plugin
  108183. */
  108184. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108185. /**
  108186. * Gets the list of physic impostors
  108187. * @returns an array of PhysicsImpostor
  108188. */
  108189. getImpostors(): Array<PhysicsImpostor>;
  108190. /**
  108191. * Gets the impostor for a physics enabled object
  108192. * @param object defines the object impersonated by the impostor
  108193. * @returns the PhysicsImpostor or null if not found
  108194. */
  108195. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108196. /**
  108197. * Gets the impostor for a physics body object
  108198. * @param body defines physics body used by the impostor
  108199. * @returns the PhysicsImpostor or null if not found
  108200. */
  108201. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108202. /**
  108203. * Does a raycast in the physics world
  108204. * @param from when should the ray start?
  108205. * @param to when should the ray end?
  108206. * @returns PhysicsRaycastResult
  108207. */
  108208. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108209. }
  108210. }
  108211. declare module BABYLON {
  108212. /** @hidden */
  108213. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  108214. private _useDeltaForWorldStep;
  108215. world: any;
  108216. name: string;
  108217. private _physicsMaterials;
  108218. private _fixedTimeStep;
  108219. private _cannonRaycastResult;
  108220. private _raycastResult;
  108221. private _removeAfterStep;
  108222. BJSCANNON: any;
  108223. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  108224. setGravity(gravity: Vector3): void;
  108225. setTimeStep(timeStep: number): void;
  108226. getTimeStep(): number;
  108227. executeStep(delta: number): void;
  108228. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108229. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108230. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108231. private _processChildMeshes;
  108232. removePhysicsBody(impostor: PhysicsImpostor): void;
  108233. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108234. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108235. private _addMaterial;
  108236. private _checkWithEpsilon;
  108237. private _createShape;
  108238. private _createHeightmap;
  108239. private _minus90X;
  108240. private _plus90X;
  108241. private _tmpPosition;
  108242. private _tmpDeltaPosition;
  108243. private _tmpUnityRotation;
  108244. private _updatePhysicsBodyTransformation;
  108245. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108246. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108247. isSupported(): boolean;
  108248. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108249. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108250. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108251. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108252. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108253. getBodyMass(impostor: PhysicsImpostor): number;
  108254. getBodyFriction(impostor: PhysicsImpostor): number;
  108255. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108256. getBodyRestitution(impostor: PhysicsImpostor): number;
  108257. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108258. sleepBody(impostor: PhysicsImpostor): void;
  108259. wakeUpBody(impostor: PhysicsImpostor): void;
  108260. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  108261. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108262. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108263. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108264. getRadius(impostor: PhysicsImpostor): number;
  108265. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108266. dispose(): void;
  108267. private _extendNamespace;
  108268. /**
  108269. * Does a raycast in the physics world
  108270. * @param from when should the ray start?
  108271. * @param to when should the ray end?
  108272. * @returns PhysicsRaycastResult
  108273. */
  108274. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108275. }
  108276. }
  108277. declare module BABYLON {
  108278. /** @hidden */
  108279. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  108280. world: any;
  108281. name: string;
  108282. BJSOIMO: any;
  108283. private _raycastResult;
  108284. constructor(iterations?: number, oimoInjection?: any);
  108285. setGravity(gravity: Vector3): void;
  108286. setTimeStep(timeStep: number): void;
  108287. getTimeStep(): number;
  108288. private _tmpImpostorsArray;
  108289. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108290. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108291. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108292. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108293. private _tmpPositionVector;
  108294. removePhysicsBody(impostor: PhysicsImpostor): void;
  108295. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108296. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108297. isSupported(): boolean;
  108298. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108299. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  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, minDistance?: number): void;
  108313. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  108314. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: 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. /**
  108320. * Does a raycast in the physics world
  108321. * @param from when should the ray start?
  108322. * @param to when should the ray end?
  108323. * @returns PhysicsRaycastResult
  108324. */
  108325. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108326. }
  108327. }
  108328. declare module BABYLON {
  108329. /**
  108330. * Class containing static functions to help procedurally build meshes
  108331. */
  108332. export class RibbonBuilder {
  108333. /**
  108334. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108335. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108336. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108337. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108338. * * 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
  108339. * * 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
  108340. * * 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
  108341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108343. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108344. * * 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
  108345. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108346. * * 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
  108347. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108349. * @param name defines the name of the mesh
  108350. * @param options defines the options used to create the mesh
  108351. * @param scene defines the hosting scene
  108352. * @returns the ribbon mesh
  108353. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108354. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108355. */
  108356. static CreateRibbon(name: string, options: {
  108357. pathArray: Vector3[][];
  108358. closeArray?: boolean;
  108359. closePath?: boolean;
  108360. offset?: number;
  108361. updatable?: boolean;
  108362. sideOrientation?: number;
  108363. frontUVs?: Vector4;
  108364. backUVs?: Vector4;
  108365. instance?: Mesh;
  108366. invertUV?: boolean;
  108367. uvs?: Vector2[];
  108368. colors?: Color4[];
  108369. }, scene?: Nullable<Scene>): Mesh;
  108370. }
  108371. }
  108372. declare module BABYLON {
  108373. /**
  108374. * Class containing static functions to help procedurally build meshes
  108375. */
  108376. export class ShapeBuilder {
  108377. /**
  108378. * 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.
  108379. * * 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.
  108380. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108381. * * 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.
  108382. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108383. * * 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
  108384. * * 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
  108385. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108388. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108390. * @param name defines the name of the mesh
  108391. * @param options defines the options used to create the mesh
  108392. * @param scene defines the hosting scene
  108393. * @returns the extruded shape mesh
  108394. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108396. */
  108397. static ExtrudeShape(name: string, options: {
  108398. shape: Vector3[];
  108399. path: Vector3[];
  108400. scale?: number;
  108401. rotation?: number;
  108402. cap?: number;
  108403. updatable?: boolean;
  108404. sideOrientation?: number;
  108405. frontUVs?: Vector4;
  108406. backUVs?: Vector4;
  108407. instance?: Mesh;
  108408. invertUV?: boolean;
  108409. }, scene?: Nullable<Scene>): Mesh;
  108410. /**
  108411. * Creates an custom extruded shape mesh.
  108412. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108413. * * 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.
  108414. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108415. * * 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
  108416. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108417. * * 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
  108418. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108419. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108420. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108421. * * 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
  108422. * * 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
  108423. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108428. * @param name defines the name of the mesh
  108429. * @param options defines the options used to create the mesh
  108430. * @param scene defines the hosting scene
  108431. * @returns the custom extruded shape mesh
  108432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108433. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108435. */
  108436. static ExtrudeShapeCustom(name: string, options: {
  108437. shape: Vector3[];
  108438. path: Vector3[];
  108439. scaleFunction?: any;
  108440. rotationFunction?: any;
  108441. ribbonCloseArray?: boolean;
  108442. ribbonClosePath?: boolean;
  108443. cap?: number;
  108444. updatable?: boolean;
  108445. sideOrientation?: number;
  108446. frontUVs?: Vector4;
  108447. backUVs?: Vector4;
  108448. instance?: Mesh;
  108449. invertUV?: boolean;
  108450. }, scene?: Nullable<Scene>): Mesh;
  108451. private static _ExtrudeShapeGeneric;
  108452. }
  108453. }
  108454. declare module BABYLON {
  108455. /**
  108456. * AmmoJS Physics plugin
  108457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108458. * @see https://github.com/kripken/ammo.js/
  108459. */
  108460. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108461. private _useDeltaForWorldStep;
  108462. /**
  108463. * Reference to the Ammo library
  108464. */
  108465. bjsAMMO: any;
  108466. /**
  108467. * Created ammoJS world which physics bodies are added to
  108468. */
  108469. world: any;
  108470. /**
  108471. * Name of the plugin
  108472. */
  108473. name: string;
  108474. private _timeStep;
  108475. private _fixedTimeStep;
  108476. private _maxSteps;
  108477. private _tmpQuaternion;
  108478. private _tmpAmmoTransform;
  108479. private _tmpAmmoQuaternion;
  108480. private _tmpAmmoConcreteContactResultCallback;
  108481. private _collisionConfiguration;
  108482. private _dispatcher;
  108483. private _overlappingPairCache;
  108484. private _solver;
  108485. private _softBodySolver;
  108486. private _tmpAmmoVectorA;
  108487. private _tmpAmmoVectorB;
  108488. private _tmpAmmoVectorC;
  108489. private _tmpAmmoVectorD;
  108490. private _tmpContactCallbackResult;
  108491. private _tmpAmmoVectorRCA;
  108492. private _tmpAmmoVectorRCB;
  108493. private _raycastResult;
  108494. private static readonly DISABLE_COLLISION_FLAG;
  108495. private static readonly KINEMATIC_FLAG;
  108496. private static readonly DISABLE_DEACTIVATION_FLAG;
  108497. /**
  108498. * Initializes the ammoJS plugin
  108499. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108500. * @param ammoInjection can be used to inject your own ammo reference
  108501. */
  108502. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108503. /**
  108504. * Sets the gravity of the physics world (m/(s^2))
  108505. * @param gravity Gravity to set
  108506. */
  108507. setGravity(gravity: Vector3): void;
  108508. /**
  108509. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108510. * @param timeStep timestep to use in seconds
  108511. */
  108512. setTimeStep(timeStep: number): void;
  108513. /**
  108514. * 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)
  108515. * @param fixedTimeStep fixedTimeStep to use in seconds
  108516. */
  108517. setFixedTimeStep(fixedTimeStep: number): void;
  108518. /**
  108519. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108520. * @param maxSteps the maximum number of steps by the physics engine per frame
  108521. */
  108522. setMaxSteps(maxSteps: number): void;
  108523. /**
  108524. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108525. * @returns the current timestep in seconds
  108526. */
  108527. getTimeStep(): number;
  108528. private _isImpostorInContact;
  108529. private _isImpostorPairInContact;
  108530. private _stepSimulation;
  108531. /**
  108532. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108533. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108534. * After the step the babylon meshes are set to the position of the physics imposters
  108535. * @param delta amount of time to step forward
  108536. * @param impostors array of imposters to update before/after the step
  108537. */
  108538. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108539. /**
  108540. * Update babylon mesh to match physics world object
  108541. * @param impostor imposter to match
  108542. */
  108543. private _afterSoftStep;
  108544. /**
  108545. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108546. * @param impostor imposter to match
  108547. */
  108548. private _ropeStep;
  108549. /**
  108550. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108551. * @param impostor imposter to match
  108552. */
  108553. private _softbodyOrClothStep;
  108554. private _tmpVector;
  108555. private _tmpMatrix;
  108556. /**
  108557. * Applies an impulse on the imposter
  108558. * @param impostor imposter to apply impulse to
  108559. * @param force amount of force to be applied to the imposter
  108560. * @param contactPoint the location to apply the impulse on the imposter
  108561. */
  108562. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108563. /**
  108564. * Applies a force on the imposter
  108565. * @param impostor imposter to apply force
  108566. * @param force amount of force to be applied to the imposter
  108567. * @param contactPoint the location to apply the force on the imposter
  108568. */
  108569. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108570. /**
  108571. * Creates a physics body using the plugin
  108572. * @param impostor the imposter to create the physics body on
  108573. */
  108574. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108575. /**
  108576. * Removes the physics body from the imposter and disposes of the body's memory
  108577. * @param impostor imposter to remove the physics body from
  108578. */
  108579. removePhysicsBody(impostor: PhysicsImpostor): void;
  108580. /**
  108581. * Generates a joint
  108582. * @param impostorJoint the imposter joint to create the joint with
  108583. */
  108584. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108585. /**
  108586. * Removes a joint
  108587. * @param impostorJoint the imposter joint to remove the joint from
  108588. */
  108589. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108590. private _addMeshVerts;
  108591. /**
  108592. * Initialise the soft body vertices to match its object's (mesh) vertices
  108593. * Softbody vertices (nodes) are in world space and to match this
  108594. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108595. * @param impostor to create the softbody for
  108596. */
  108597. private _softVertexData;
  108598. /**
  108599. * Create an impostor's soft body
  108600. * @param impostor to create the softbody for
  108601. */
  108602. private _createSoftbody;
  108603. /**
  108604. * Create cloth for an impostor
  108605. * @param impostor to create the softbody for
  108606. */
  108607. private _createCloth;
  108608. /**
  108609. * Create rope for an impostor
  108610. * @param impostor to create the softbody for
  108611. */
  108612. private _createRope;
  108613. private _addHullVerts;
  108614. private _createShape;
  108615. /**
  108616. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108617. * @param impostor imposter containing the physics body and babylon object
  108618. */
  108619. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108620. /**
  108621. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108622. * @param impostor imposter containing the physics body and babylon object
  108623. * @param newPosition new position
  108624. * @param newRotation new rotation
  108625. */
  108626. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108627. /**
  108628. * If this plugin is supported
  108629. * @returns true if its supported
  108630. */
  108631. isSupported(): boolean;
  108632. /**
  108633. * Sets the linear velocity of the physics body
  108634. * @param impostor imposter to set the velocity on
  108635. * @param velocity velocity to set
  108636. */
  108637. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108638. /**
  108639. * Sets the angular velocity of the physics body
  108640. * @param impostor imposter to set the velocity on
  108641. * @param velocity velocity to set
  108642. */
  108643. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108644. /**
  108645. * gets the linear velocity
  108646. * @param impostor imposter to get linear velocity from
  108647. * @returns linear velocity
  108648. */
  108649. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108650. /**
  108651. * gets the angular velocity
  108652. * @param impostor imposter to get angular velocity from
  108653. * @returns angular velocity
  108654. */
  108655. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108656. /**
  108657. * Sets the mass of physics body
  108658. * @param impostor imposter to set the mass on
  108659. * @param mass mass to set
  108660. */
  108661. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108662. /**
  108663. * Gets the mass of the physics body
  108664. * @param impostor imposter to get the mass from
  108665. * @returns mass
  108666. */
  108667. getBodyMass(impostor: PhysicsImpostor): number;
  108668. /**
  108669. * Gets friction of the impostor
  108670. * @param impostor impostor to get friction from
  108671. * @returns friction value
  108672. */
  108673. getBodyFriction(impostor: PhysicsImpostor): number;
  108674. /**
  108675. * Sets friction of the impostor
  108676. * @param impostor impostor to set friction on
  108677. * @param friction friction value
  108678. */
  108679. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108680. /**
  108681. * Gets restitution of the impostor
  108682. * @param impostor impostor to get restitution from
  108683. * @returns restitution value
  108684. */
  108685. getBodyRestitution(impostor: PhysicsImpostor): number;
  108686. /**
  108687. * Sets resitution of the impostor
  108688. * @param impostor impostor to set resitution on
  108689. * @param restitution resitution value
  108690. */
  108691. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108692. /**
  108693. * Gets pressure inside the impostor
  108694. * @param impostor impostor to get pressure from
  108695. * @returns pressure value
  108696. */
  108697. getBodyPressure(impostor: PhysicsImpostor): number;
  108698. /**
  108699. * Sets pressure inside a soft body impostor
  108700. * Cloth and rope must remain 0 pressure
  108701. * @param impostor impostor to set pressure on
  108702. * @param pressure pressure value
  108703. */
  108704. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108705. /**
  108706. * Gets stiffness of the impostor
  108707. * @param impostor impostor to get stiffness from
  108708. * @returns pressure value
  108709. */
  108710. getBodyStiffness(impostor: PhysicsImpostor): number;
  108711. /**
  108712. * Sets stiffness of the impostor
  108713. * @param impostor impostor to set stiffness on
  108714. * @param stiffness stiffness value from 0 to 1
  108715. */
  108716. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108717. /**
  108718. * Gets velocityIterations of the impostor
  108719. * @param impostor impostor to get velocity iterations from
  108720. * @returns velocityIterations value
  108721. */
  108722. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108723. /**
  108724. * Sets velocityIterations of the impostor
  108725. * @param impostor impostor to set velocity iterations on
  108726. * @param velocityIterations velocityIterations value
  108727. */
  108728. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108729. /**
  108730. * Gets positionIterations of the impostor
  108731. * @param impostor impostor to get position iterations from
  108732. * @returns positionIterations value
  108733. */
  108734. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108735. /**
  108736. * Sets positionIterations of the impostor
  108737. * @param impostor impostor to set position on
  108738. * @param positionIterations positionIterations value
  108739. */
  108740. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108741. /**
  108742. * Append an anchor to a cloth object
  108743. * @param impostor is the cloth impostor to add anchor to
  108744. * @param otherImpostor is the rigid impostor to anchor to
  108745. * @param width ratio across width from 0 to 1
  108746. * @param height ratio up height from 0 to 1
  108747. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108748. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108749. */
  108750. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108751. /**
  108752. * Append an hook to a rope object
  108753. * @param impostor is the rope impostor to add hook to
  108754. * @param otherImpostor is the rigid impostor to hook to
  108755. * @param length ratio along the rope from 0 to 1
  108756. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108757. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108758. */
  108759. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108760. /**
  108761. * Sleeps the physics body and stops it from being active
  108762. * @param impostor impostor to sleep
  108763. */
  108764. sleepBody(impostor: PhysicsImpostor): void;
  108765. /**
  108766. * Activates the physics body
  108767. * @param impostor impostor to activate
  108768. */
  108769. wakeUpBody(impostor: PhysicsImpostor): void;
  108770. /**
  108771. * Updates the distance parameters of the joint
  108772. * @param joint joint to update
  108773. * @param maxDistance maximum distance of the joint
  108774. * @param minDistance minimum distance of the joint
  108775. */
  108776. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108777. /**
  108778. * Sets a motor on the joint
  108779. * @param joint joint to set motor on
  108780. * @param speed speed of the motor
  108781. * @param maxForce maximum force of the motor
  108782. * @param motorIndex index of the motor
  108783. */
  108784. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108785. /**
  108786. * Sets the motors limit
  108787. * @param joint joint to set limit on
  108788. * @param upperLimit upper limit
  108789. * @param lowerLimit lower limit
  108790. */
  108791. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108792. /**
  108793. * Syncs the position and rotation of a mesh with the impostor
  108794. * @param mesh mesh to sync
  108795. * @param impostor impostor to update the mesh with
  108796. */
  108797. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108798. /**
  108799. * Gets the radius of the impostor
  108800. * @param impostor impostor to get radius from
  108801. * @returns the radius
  108802. */
  108803. getRadius(impostor: PhysicsImpostor): number;
  108804. /**
  108805. * Gets the box size of the impostor
  108806. * @param impostor impostor to get box size from
  108807. * @param result the resulting box size
  108808. */
  108809. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108810. /**
  108811. * Disposes of the impostor
  108812. */
  108813. dispose(): void;
  108814. /**
  108815. * Does a raycast in the physics world
  108816. * @param from when should the ray start?
  108817. * @param to when should the ray end?
  108818. * @returns PhysicsRaycastResult
  108819. */
  108820. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108821. }
  108822. }
  108823. declare module BABYLON {
  108824. interface AbstractScene {
  108825. /**
  108826. * The list of reflection probes added to the scene
  108827. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108828. */
  108829. reflectionProbes: Array<ReflectionProbe>;
  108830. /**
  108831. * Removes the given reflection probe from this scene.
  108832. * @param toRemove The reflection probe to remove
  108833. * @returns The index of the removed reflection probe
  108834. */
  108835. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108836. /**
  108837. * Adds the given reflection probe to this scene.
  108838. * @param newReflectionProbe The reflection probe to add
  108839. */
  108840. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108841. }
  108842. /**
  108843. * Class used to generate realtime reflection / refraction cube textures
  108844. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108845. */
  108846. export class ReflectionProbe {
  108847. /** defines the name of the probe */
  108848. name: string;
  108849. private _scene;
  108850. private _renderTargetTexture;
  108851. private _projectionMatrix;
  108852. private _viewMatrix;
  108853. private _target;
  108854. private _add;
  108855. private _attachedMesh;
  108856. private _invertYAxis;
  108857. /** Gets or sets probe position (center of the cube map) */
  108858. position: Vector3;
  108859. /**
  108860. * Creates a new reflection probe
  108861. * @param name defines the name of the probe
  108862. * @param size defines the texture resolution (for each face)
  108863. * @param scene defines the hosting scene
  108864. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108865. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108866. */
  108867. constructor(
  108868. /** defines the name of the probe */
  108869. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108870. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108871. samples: number;
  108872. /** Gets or sets the refresh rate to use (on every frame by default) */
  108873. refreshRate: number;
  108874. /**
  108875. * Gets the hosting scene
  108876. * @returns a Scene
  108877. */
  108878. getScene(): Scene;
  108879. /** Gets the internal CubeTexture used to render to */
  108880. readonly cubeTexture: RenderTargetTexture;
  108881. /** Gets the list of meshes to render */
  108882. readonly renderList: Nullable<AbstractMesh[]>;
  108883. /**
  108884. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108885. * @param mesh defines the mesh to attach to
  108886. */
  108887. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108888. /**
  108889. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108890. * @param renderingGroupId The rendering group id corresponding to its index
  108891. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108892. */
  108893. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108894. /**
  108895. * Clean all associated resources
  108896. */
  108897. dispose(): void;
  108898. /**
  108899. * Converts the reflection probe information to a readable string for debug purpose.
  108900. * @param fullDetails Supports for multiple levels of logging within scene loading
  108901. * @returns the human readable reflection probe info
  108902. */
  108903. toString(fullDetails?: boolean): string;
  108904. /**
  108905. * Get the class name of the relfection probe.
  108906. * @returns "ReflectionProbe"
  108907. */
  108908. getClassName(): string;
  108909. /**
  108910. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108911. * @returns The JSON representation of the texture
  108912. */
  108913. serialize(): any;
  108914. /**
  108915. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108916. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108917. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108918. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108919. * @returns The parsed reflection probe if successful
  108920. */
  108921. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108922. }
  108923. }
  108924. declare module BABYLON {
  108925. /** @hidden */
  108926. export var _BabylonLoaderRegistered: boolean;
  108927. }
  108928. declare module BABYLON {
  108929. /**
  108930. * The Physically based simple base material of BJS.
  108931. *
  108932. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108933. * It is used as the base class for both the specGloss and metalRough conventions.
  108934. */
  108935. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108936. /**
  108937. * Number of Simultaneous lights allowed on the material.
  108938. */
  108939. maxSimultaneousLights: number;
  108940. /**
  108941. * If sets to true, disables all the lights affecting the material.
  108942. */
  108943. disableLighting: boolean;
  108944. /**
  108945. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108946. */
  108947. environmentTexture: BaseTexture;
  108948. /**
  108949. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108950. */
  108951. invertNormalMapX: boolean;
  108952. /**
  108953. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108954. */
  108955. invertNormalMapY: boolean;
  108956. /**
  108957. * Normal map used in the model.
  108958. */
  108959. normalTexture: BaseTexture;
  108960. /**
  108961. * Emissivie color used to self-illuminate the model.
  108962. */
  108963. emissiveColor: Color3;
  108964. /**
  108965. * Emissivie texture used to self-illuminate the model.
  108966. */
  108967. emissiveTexture: BaseTexture;
  108968. /**
  108969. * Occlusion Channel Strenght.
  108970. */
  108971. occlusionStrength: number;
  108972. /**
  108973. * Occlusion Texture of the material (adding extra occlusion effects).
  108974. */
  108975. occlusionTexture: BaseTexture;
  108976. /**
  108977. * Defines the alpha limits in alpha test mode.
  108978. */
  108979. alphaCutOff: number;
  108980. /**
  108981. * Gets the current double sided mode.
  108982. */
  108983. /**
  108984. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108985. */
  108986. doubleSided: boolean;
  108987. /**
  108988. * Stores the pre-calculated light information of a mesh in a texture.
  108989. */
  108990. lightmapTexture: BaseTexture;
  108991. /**
  108992. * If true, the light map contains occlusion information instead of lighting info.
  108993. */
  108994. useLightmapAsShadowmap: boolean;
  108995. /**
  108996. * Instantiates a new PBRMaterial instance.
  108997. *
  108998. * @param name The material name
  108999. * @param scene The scene the material will be use in.
  109000. */
  109001. constructor(name: string, scene: Scene);
  109002. getClassName(): string;
  109003. }
  109004. }
  109005. declare module BABYLON {
  109006. /**
  109007. * The PBR material of BJS following the metal roughness convention.
  109008. *
  109009. * This fits to the PBR convention in the GLTF definition:
  109010. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  109011. */
  109012. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  109013. /**
  109014. * The base color has two different interpretations depending on the value of metalness.
  109015. * When the material is a metal, the base color is the specific measured reflectance value
  109016. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  109017. * of the material.
  109018. */
  109019. baseColor: Color3;
  109020. /**
  109021. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  109022. * well as opacity information in the alpha channel.
  109023. */
  109024. baseTexture: BaseTexture;
  109025. /**
  109026. * Specifies the metallic scalar value of the material.
  109027. * Can also be used to scale the metalness values of the metallic texture.
  109028. */
  109029. metallic: number;
  109030. /**
  109031. * Specifies the roughness scalar value of the material.
  109032. * Can also be used to scale the roughness values of the metallic texture.
  109033. */
  109034. roughness: number;
  109035. /**
  109036. * Texture containing both the metallic value in the B channel and the
  109037. * roughness value in the G channel to keep better precision.
  109038. */
  109039. metallicRoughnessTexture: BaseTexture;
  109040. /**
  109041. * Instantiates a new PBRMetalRoughnessMaterial instance.
  109042. *
  109043. * @param name The material name
  109044. * @param scene The scene the material will be use in.
  109045. */
  109046. constructor(name: string, scene: Scene);
  109047. /**
  109048. * Return the currrent class name of the material.
  109049. */
  109050. getClassName(): string;
  109051. /**
  109052. * Makes a duplicate of the current material.
  109053. * @param name - name to use for the new material.
  109054. */
  109055. clone(name: string): PBRMetallicRoughnessMaterial;
  109056. /**
  109057. * Serialize the material to a parsable JSON object.
  109058. */
  109059. serialize(): any;
  109060. /**
  109061. * Parses a JSON object correponding to the serialize function.
  109062. */
  109063. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  109064. }
  109065. }
  109066. declare module BABYLON {
  109067. /**
  109068. * The PBR material of BJS following the specular glossiness convention.
  109069. *
  109070. * This fits to the PBR convention in the GLTF definition:
  109071. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  109072. */
  109073. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  109074. /**
  109075. * Specifies the diffuse color of the material.
  109076. */
  109077. diffuseColor: Color3;
  109078. /**
  109079. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  109080. * channel.
  109081. */
  109082. diffuseTexture: BaseTexture;
  109083. /**
  109084. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  109085. */
  109086. specularColor: Color3;
  109087. /**
  109088. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  109089. */
  109090. glossiness: number;
  109091. /**
  109092. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  109093. */
  109094. specularGlossinessTexture: BaseTexture;
  109095. /**
  109096. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  109097. *
  109098. * @param name The material name
  109099. * @param scene The scene the material will be use in.
  109100. */
  109101. constructor(name: string, scene: Scene);
  109102. /**
  109103. * Return the currrent class name of the material.
  109104. */
  109105. getClassName(): string;
  109106. /**
  109107. * Makes a duplicate of the current material.
  109108. * @param name - name to use for the new material.
  109109. */
  109110. clone(name: string): PBRSpecularGlossinessMaterial;
  109111. /**
  109112. * Serialize the material to a parsable JSON object.
  109113. */
  109114. serialize(): any;
  109115. /**
  109116. * Parses a JSON object correponding to the serialize function.
  109117. */
  109118. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  109119. }
  109120. }
  109121. declare module BABYLON {
  109122. /**
  109123. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  109124. * It can help converting any input color in a desired output one. This can then be used to create effects
  109125. * from sepia, black and white to sixties or futuristic rendering...
  109126. *
  109127. * The only supported format is currently 3dl.
  109128. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  109129. */
  109130. export class ColorGradingTexture extends BaseTexture {
  109131. /**
  109132. * The current texture matrix. (will always be identity in color grading texture)
  109133. */
  109134. private _textureMatrix;
  109135. /**
  109136. * The texture URL.
  109137. */
  109138. url: string;
  109139. /**
  109140. * Empty line regex stored for GC.
  109141. */
  109142. private static _noneEmptyLineRegex;
  109143. private _engine;
  109144. /**
  109145. * Instantiates a ColorGradingTexture from the following parameters.
  109146. *
  109147. * @param url The location of the color gradind data (currently only supporting 3dl)
  109148. * @param scene The scene the texture will be used in
  109149. */
  109150. constructor(url: string, scene: Scene);
  109151. /**
  109152. * Returns the texture matrix used in most of the material.
  109153. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  109154. */
  109155. getTextureMatrix(): Matrix;
  109156. /**
  109157. * Occurs when the file being loaded is a .3dl LUT file.
  109158. */
  109159. private load3dlTexture;
  109160. /**
  109161. * Starts the loading process of the texture.
  109162. */
  109163. private loadTexture;
  109164. /**
  109165. * Clones the color gradind texture.
  109166. */
  109167. clone(): ColorGradingTexture;
  109168. /**
  109169. * Called during delayed load for textures.
  109170. */
  109171. delayLoad(): void;
  109172. /**
  109173. * Parses a color grading texture serialized by Babylon.
  109174. * @param parsedTexture The texture information being parsedTexture
  109175. * @param scene The scene to load the texture in
  109176. * @param rootUrl The root url of the data assets to load
  109177. * @return A color gradind texture
  109178. */
  109179. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  109180. /**
  109181. * Serializes the LUT texture to json format.
  109182. */
  109183. serialize(): any;
  109184. }
  109185. }
  109186. declare module BABYLON {
  109187. /**
  109188. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  109189. */
  109190. export class EquiRectangularCubeTexture extends BaseTexture {
  109191. /** The six faces of the cube. */
  109192. private static _FacesMapping;
  109193. private _noMipmap;
  109194. private _onLoad;
  109195. private _onError;
  109196. /** The size of the cubemap. */
  109197. private _size;
  109198. /** The buffer of the image. */
  109199. private _buffer;
  109200. /** The width of the input image. */
  109201. private _width;
  109202. /** The height of the input image. */
  109203. private _height;
  109204. /** The URL to the image. */
  109205. url: string;
  109206. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  109207. coordinatesMode: number;
  109208. /**
  109209. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  109210. * @param url The location of the image
  109211. * @param scene The scene the texture will be used in
  109212. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  109213. * @param noMipmap Forces to not generate the mipmap if true
  109214. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  109215. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  109216. * @param onLoad — defines a callback called when texture is loaded
  109217. * @param onError — defines a callback called if there is an error
  109218. */
  109219. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  109220. /**
  109221. * Load the image data, by putting the image on a canvas and extracting its buffer.
  109222. */
  109223. private loadImage;
  109224. /**
  109225. * Convert the image buffer into a cubemap and create a CubeTexture.
  109226. */
  109227. private loadTexture;
  109228. /**
  109229. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  109230. * @param buffer The ArrayBuffer that should be converted.
  109231. * @returns The buffer as Float32Array.
  109232. */
  109233. private getFloat32ArrayFromArrayBuffer;
  109234. /**
  109235. * Get the current class name of the texture useful for serialization or dynamic coding.
  109236. * @returns "EquiRectangularCubeTexture"
  109237. */
  109238. getClassName(): string;
  109239. /**
  109240. * Create a clone of the current EquiRectangularCubeTexture and return it.
  109241. * @returns A clone of the current EquiRectangularCubeTexture.
  109242. */
  109243. clone(): EquiRectangularCubeTexture;
  109244. }
  109245. }
  109246. declare module BABYLON {
  109247. /**
  109248. * Based on jsTGALoader - Javascript loader for TGA file
  109249. * By Vincent Thibault
  109250. * @see http://blog.robrowser.com/javascript-tga-loader.html
  109251. */
  109252. export class TGATools {
  109253. private static _TYPE_INDEXED;
  109254. private static _TYPE_RGB;
  109255. private static _TYPE_GREY;
  109256. private static _TYPE_RLE_INDEXED;
  109257. private static _TYPE_RLE_RGB;
  109258. private static _TYPE_RLE_GREY;
  109259. private static _ORIGIN_MASK;
  109260. private static _ORIGIN_SHIFT;
  109261. private static _ORIGIN_BL;
  109262. private static _ORIGIN_BR;
  109263. private static _ORIGIN_UL;
  109264. private static _ORIGIN_UR;
  109265. /**
  109266. * Gets the header of a TGA file
  109267. * @param data defines the TGA data
  109268. * @returns the header
  109269. */
  109270. static GetTGAHeader(data: Uint8Array): any;
  109271. /**
  109272. * Uploads TGA content to a Babylon Texture
  109273. * @hidden
  109274. */
  109275. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  109276. /** @hidden */
  109277. 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;
  109278. /** @hidden */
  109279. 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;
  109280. /** @hidden */
  109281. 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;
  109282. /** @hidden */
  109283. 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;
  109284. /** @hidden */
  109285. 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;
  109286. /** @hidden */
  109287. 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;
  109288. }
  109289. }
  109290. declare module BABYLON {
  109291. /**
  109292. * Implementation of the TGA Texture Loader.
  109293. * @hidden
  109294. */
  109295. export class _TGATextureLoader implements IInternalTextureLoader {
  109296. /**
  109297. * Defines wether the loader supports cascade loading the different faces.
  109298. */
  109299. readonly supportCascades: boolean;
  109300. /**
  109301. * This returns if the loader support the current file information.
  109302. * @param extension defines the file extension of the file being loaded
  109303. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109304. * @param fallback defines the fallback internal texture if any
  109305. * @param isBase64 defines whether the texture is encoded as a base64
  109306. * @param isBuffer defines whether the texture data are stored as a buffer
  109307. * @returns true if the loader can load the specified file
  109308. */
  109309. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109310. /**
  109311. * Transform the url before loading if required.
  109312. * @param rootUrl the url of the texture
  109313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109314. * @returns the transformed texture
  109315. */
  109316. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109317. /**
  109318. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109319. * @param rootUrl the url of the texture
  109320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109321. * @returns the fallback texture
  109322. */
  109323. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109324. /**
  109325. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109326. * @param data contains the texture data
  109327. * @param texture defines the BabylonJS internal texture
  109328. * @param createPolynomials will be true if polynomials have been requested
  109329. * @param onLoad defines the callback to trigger once the texture is ready
  109330. * @param onError defines the callback to trigger in case of error
  109331. */
  109332. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109333. /**
  109334. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109335. * @param data contains the texture data
  109336. * @param texture defines the BabylonJS internal texture
  109337. * @param callback defines the method to call once ready to upload
  109338. */
  109339. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109340. }
  109341. }
  109342. declare module BABYLON {
  109343. /**
  109344. * 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.
  109345. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109346. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109347. */
  109348. export class CustomProceduralTexture extends ProceduralTexture {
  109349. private _animate;
  109350. private _time;
  109351. private _config;
  109352. private _texturePath;
  109353. /**
  109354. * Instantiates a new Custom Procedural Texture.
  109355. * 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.
  109356. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109357. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109358. * @param name Define the name of the texture
  109359. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  109360. * @param size Define the size of the texture to create
  109361. * @param scene Define the scene the texture belongs to
  109362. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  109363. * @param generateMipMaps Define if the texture should creates mip maps or not
  109364. */
  109365. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109366. private _loadJson;
  109367. /**
  109368. * Is the texture ready to be used ? (rendered at least once)
  109369. * @returns true if ready, otherwise, false.
  109370. */
  109371. isReady(): boolean;
  109372. /**
  109373. * Render the texture to its associated render target.
  109374. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  109375. */
  109376. render(useCameraPostProcess?: boolean): void;
  109377. /**
  109378. * Update the list of dependant textures samplers in the shader.
  109379. */
  109380. updateTextures(): void;
  109381. /**
  109382. * Update the uniform values of the procedural texture in the shader.
  109383. */
  109384. updateShaderUniforms(): void;
  109385. /**
  109386. * Define if the texture animates or not.
  109387. */
  109388. animate: boolean;
  109389. }
  109390. }
  109391. declare module BABYLON {
  109392. /** @hidden */
  109393. export var noisePixelShader: {
  109394. name: string;
  109395. shader: string;
  109396. };
  109397. }
  109398. declare module BABYLON {
  109399. /**
  109400. * Class used to generate noise procedural textures
  109401. */
  109402. export class NoiseProceduralTexture extends ProceduralTexture {
  109403. private _time;
  109404. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109405. brightness: number;
  109406. /** Defines the number of octaves to process */
  109407. octaves: number;
  109408. /** Defines the level of persistence (0.8 by default) */
  109409. persistence: number;
  109410. /** Gets or sets animation speed factor (default is 1) */
  109411. animationSpeedFactor: number;
  109412. /**
  109413. * Creates a new NoiseProceduralTexture
  109414. * @param name defines the name fo the texture
  109415. * @param size defines the size of the texture (default is 256)
  109416. * @param scene defines the hosting scene
  109417. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109418. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109419. */
  109420. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109421. private _updateShaderUniforms;
  109422. protected _getDefines(): string;
  109423. /** Generate the current state of the procedural texture */
  109424. render(useCameraPostProcess?: boolean): void;
  109425. /**
  109426. * Serializes this noise procedural texture
  109427. * @returns a serialized noise procedural texture object
  109428. */
  109429. serialize(): any;
  109430. /**
  109431. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109432. * @param parsedTexture defines parsed texture data
  109433. * @param scene defines the current scene
  109434. * @param rootUrl defines the root URL containing noise procedural texture information
  109435. * @returns a parsed NoiseProceduralTexture
  109436. */
  109437. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109438. }
  109439. }
  109440. declare module BABYLON {
  109441. /**
  109442. * Raw cube texture where the raw buffers are passed in
  109443. */
  109444. export class RawCubeTexture extends CubeTexture {
  109445. /**
  109446. * Creates a cube texture where the raw buffers are passed in.
  109447. * @param scene defines the scene the texture is attached to
  109448. * @param data defines the array of data to use to create each face
  109449. * @param size defines the size of the textures
  109450. * @param format defines the format of the data
  109451. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109452. * @param generateMipMaps defines if the engine should generate the mip levels
  109453. * @param invertY defines if data must be stored with Y axis inverted
  109454. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109455. * @param compression defines the compression used (null by default)
  109456. */
  109457. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109458. /**
  109459. * Updates the raw cube texture.
  109460. * @param data defines the data to store
  109461. * @param format defines the data format
  109462. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109463. * @param invertY defines if data must be stored with Y axis inverted
  109464. * @param compression defines the compression used (null by default)
  109465. * @param level defines which level of the texture to update
  109466. */
  109467. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109468. /**
  109469. * Updates a raw cube texture with RGBD encoded data.
  109470. * @param data defines the array of data [mipmap][face] to use to create each face
  109471. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109472. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109473. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109474. * @returns a promsie that resolves when the operation is complete
  109475. */
  109476. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109477. /**
  109478. * Clones the raw cube texture.
  109479. * @return a new cube texture
  109480. */
  109481. clone(): CubeTexture;
  109482. /** @hidden */
  109483. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109484. }
  109485. }
  109486. declare module BABYLON {
  109487. /**
  109488. * Class used to store 3D textures containing user data
  109489. */
  109490. export class RawTexture3D extends Texture {
  109491. /** Gets or sets the texture format to use */
  109492. format: number;
  109493. private _engine;
  109494. /**
  109495. * Create a new RawTexture3D
  109496. * @param data defines the data of the texture
  109497. * @param width defines the width of the texture
  109498. * @param height defines the height of the texture
  109499. * @param depth defines the depth of the texture
  109500. * @param format defines the texture format to use
  109501. * @param scene defines the hosting scene
  109502. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109503. * @param invertY defines if texture must be stored with Y axis inverted
  109504. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109505. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109506. */
  109507. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109508. /** Gets or sets the texture format to use */
  109509. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109510. /**
  109511. * Update the texture with new data
  109512. * @param data defines the data to store in the texture
  109513. */
  109514. update(data: ArrayBufferView): void;
  109515. }
  109516. }
  109517. declare module BABYLON {
  109518. /**
  109519. * Creates a refraction texture used by refraction channel of the standard material.
  109520. * It is like a mirror but to see through a material.
  109521. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109522. */
  109523. export class RefractionTexture extends RenderTargetTexture {
  109524. /**
  109525. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109526. * 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.
  109527. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109528. */
  109529. refractionPlane: Plane;
  109530. /**
  109531. * Define how deep under the surface we should see.
  109532. */
  109533. depth: number;
  109534. /**
  109535. * Creates a refraction texture used by refraction channel of the standard material.
  109536. * It is like a mirror but to see through a material.
  109537. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109538. * @param name Define the texture name
  109539. * @param size Define the size of the underlying texture
  109540. * @param scene Define the scene the refraction belongs to
  109541. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109542. */
  109543. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109544. /**
  109545. * Clone the refraction texture.
  109546. * @returns the cloned texture
  109547. */
  109548. clone(): RefractionTexture;
  109549. /**
  109550. * Serialize the texture to a JSON representation you could use in Parse later on
  109551. * @returns the serialized JSON representation
  109552. */
  109553. serialize(): any;
  109554. }
  109555. }
  109556. declare module BABYLON {
  109557. /**
  109558. * Defines the options related to the creation of an HtmlElementTexture
  109559. */
  109560. export interface IHtmlElementTextureOptions {
  109561. /**
  109562. * Defines wether mip maps should be created or not.
  109563. */
  109564. generateMipMaps?: boolean;
  109565. /**
  109566. * Defines the sampling mode of the texture.
  109567. */
  109568. samplingMode?: number;
  109569. /**
  109570. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109571. */
  109572. engine: Nullable<Engine>;
  109573. /**
  109574. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109575. */
  109576. scene: Nullable<Scene>;
  109577. }
  109578. /**
  109579. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109580. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109581. * is automatically managed.
  109582. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109583. * in your application.
  109584. *
  109585. * As the update is not automatic, you need to call them manually.
  109586. */
  109587. export class HtmlElementTexture extends BaseTexture {
  109588. /**
  109589. * The texture URL.
  109590. */
  109591. element: HTMLVideoElement | HTMLCanvasElement;
  109592. private static readonly DefaultOptions;
  109593. private _textureMatrix;
  109594. private _engine;
  109595. private _isVideo;
  109596. private _generateMipMaps;
  109597. private _samplingMode;
  109598. /**
  109599. * Instantiates a HtmlElementTexture from the following parameters.
  109600. *
  109601. * @param name Defines the name of the texture
  109602. * @param element Defines the video or canvas the texture is filled with
  109603. * @param options Defines the other none mandatory texture creation options
  109604. */
  109605. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109606. private _createInternalTexture;
  109607. /**
  109608. * Returns the texture matrix used in most of the material.
  109609. */
  109610. getTextureMatrix(): Matrix;
  109611. /**
  109612. * Updates the content of the texture.
  109613. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109614. */
  109615. update(invertY?: Nullable<boolean>): void;
  109616. }
  109617. }
  109618. declare module BABYLON {
  109619. /**
  109620. * Helper class to push actions to a pool of workers.
  109621. */
  109622. export class WorkerPool implements IDisposable {
  109623. private _workerInfos;
  109624. private _pendingActions;
  109625. /**
  109626. * Constructor
  109627. * @param workers Array of workers to use for actions
  109628. */
  109629. constructor(workers: Array<Worker>);
  109630. /**
  109631. * Terminates all workers and clears any pending actions.
  109632. */
  109633. dispose(): void;
  109634. /**
  109635. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109636. * pended until a worker has completed its action.
  109637. * @param action The action to perform. Call onComplete when the action is complete.
  109638. */
  109639. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109640. private _execute;
  109641. }
  109642. }
  109643. declare module BABYLON {
  109644. /**
  109645. * Configuration for Draco compression
  109646. */
  109647. export interface IDracoCompressionConfiguration {
  109648. /**
  109649. * Configuration for the decoder.
  109650. */
  109651. decoder?: {
  109652. /**
  109653. * The url to the WebAssembly module.
  109654. */
  109655. wasmUrl?: string;
  109656. /**
  109657. * The url to the WebAssembly binary.
  109658. */
  109659. wasmBinaryUrl?: string;
  109660. /**
  109661. * The url to the fallback JavaScript module.
  109662. */
  109663. fallbackUrl?: string;
  109664. };
  109665. }
  109666. /**
  109667. * Draco compression (https://google.github.io/draco/)
  109668. *
  109669. * This class wraps the Draco module.
  109670. *
  109671. * **Encoder**
  109672. *
  109673. * The encoder is not currently implemented.
  109674. *
  109675. * **Decoder**
  109676. *
  109677. * 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.
  109678. *
  109679. * To update the configuration, use the following code:
  109680. * ```javascript
  109681. * DracoCompression.Configuration = {
  109682. * decoder: {
  109683. * wasmUrl: "<url to the WebAssembly library>",
  109684. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109685. * fallbackUrl: "<url to the fallback JavaScript library>",
  109686. * }
  109687. * };
  109688. * ```
  109689. *
  109690. * 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.
  109691. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109692. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  109693. *
  109694. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  109695. * ```javascript
  109696. * var dracoCompression = new DracoCompression();
  109697. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  109698. * [VertexBuffer.PositionKind]: 0
  109699. * });
  109700. * ```
  109701. *
  109702. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109703. */
  109704. export class DracoCompression implements IDisposable {
  109705. private _workerPoolPromise;
  109706. /**
  109707. * The configuration. Defaults to the following urls:
  109708. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109709. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109710. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109711. */
  109712. static Configuration: IDracoCompressionConfiguration;
  109713. /**
  109714. * Returns true if the decoder is available.
  109715. */
  109716. static readonly DecoderAvailable: boolean;
  109717. /**
  109718. * Default number of workers to create when creating the draco compression object.
  109719. */
  109720. static DefaultNumWorkers: number;
  109721. private static GetDefaultNumWorkers;
  109722. private static _Default;
  109723. /**
  109724. * Default instance for the draco compression object.
  109725. */
  109726. static readonly Default: DracoCompression;
  109727. /**
  109728. * Constructor
  109729. * @param numWorkers The number of workers for async operations
  109730. */
  109731. constructor(numWorkers?: number);
  109732. /**
  109733. * Stop all async operations and release resources.
  109734. */
  109735. dispose(): void;
  109736. /**
  109737. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109738. * @returns a promise that resolves when ready
  109739. */
  109740. whenReadyAsync(): Promise<void>;
  109741. /**
  109742. * Decode Draco compressed mesh data to vertex data.
  109743. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109744. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109745. * @returns A promise that resolves with the decoded vertex data
  109746. */
  109747. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109748. [kind: string]: number;
  109749. }): Promise<VertexData>;
  109750. /**
  109751. * The worker function that gets converted to a blob url to pass into a worker.
  109752. */
  109753. private static _Worker;
  109754. private _loadDecoderWasmBinaryAsync;
  109755. }
  109756. }
  109757. declare module BABYLON {
  109758. /**
  109759. * Class for building Constructive Solid Geometry
  109760. */
  109761. export class CSG {
  109762. private polygons;
  109763. /**
  109764. * The world matrix
  109765. */
  109766. matrix: Matrix;
  109767. /**
  109768. * Stores the position
  109769. */
  109770. position: Vector3;
  109771. /**
  109772. * Stores the rotation
  109773. */
  109774. rotation: Vector3;
  109775. /**
  109776. * Stores the rotation quaternion
  109777. */
  109778. rotationQuaternion: Nullable<Quaternion>;
  109779. /**
  109780. * Stores the scaling vector
  109781. */
  109782. scaling: Vector3;
  109783. /**
  109784. * Convert the Mesh to CSG
  109785. * @param mesh The Mesh to convert to CSG
  109786. * @returns A new CSG from the Mesh
  109787. */
  109788. static FromMesh(mesh: Mesh): CSG;
  109789. /**
  109790. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109791. * @param polygons Polygons used to construct a CSG solid
  109792. */
  109793. private static FromPolygons;
  109794. /**
  109795. * Clones, or makes a deep copy, of the CSG
  109796. * @returns A new CSG
  109797. */
  109798. clone(): CSG;
  109799. /**
  109800. * Unions this CSG with another CSG
  109801. * @param csg The CSG to union against this CSG
  109802. * @returns The unioned CSG
  109803. */
  109804. union(csg: CSG): CSG;
  109805. /**
  109806. * Unions this CSG with another CSG in place
  109807. * @param csg The CSG to union against this CSG
  109808. */
  109809. unionInPlace(csg: CSG): void;
  109810. /**
  109811. * Subtracts this CSG with another CSG
  109812. * @param csg The CSG to subtract against this CSG
  109813. * @returns A new CSG
  109814. */
  109815. subtract(csg: CSG): CSG;
  109816. /**
  109817. * Subtracts this CSG with another CSG in place
  109818. * @param csg The CSG to subtact against this CSG
  109819. */
  109820. subtractInPlace(csg: CSG): void;
  109821. /**
  109822. * Intersect this CSG with another CSG
  109823. * @param csg The CSG to intersect against this CSG
  109824. * @returns A new CSG
  109825. */
  109826. intersect(csg: CSG): CSG;
  109827. /**
  109828. * Intersects this CSG with another CSG in place
  109829. * @param csg The CSG to intersect against this CSG
  109830. */
  109831. intersectInPlace(csg: CSG): void;
  109832. /**
  109833. * Return a new CSG solid with solid and empty space switched. This solid is
  109834. * not modified.
  109835. * @returns A new CSG solid with solid and empty space switched
  109836. */
  109837. inverse(): CSG;
  109838. /**
  109839. * Inverses the CSG in place
  109840. */
  109841. inverseInPlace(): void;
  109842. /**
  109843. * This is used to keep meshes transformations so they can be restored
  109844. * when we build back a Babylon Mesh
  109845. * NB : All CSG operations are performed in world coordinates
  109846. * @param csg The CSG to copy the transform attributes from
  109847. * @returns This CSG
  109848. */
  109849. copyTransformAttributes(csg: CSG): CSG;
  109850. /**
  109851. * Build Raw mesh from CSG
  109852. * Coordinates here are in world space
  109853. * @param name The name of the mesh geometry
  109854. * @param scene The Scene
  109855. * @param keepSubMeshes Specifies if the submeshes should be kept
  109856. * @returns A new Mesh
  109857. */
  109858. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109859. /**
  109860. * Build Mesh from CSG taking material and transforms into account
  109861. * @param name The name of the Mesh
  109862. * @param material The material of the Mesh
  109863. * @param scene The Scene
  109864. * @param keepSubMeshes Specifies if submeshes should be kept
  109865. * @returns The new Mesh
  109866. */
  109867. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109868. }
  109869. }
  109870. declare module BABYLON {
  109871. /**
  109872. * Class used to create a trail following a mesh
  109873. */
  109874. export class TrailMesh extends Mesh {
  109875. private _generator;
  109876. private _autoStart;
  109877. private _running;
  109878. private _diameter;
  109879. private _length;
  109880. private _sectionPolygonPointsCount;
  109881. private _sectionVectors;
  109882. private _sectionNormalVectors;
  109883. private _beforeRenderObserver;
  109884. /**
  109885. * @constructor
  109886. * @param name The value used by scene.getMeshByName() to do a lookup.
  109887. * @param generator The mesh to generate a trail.
  109888. * @param scene The scene to add this mesh to.
  109889. * @param diameter Diameter of trailing mesh. Default is 1.
  109890. * @param length Length of trailing mesh. Default is 60.
  109891. * @param autoStart Automatically start trailing mesh. Default true.
  109892. */
  109893. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109894. /**
  109895. * "TrailMesh"
  109896. * @returns "TrailMesh"
  109897. */
  109898. getClassName(): string;
  109899. private _createMesh;
  109900. /**
  109901. * Start trailing mesh.
  109902. */
  109903. start(): void;
  109904. /**
  109905. * Stop trailing mesh.
  109906. */
  109907. stop(): void;
  109908. /**
  109909. * Update trailing mesh geometry.
  109910. */
  109911. update(): void;
  109912. /**
  109913. * Returns a new TrailMesh object.
  109914. * @param name is a string, the name given to the new mesh
  109915. * @param newGenerator use new generator object for cloned trail mesh
  109916. * @returns a new mesh
  109917. */
  109918. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109919. /**
  109920. * Serializes this trail mesh
  109921. * @param serializationObject object to write serialization to
  109922. */
  109923. serialize(serializationObject: any): void;
  109924. /**
  109925. * Parses a serialized trail mesh
  109926. * @param parsedMesh the serialized mesh
  109927. * @param scene the scene to create the trail mesh in
  109928. * @returns the created trail mesh
  109929. */
  109930. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109931. }
  109932. }
  109933. declare module BABYLON {
  109934. /**
  109935. * Class containing static functions to help procedurally build meshes
  109936. */
  109937. export class TorusKnotBuilder {
  109938. /**
  109939. * Creates a torus knot mesh
  109940. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109941. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109942. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109943. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109947. * @param name defines the name of the mesh
  109948. * @param options defines the options used to create the mesh
  109949. * @param scene defines the hosting scene
  109950. * @returns the torus knot mesh
  109951. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109952. */
  109953. static CreateTorusKnot(name: string, options: {
  109954. radius?: number;
  109955. tube?: number;
  109956. radialSegments?: number;
  109957. tubularSegments?: number;
  109958. p?: number;
  109959. q?: number;
  109960. updatable?: boolean;
  109961. sideOrientation?: number;
  109962. frontUVs?: Vector4;
  109963. backUVs?: Vector4;
  109964. }, scene: any): Mesh;
  109965. }
  109966. }
  109967. declare module BABYLON {
  109968. /**
  109969. * Polygon
  109970. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109971. */
  109972. export class Polygon {
  109973. /**
  109974. * Creates a rectangle
  109975. * @param xmin bottom X coord
  109976. * @param ymin bottom Y coord
  109977. * @param xmax top X coord
  109978. * @param ymax top Y coord
  109979. * @returns points that make the resulting rectation
  109980. */
  109981. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109982. /**
  109983. * Creates a circle
  109984. * @param radius radius of circle
  109985. * @param cx scale in x
  109986. * @param cy scale in y
  109987. * @param numberOfSides number of sides that make up the circle
  109988. * @returns points that make the resulting circle
  109989. */
  109990. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109991. /**
  109992. * Creates a polygon from input string
  109993. * @param input Input polygon data
  109994. * @returns the parsed points
  109995. */
  109996. static Parse(input: string): Vector2[];
  109997. /**
  109998. * Starts building a polygon from x and y coordinates
  109999. * @param x x coordinate
  110000. * @param y y coordinate
  110001. * @returns the started path2
  110002. */
  110003. static StartingAt(x: number, y: number): Path2;
  110004. }
  110005. /**
  110006. * Builds a polygon
  110007. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  110008. */
  110009. export class PolygonMeshBuilder {
  110010. private _points;
  110011. private _outlinepoints;
  110012. private _holes;
  110013. private _name;
  110014. private _scene;
  110015. private _epoints;
  110016. private _eholes;
  110017. private _addToepoint;
  110018. /**
  110019. * Babylon reference to the earcut plugin.
  110020. */
  110021. bjsEarcut: any;
  110022. /**
  110023. * Creates a PolygonMeshBuilder
  110024. * @param name name of the builder
  110025. * @param contours Path of the polygon
  110026. * @param scene scene to add to when creating the mesh
  110027. * @param earcutInjection can be used to inject your own earcut reference
  110028. */
  110029. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  110030. /**
  110031. * Adds a whole within the polygon
  110032. * @param hole Array of points defining the hole
  110033. * @returns this
  110034. */
  110035. addHole(hole: Vector2[]): PolygonMeshBuilder;
  110036. /**
  110037. * Creates the polygon
  110038. * @param updatable If the mesh should be updatable
  110039. * @param depth The depth of the mesh created
  110040. * @returns the created mesh
  110041. */
  110042. build(updatable?: boolean, depth?: number): Mesh;
  110043. /**
  110044. * Creates the polygon
  110045. * @param depth The depth of the mesh created
  110046. * @returns the created VertexData
  110047. */
  110048. buildVertexData(depth?: number): VertexData;
  110049. /**
  110050. * Adds a side to the polygon
  110051. * @param positions points that make the polygon
  110052. * @param normals normals of the polygon
  110053. * @param uvs uvs of the polygon
  110054. * @param indices indices of the polygon
  110055. * @param bounds bounds of the polygon
  110056. * @param points points of the polygon
  110057. * @param depth depth of the polygon
  110058. * @param flip flip of the polygon
  110059. */
  110060. private addSide;
  110061. }
  110062. }
  110063. declare module BABYLON {
  110064. /**
  110065. * Class containing static functions to help procedurally build meshes
  110066. */
  110067. export class PolygonBuilder {
  110068. /**
  110069. * Creates a polygon mesh
  110070. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110071. * * 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
  110072. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110075. * * Remember you can only change the shape positions, not their number when updating a polygon
  110076. * @param name defines the name of the mesh
  110077. * @param options defines the options used to create the mesh
  110078. * @param scene defines the hosting scene
  110079. * @param earcutInjection can be used to inject your own earcut reference
  110080. * @returns the polygon mesh
  110081. */
  110082. static CreatePolygon(name: string, options: {
  110083. shape: Vector3[];
  110084. holes?: Vector3[][];
  110085. depth?: number;
  110086. faceUV?: Vector4[];
  110087. faceColors?: Color4[];
  110088. updatable?: boolean;
  110089. sideOrientation?: number;
  110090. frontUVs?: Vector4;
  110091. backUVs?: Vector4;
  110092. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110093. /**
  110094. * Creates an extruded polygon mesh, with depth in the Y direction.
  110095. * * 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)
  110096. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110097. * @param name defines the name of the mesh
  110098. * @param options defines the options used to create the mesh
  110099. * @param scene defines the hosting scene
  110100. * @param earcutInjection can be used to inject your own earcut reference
  110101. * @returns the polygon mesh
  110102. */
  110103. static ExtrudePolygon(name: string, options: {
  110104. shape: Vector3[];
  110105. holes?: Vector3[][];
  110106. depth?: number;
  110107. faceUV?: Vector4[];
  110108. faceColors?: Color4[];
  110109. updatable?: boolean;
  110110. sideOrientation?: number;
  110111. frontUVs?: Vector4;
  110112. backUVs?: Vector4;
  110113. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110114. }
  110115. }
  110116. declare module BABYLON {
  110117. /**
  110118. * Class containing static functions to help procedurally build meshes
  110119. */
  110120. export class LatheBuilder {
  110121. /**
  110122. * Creates lathe mesh.
  110123. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110124. * * 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
  110125. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110126. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110127. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110128. * * 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
  110129. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110130. * * 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
  110131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110133. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110135. * @param name defines the name of the mesh
  110136. * @param options defines the options used to create the mesh
  110137. * @param scene defines the hosting scene
  110138. * @returns the lathe mesh
  110139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110140. */
  110141. static CreateLathe(name: string, options: {
  110142. shape: Vector3[];
  110143. radius?: number;
  110144. tessellation?: number;
  110145. clip?: number;
  110146. arc?: number;
  110147. closed?: boolean;
  110148. updatable?: boolean;
  110149. sideOrientation?: number;
  110150. frontUVs?: Vector4;
  110151. backUVs?: Vector4;
  110152. cap?: number;
  110153. invertUV?: boolean;
  110154. }, scene?: Nullable<Scene>): Mesh;
  110155. }
  110156. }
  110157. declare module BABYLON {
  110158. /**
  110159. * Class containing static functions to help procedurally build meshes
  110160. */
  110161. export class TubeBuilder {
  110162. /**
  110163. * Creates a tube mesh.
  110164. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110165. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110166. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110167. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110168. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110169. * * 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)
  110170. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110171. * * 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
  110172. * * 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
  110173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110175. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110177. * @param name defines the name of the mesh
  110178. * @param options defines the options used to create the mesh
  110179. * @param scene defines the hosting scene
  110180. * @returns the tube mesh
  110181. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110182. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110183. */
  110184. static CreateTube(name: string, options: {
  110185. path: Vector3[];
  110186. radius?: number;
  110187. tessellation?: number;
  110188. radiusFunction?: {
  110189. (i: number, distance: number): number;
  110190. };
  110191. cap?: number;
  110192. arc?: number;
  110193. updatable?: boolean;
  110194. sideOrientation?: number;
  110195. frontUVs?: Vector4;
  110196. backUVs?: Vector4;
  110197. instance?: Mesh;
  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 IcoSphereBuilder {
  110207. /**
  110208. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110209. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110210. * * 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`)
  110211. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110212. * * 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
  110213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110216. * @param name defines the name of the mesh
  110217. * @param options defines the options used to create the mesh
  110218. * @param scene defines the hosting scene
  110219. * @returns the icosahedron mesh
  110220. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110221. */
  110222. static CreateIcoSphere(name: string, options: {
  110223. radius?: number;
  110224. radiusX?: number;
  110225. radiusY?: number;
  110226. radiusZ?: number;
  110227. flat?: boolean;
  110228. subdivisions?: number;
  110229. sideOrientation?: number;
  110230. frontUVs?: Vector4;
  110231. backUVs?: Vector4;
  110232. updatable?: boolean;
  110233. }, scene?: Nullable<Scene>): Mesh;
  110234. }
  110235. }
  110236. declare module BABYLON {
  110237. /**
  110238. * Class containing static functions to help procedurally build meshes
  110239. */
  110240. export class DecalBuilder {
  110241. /**
  110242. * Creates a decal mesh.
  110243. * 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
  110244. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110245. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110246. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110247. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110248. * @param name defines the name of the mesh
  110249. * @param sourceMesh defines the mesh where the decal must be applied
  110250. * @param options defines the options used to create the mesh
  110251. * @param scene defines the hosting scene
  110252. * @returns the decal mesh
  110253. * @see https://doc.babylonjs.com/how_to/decals
  110254. */
  110255. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110256. position?: Vector3;
  110257. normal?: Vector3;
  110258. size?: Vector3;
  110259. angle?: number;
  110260. }): Mesh;
  110261. }
  110262. }
  110263. declare module BABYLON {
  110264. /**
  110265. * Class containing static functions to help procedurally build meshes
  110266. */
  110267. export class MeshBuilder {
  110268. /**
  110269. * Creates a box mesh
  110270. * * The parameter `size` sets the size (float) of each box side (default 1)
  110271. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110272. * * 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)
  110273. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110277. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110278. * @param name defines the name of the mesh
  110279. * @param options defines the options used to create the mesh
  110280. * @param scene defines the hosting scene
  110281. * @returns the box mesh
  110282. */
  110283. static CreateBox(name: string, options: {
  110284. size?: number;
  110285. width?: number;
  110286. height?: number;
  110287. depth?: number;
  110288. faceUV?: Vector4[];
  110289. faceColors?: Color4[];
  110290. sideOrientation?: number;
  110291. frontUVs?: Vector4;
  110292. backUVs?: Vector4;
  110293. updatable?: boolean;
  110294. }, scene?: Nullable<Scene>): Mesh;
  110295. /**
  110296. * Creates a sphere mesh
  110297. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110298. * * 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`)
  110299. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110300. * * 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
  110301. * * 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)
  110302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110305. * @param name defines the name of the mesh
  110306. * @param options defines the options used to create the mesh
  110307. * @param scene defines the hosting scene
  110308. * @returns the sphere mesh
  110309. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110310. */
  110311. static CreateSphere(name: string, options: {
  110312. segments?: number;
  110313. diameter?: number;
  110314. diameterX?: number;
  110315. diameterY?: number;
  110316. diameterZ?: number;
  110317. arc?: number;
  110318. slice?: number;
  110319. sideOrientation?: number;
  110320. frontUVs?: Vector4;
  110321. backUVs?: Vector4;
  110322. updatable?: boolean;
  110323. }, scene?: Nullable<Scene>): Mesh;
  110324. /**
  110325. * Creates a plane polygonal mesh. By default, this is a disc
  110326. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110327. * * 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
  110328. * * 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
  110329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110332. * @param name defines the name of the mesh
  110333. * @param options defines the options used to create the mesh
  110334. * @param scene defines the hosting scene
  110335. * @returns the plane polygonal mesh
  110336. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110337. */
  110338. static CreateDisc(name: string, options: {
  110339. radius?: number;
  110340. tessellation?: number;
  110341. arc?: number;
  110342. updatable?: boolean;
  110343. sideOrientation?: number;
  110344. frontUVs?: Vector4;
  110345. backUVs?: Vector4;
  110346. }, scene?: Nullable<Scene>): Mesh;
  110347. /**
  110348. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110349. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110350. * * 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`)
  110351. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110352. * * 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
  110353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110356. * @param name defines the name of the mesh
  110357. * @param options defines the options used to create the mesh
  110358. * @param scene defines the hosting scene
  110359. * @returns the icosahedron mesh
  110360. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110361. */
  110362. static CreateIcoSphere(name: string, options: {
  110363. radius?: number;
  110364. radiusX?: number;
  110365. radiusY?: number;
  110366. radiusZ?: number;
  110367. flat?: boolean;
  110368. subdivisions?: number;
  110369. sideOrientation?: number;
  110370. frontUVs?: Vector4;
  110371. backUVs?: Vector4;
  110372. updatable?: boolean;
  110373. }, scene?: Nullable<Scene>): Mesh;
  110374. /**
  110375. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110376. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110377. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110378. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110379. * * 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
  110380. * * 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
  110381. * * 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
  110382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110384. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110385. * * 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
  110386. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110387. * * 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
  110388. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110390. * @param name defines the name of the mesh
  110391. * @param options defines the options used to create the mesh
  110392. * @param scene defines the hosting scene
  110393. * @returns the ribbon mesh
  110394. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110395. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110396. */
  110397. static CreateRibbon(name: string, options: {
  110398. pathArray: Vector3[][];
  110399. closeArray?: boolean;
  110400. closePath?: boolean;
  110401. offset?: number;
  110402. updatable?: boolean;
  110403. sideOrientation?: number;
  110404. frontUVs?: Vector4;
  110405. backUVs?: Vector4;
  110406. instance?: Mesh;
  110407. invertUV?: boolean;
  110408. uvs?: Vector2[];
  110409. colors?: Color4[];
  110410. }, scene?: Nullable<Scene>): Mesh;
  110411. /**
  110412. * Creates a cylinder or a cone mesh
  110413. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110414. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110415. * * 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.
  110416. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110417. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110418. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110419. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110420. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110421. * * 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).
  110422. * * 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
  110423. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110424. * * 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
  110425. * * 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.
  110426. * * If `enclose` is false, a ring surface is one element.
  110427. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110428. * * 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
  110429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110432. * @param name defines the name of the mesh
  110433. * @param options defines the options used to create the mesh
  110434. * @param scene defines the hosting scene
  110435. * @returns the cylinder mesh
  110436. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110437. */
  110438. static CreateCylinder(name: string, options: {
  110439. height?: number;
  110440. diameterTop?: number;
  110441. diameterBottom?: number;
  110442. diameter?: number;
  110443. tessellation?: number;
  110444. subdivisions?: number;
  110445. arc?: number;
  110446. faceColors?: Color4[];
  110447. faceUV?: Vector4[];
  110448. updatable?: boolean;
  110449. hasRings?: boolean;
  110450. enclose?: boolean;
  110451. sideOrientation?: number;
  110452. frontUVs?: Vector4;
  110453. backUVs?: Vector4;
  110454. }, scene?: Nullable<Scene>): Mesh;
  110455. /**
  110456. * Creates a torus mesh
  110457. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110458. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110459. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110463. * @param name defines the name of the mesh
  110464. * @param options defines the options used to create the mesh
  110465. * @param scene defines the hosting scene
  110466. * @returns the torus mesh
  110467. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110468. */
  110469. static CreateTorus(name: string, options: {
  110470. diameter?: number;
  110471. thickness?: number;
  110472. tessellation?: number;
  110473. updatable?: boolean;
  110474. sideOrientation?: number;
  110475. frontUVs?: Vector4;
  110476. backUVs?: Vector4;
  110477. }, scene?: Nullable<Scene>): Mesh;
  110478. /**
  110479. * Creates a torus knot mesh
  110480. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110481. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110482. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110483. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110487. * @param name defines the name of the mesh
  110488. * @param options defines the options used to create the mesh
  110489. * @param scene defines the hosting scene
  110490. * @returns the torus knot mesh
  110491. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110492. */
  110493. static CreateTorusKnot(name: string, options: {
  110494. radius?: number;
  110495. tube?: number;
  110496. radialSegments?: number;
  110497. tubularSegments?: number;
  110498. p?: number;
  110499. q?: number;
  110500. updatable?: boolean;
  110501. sideOrientation?: number;
  110502. frontUVs?: Vector4;
  110503. backUVs?: Vector4;
  110504. }, scene?: Nullable<Scene>): Mesh;
  110505. /**
  110506. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110507. * * 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
  110508. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110509. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110510. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110511. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110512. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110513. * * 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
  110514. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110516. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110517. * @param name defines the name of the new line system
  110518. * @param options defines the options used to create the line system
  110519. * @param scene defines the hosting scene
  110520. * @returns a new line system mesh
  110521. */
  110522. static CreateLineSystem(name: string, options: {
  110523. lines: Vector3[][];
  110524. updatable?: boolean;
  110525. instance?: Nullable<LinesMesh>;
  110526. colors?: Nullable<Color4[][]>;
  110527. useVertexAlpha?: boolean;
  110528. }, scene: Nullable<Scene>): LinesMesh;
  110529. /**
  110530. * Creates a line mesh
  110531. * 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
  110532. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110533. * * The parameter `points` is an array successive Vector3
  110534. * * 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
  110535. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110536. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110537. * * When updating an instance, remember that only point positions can change, not the number of points
  110538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110540. * @param name defines the name of the new line system
  110541. * @param options defines the options used to create the line system
  110542. * @param scene defines the hosting scene
  110543. * @returns a new line mesh
  110544. */
  110545. static CreateLines(name: string, options: {
  110546. points: Vector3[];
  110547. updatable?: boolean;
  110548. instance?: Nullable<LinesMesh>;
  110549. colors?: Color4[];
  110550. useVertexAlpha?: boolean;
  110551. }, scene?: Nullable<Scene>): LinesMesh;
  110552. /**
  110553. * Creates a dashed line mesh
  110554. * * 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
  110555. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110556. * * The parameter `points` is an array successive Vector3
  110557. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110558. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110559. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110560. * * 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
  110561. * * When updating an instance, remember that only point positions can change, not the number of points
  110562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110563. * @param name defines the name of the mesh
  110564. * @param options defines the options used to create the mesh
  110565. * @param scene defines the hosting scene
  110566. * @returns the dashed line mesh
  110567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110568. */
  110569. static CreateDashedLines(name: string, options: {
  110570. points: Vector3[];
  110571. dashSize?: number;
  110572. gapSize?: number;
  110573. dashNb?: number;
  110574. updatable?: boolean;
  110575. instance?: LinesMesh;
  110576. }, scene?: Nullable<Scene>): LinesMesh;
  110577. /**
  110578. * 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.
  110579. * * 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.
  110580. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110581. * * 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.
  110582. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110583. * * 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
  110584. * * 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
  110585. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110588. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110590. * @param name defines the name of the mesh
  110591. * @param options defines the options used to create the mesh
  110592. * @param scene defines the hosting scene
  110593. * @returns the extruded shape mesh
  110594. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110596. */
  110597. static ExtrudeShape(name: string, options: {
  110598. shape: Vector3[];
  110599. path: Vector3[];
  110600. scale?: number;
  110601. rotation?: number;
  110602. cap?: number;
  110603. updatable?: boolean;
  110604. sideOrientation?: number;
  110605. frontUVs?: Vector4;
  110606. backUVs?: Vector4;
  110607. instance?: Mesh;
  110608. invertUV?: boolean;
  110609. }, scene?: Nullable<Scene>): Mesh;
  110610. /**
  110611. * Creates an custom extruded shape mesh.
  110612. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110613. * * 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.
  110614. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110615. * * 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
  110616. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110617. * * 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
  110618. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110619. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110620. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110621. * * 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
  110622. * * 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
  110623. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110626. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110628. * @param name defines the name of the mesh
  110629. * @param options defines the options used to create the mesh
  110630. * @param scene defines the hosting scene
  110631. * @returns the custom extruded shape mesh
  110632. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110633. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110634. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110635. */
  110636. static ExtrudeShapeCustom(name: string, options: {
  110637. shape: Vector3[];
  110638. path: Vector3[];
  110639. scaleFunction?: any;
  110640. rotationFunction?: any;
  110641. ribbonCloseArray?: boolean;
  110642. ribbonClosePath?: boolean;
  110643. cap?: number;
  110644. updatable?: boolean;
  110645. sideOrientation?: number;
  110646. frontUVs?: Vector4;
  110647. backUVs?: Vector4;
  110648. instance?: Mesh;
  110649. invertUV?: boolean;
  110650. }, scene?: Nullable<Scene>): Mesh;
  110651. /**
  110652. * Creates lathe mesh.
  110653. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110654. * * 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
  110655. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110656. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110657. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110658. * * 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
  110659. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110660. * * 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
  110661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110663. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110665. * @param name defines the name of the mesh
  110666. * @param options defines the options used to create the mesh
  110667. * @param scene defines the hosting scene
  110668. * @returns the lathe mesh
  110669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110670. */
  110671. static CreateLathe(name: string, options: {
  110672. shape: Vector3[];
  110673. radius?: number;
  110674. tessellation?: number;
  110675. clip?: number;
  110676. arc?: number;
  110677. closed?: boolean;
  110678. updatable?: boolean;
  110679. sideOrientation?: number;
  110680. frontUVs?: Vector4;
  110681. backUVs?: Vector4;
  110682. cap?: number;
  110683. invertUV?: boolean;
  110684. }, scene?: Nullable<Scene>): Mesh;
  110685. /**
  110686. * Creates a plane mesh
  110687. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110688. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110689. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110693. * @param name defines the name of the mesh
  110694. * @param options defines the options used to create the mesh
  110695. * @param scene defines the hosting scene
  110696. * @returns the plane mesh
  110697. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110698. */
  110699. static CreatePlane(name: string, options: {
  110700. size?: number;
  110701. width?: number;
  110702. height?: number;
  110703. sideOrientation?: number;
  110704. frontUVs?: Vector4;
  110705. backUVs?: Vector4;
  110706. updatable?: boolean;
  110707. sourcePlane?: Plane;
  110708. }, scene?: Nullable<Scene>): Mesh;
  110709. /**
  110710. * Creates a ground mesh
  110711. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110712. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110714. * @param name defines the name of the mesh
  110715. * @param options defines the options used to create the mesh
  110716. * @param scene defines the hosting scene
  110717. * @returns the ground mesh
  110718. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110719. */
  110720. static CreateGround(name: string, options: {
  110721. width?: number;
  110722. height?: number;
  110723. subdivisions?: number;
  110724. subdivisionsX?: number;
  110725. subdivisionsY?: number;
  110726. updatable?: boolean;
  110727. }, scene?: Nullable<Scene>): Mesh;
  110728. /**
  110729. * Creates a tiled ground mesh
  110730. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110731. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110732. * * 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
  110733. * * 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
  110734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110735. * @param name defines the name of the mesh
  110736. * @param options defines the options used to create the mesh
  110737. * @param scene defines the hosting scene
  110738. * @returns the tiled ground mesh
  110739. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110740. */
  110741. static CreateTiledGround(name: string, options: {
  110742. xmin: number;
  110743. zmin: number;
  110744. xmax: number;
  110745. zmax: number;
  110746. subdivisions?: {
  110747. w: number;
  110748. h: number;
  110749. };
  110750. precision?: {
  110751. w: number;
  110752. h: number;
  110753. };
  110754. updatable?: boolean;
  110755. }, scene?: Nullable<Scene>): Mesh;
  110756. /**
  110757. * Creates a ground mesh from a height map
  110758. * * The parameter `url` sets the URL of the height map image resource.
  110759. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110760. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110761. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110762. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110763. * * 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.
  110764. * * 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).
  110765. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110767. * @param name defines the name of the mesh
  110768. * @param url defines the url to the height map
  110769. * @param options defines the options used to create the mesh
  110770. * @param scene defines the hosting scene
  110771. * @returns the ground mesh
  110772. * @see https://doc.babylonjs.com/babylon101/height_map
  110773. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110774. */
  110775. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110776. width?: number;
  110777. height?: number;
  110778. subdivisions?: number;
  110779. minHeight?: number;
  110780. maxHeight?: number;
  110781. colorFilter?: Color3;
  110782. alphaFilter?: number;
  110783. updatable?: boolean;
  110784. onReady?: (mesh: GroundMesh) => void;
  110785. }, scene?: Nullable<Scene>): GroundMesh;
  110786. /**
  110787. * Creates a polygon mesh
  110788. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110789. * * 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
  110790. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110793. * * Remember you can only change the shape positions, not their number when updating a polygon
  110794. * @param name defines the name of the mesh
  110795. * @param options defines the options used to create the mesh
  110796. * @param scene defines the hosting scene
  110797. * @param earcutInjection can be used to inject your own earcut reference
  110798. * @returns the polygon mesh
  110799. */
  110800. static CreatePolygon(name: string, options: {
  110801. shape: Vector3[];
  110802. holes?: Vector3[][];
  110803. depth?: number;
  110804. faceUV?: Vector4[];
  110805. faceColors?: Color4[];
  110806. updatable?: boolean;
  110807. sideOrientation?: number;
  110808. frontUVs?: Vector4;
  110809. backUVs?: Vector4;
  110810. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110811. /**
  110812. * Creates an extruded polygon mesh, with depth in the Y direction.
  110813. * * 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)
  110814. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110815. * @param name defines the name of the mesh
  110816. * @param options defines the options used to create the mesh
  110817. * @param scene defines the hosting scene
  110818. * @param earcutInjection can be used to inject your own earcut reference
  110819. * @returns the polygon mesh
  110820. */
  110821. static ExtrudePolygon(name: string, options: {
  110822. shape: Vector3[];
  110823. holes?: Vector3[][];
  110824. depth?: number;
  110825. faceUV?: Vector4[];
  110826. faceColors?: Color4[];
  110827. updatable?: boolean;
  110828. sideOrientation?: number;
  110829. frontUVs?: Vector4;
  110830. backUVs?: Vector4;
  110831. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110832. /**
  110833. * Creates a tube mesh.
  110834. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110835. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110836. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110837. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110838. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110839. * * 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)
  110840. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110841. * * 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
  110842. * * 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
  110843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110845. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110847. * @param name defines the name of the mesh
  110848. * @param options defines the options used to create the mesh
  110849. * @param scene defines the hosting scene
  110850. * @returns the tube mesh
  110851. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110852. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110853. */
  110854. static CreateTube(name: string, options: {
  110855. path: Vector3[];
  110856. radius?: number;
  110857. tessellation?: number;
  110858. radiusFunction?: {
  110859. (i: number, distance: number): number;
  110860. };
  110861. cap?: number;
  110862. arc?: number;
  110863. updatable?: boolean;
  110864. sideOrientation?: number;
  110865. frontUVs?: Vector4;
  110866. backUVs?: Vector4;
  110867. instance?: Mesh;
  110868. invertUV?: boolean;
  110869. }, scene?: Nullable<Scene>): Mesh;
  110870. /**
  110871. * Creates a polyhedron mesh
  110872. * * 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
  110873. * * The parameter `size` (positive float, default 1) sets the polygon size
  110874. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110875. * * 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`
  110876. * * 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
  110877. * * 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)`)
  110878. * * 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
  110879. * * 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
  110880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110883. * @param name defines the name of the mesh
  110884. * @param options defines the options used to create the mesh
  110885. * @param scene defines the hosting scene
  110886. * @returns the polyhedron mesh
  110887. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110888. */
  110889. static CreatePolyhedron(name: string, options: {
  110890. type?: number;
  110891. size?: number;
  110892. sizeX?: number;
  110893. sizeY?: number;
  110894. sizeZ?: number;
  110895. custom?: any;
  110896. faceUV?: Vector4[];
  110897. faceColors?: Color4[];
  110898. flat?: boolean;
  110899. updatable?: boolean;
  110900. sideOrientation?: number;
  110901. frontUVs?: Vector4;
  110902. backUVs?: Vector4;
  110903. }, scene?: Nullable<Scene>): Mesh;
  110904. /**
  110905. * Creates a decal mesh.
  110906. * 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
  110907. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110908. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110909. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110910. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110911. * @param name defines the name of the mesh
  110912. * @param sourceMesh defines the mesh where the decal must be applied
  110913. * @param options defines the options used to create the mesh
  110914. * @param scene defines the hosting scene
  110915. * @returns the decal mesh
  110916. * @see https://doc.babylonjs.com/how_to/decals
  110917. */
  110918. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110919. position?: Vector3;
  110920. normal?: Vector3;
  110921. size?: Vector3;
  110922. angle?: number;
  110923. }): Mesh;
  110924. }
  110925. }
  110926. declare module BABYLON {
  110927. /**
  110928. * A simplifier interface for future simplification implementations
  110929. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110930. */
  110931. export interface ISimplifier {
  110932. /**
  110933. * Simplification of a given mesh according to the given settings.
  110934. * Since this requires computation, it is assumed that the function runs async.
  110935. * @param settings The settings of the simplification, including quality and distance
  110936. * @param successCallback A callback that will be called after the mesh was simplified.
  110937. * @param errorCallback in case of an error, this callback will be called. optional.
  110938. */
  110939. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110940. }
  110941. /**
  110942. * Expected simplification settings.
  110943. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110944. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110945. */
  110946. export interface ISimplificationSettings {
  110947. /**
  110948. * Gets or sets the expected quality
  110949. */
  110950. quality: number;
  110951. /**
  110952. * Gets or sets the distance when this optimized version should be used
  110953. */
  110954. distance: number;
  110955. /**
  110956. * Gets an already optimized mesh
  110957. */
  110958. optimizeMesh?: boolean;
  110959. }
  110960. /**
  110961. * Class used to specify simplification options
  110962. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110963. */
  110964. export class SimplificationSettings implements ISimplificationSettings {
  110965. /** expected quality */
  110966. quality: number;
  110967. /** distance when this optimized version should be used */
  110968. distance: number;
  110969. /** already optimized mesh */
  110970. optimizeMesh?: boolean | undefined;
  110971. /**
  110972. * Creates a SimplificationSettings
  110973. * @param quality expected quality
  110974. * @param distance distance when this optimized version should be used
  110975. * @param optimizeMesh already optimized mesh
  110976. */
  110977. constructor(
  110978. /** expected quality */
  110979. quality: number,
  110980. /** distance when this optimized version should be used */
  110981. distance: number,
  110982. /** already optimized mesh */
  110983. optimizeMesh?: boolean | undefined);
  110984. }
  110985. /**
  110986. * Interface used to define a simplification task
  110987. */
  110988. export interface ISimplificationTask {
  110989. /**
  110990. * Array of settings
  110991. */
  110992. settings: Array<ISimplificationSettings>;
  110993. /**
  110994. * Simplification type
  110995. */
  110996. simplificationType: SimplificationType;
  110997. /**
  110998. * Mesh to simplify
  110999. */
  111000. mesh: Mesh;
  111001. /**
  111002. * Callback called on success
  111003. */
  111004. successCallback?: () => void;
  111005. /**
  111006. * Defines if parallel processing can be used
  111007. */
  111008. parallelProcessing: boolean;
  111009. }
  111010. /**
  111011. * Queue used to order the simplification tasks
  111012. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111013. */
  111014. export class SimplificationQueue {
  111015. private _simplificationArray;
  111016. /**
  111017. * Gets a boolean indicating that the process is still running
  111018. */
  111019. running: boolean;
  111020. /**
  111021. * Creates a new queue
  111022. */
  111023. constructor();
  111024. /**
  111025. * Adds a new simplification task
  111026. * @param task defines a task to add
  111027. */
  111028. addTask(task: ISimplificationTask): void;
  111029. /**
  111030. * Execute next task
  111031. */
  111032. executeNext(): void;
  111033. /**
  111034. * Execute a simplification task
  111035. * @param task defines the task to run
  111036. */
  111037. runSimplification(task: ISimplificationTask): void;
  111038. private getSimplifier;
  111039. }
  111040. /**
  111041. * The implemented types of simplification
  111042. * At the moment only Quadratic Error Decimation is implemented
  111043. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111044. */
  111045. export enum SimplificationType {
  111046. /** Quadratic error decimation */
  111047. QUADRATIC = 0
  111048. }
  111049. }
  111050. declare module BABYLON {
  111051. interface Scene {
  111052. /** @hidden (Backing field) */
  111053. _simplificationQueue: SimplificationQueue;
  111054. /**
  111055. * Gets or sets the simplification queue attached to the scene
  111056. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111057. */
  111058. simplificationQueue: SimplificationQueue;
  111059. }
  111060. interface Mesh {
  111061. /**
  111062. * Simplify the mesh according to the given array of settings.
  111063. * Function will return immediately and will simplify async
  111064. * @param settings a collection of simplification settings
  111065. * @param parallelProcessing should all levels calculate parallel or one after the other
  111066. * @param simplificationType the type of simplification to run
  111067. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  111068. * @returns the current mesh
  111069. */
  111070. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  111071. }
  111072. /**
  111073. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  111074. * created in a scene
  111075. */
  111076. export class SimplicationQueueSceneComponent implements ISceneComponent {
  111077. /**
  111078. * The component name helpfull to identify the component in the list of scene components.
  111079. */
  111080. readonly name: string;
  111081. /**
  111082. * The scene the component belongs to.
  111083. */
  111084. scene: Scene;
  111085. /**
  111086. * Creates a new instance of the component for the given scene
  111087. * @param scene Defines the scene to register the component in
  111088. */
  111089. constructor(scene: Scene);
  111090. /**
  111091. * Registers the component in a given scene
  111092. */
  111093. register(): void;
  111094. /**
  111095. * Rebuilds the elements related to this component in case of
  111096. * context lost for instance.
  111097. */
  111098. rebuild(): void;
  111099. /**
  111100. * Disposes the component and the associated ressources
  111101. */
  111102. dispose(): void;
  111103. private _beforeCameraUpdate;
  111104. }
  111105. }
  111106. declare module BABYLON {
  111107. /**
  111108. * Class used to enable access to IndexedDB
  111109. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111110. */
  111111. export class Database implements IOfflineProvider {
  111112. private _callbackManifestChecked;
  111113. private _currentSceneUrl;
  111114. private _db;
  111115. private _enableSceneOffline;
  111116. private _enableTexturesOffline;
  111117. private _manifestVersionFound;
  111118. private _mustUpdateRessources;
  111119. private _hasReachedQuota;
  111120. private _isSupported;
  111121. private _idbFactory;
  111122. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  111123. private static IsUASupportingBlobStorage;
  111124. /**
  111125. * Gets a boolean indicating if Database storate is enabled (off by default)
  111126. */
  111127. static IDBStorageEnabled: boolean;
  111128. /**
  111129. * Gets a boolean indicating if scene must be saved in the database
  111130. */
  111131. readonly enableSceneOffline: boolean;
  111132. /**
  111133. * Gets a boolean indicating if textures must be saved in the database
  111134. */
  111135. readonly enableTexturesOffline: boolean;
  111136. /**
  111137. * Creates a new Database
  111138. * @param urlToScene defines the url to load the scene
  111139. * @param callbackManifestChecked defines the callback to use when manifest is checked
  111140. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  111141. */
  111142. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  111143. private static _ParseURL;
  111144. private static _ReturnFullUrlLocation;
  111145. private _checkManifestFile;
  111146. /**
  111147. * Open the database and make it available
  111148. * @param successCallback defines the callback to call on success
  111149. * @param errorCallback defines the callback to call on error
  111150. */
  111151. open(successCallback: () => void, errorCallback: () => void): void;
  111152. /**
  111153. * Loads an image from the database
  111154. * @param url defines the url to load from
  111155. * @param image defines the target DOM image
  111156. */
  111157. loadImage(url: string, image: HTMLImageElement): void;
  111158. private _loadImageFromDBAsync;
  111159. private _saveImageIntoDBAsync;
  111160. private _checkVersionFromDB;
  111161. private _loadVersionFromDBAsync;
  111162. private _saveVersionIntoDBAsync;
  111163. /**
  111164. * Loads a file from database
  111165. * @param url defines the URL to load from
  111166. * @param sceneLoaded defines a callback to call on success
  111167. * @param progressCallBack defines a callback to call when progress changed
  111168. * @param errorCallback defines a callback to call on error
  111169. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  111170. */
  111171. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  111172. private _loadFileAsync;
  111173. private _saveFileAsync;
  111174. /**
  111175. * Validates if xhr data is correct
  111176. * @param xhr defines the request to validate
  111177. * @param dataType defines the expected data type
  111178. * @returns true if data is correct
  111179. */
  111180. private static _ValidateXHRData;
  111181. }
  111182. }
  111183. declare module BABYLON {
  111184. /** @hidden */
  111185. export var gpuUpdateParticlesPixelShader: {
  111186. name: string;
  111187. shader: string;
  111188. };
  111189. }
  111190. declare module BABYLON {
  111191. /** @hidden */
  111192. export var gpuUpdateParticlesVertexShader: {
  111193. name: string;
  111194. shader: string;
  111195. };
  111196. }
  111197. declare module BABYLON {
  111198. /** @hidden */
  111199. export var clipPlaneFragmentDeclaration2: {
  111200. name: string;
  111201. shader: string;
  111202. };
  111203. }
  111204. declare module BABYLON {
  111205. /** @hidden */
  111206. export var gpuRenderParticlesPixelShader: {
  111207. name: string;
  111208. shader: string;
  111209. };
  111210. }
  111211. declare module BABYLON {
  111212. /** @hidden */
  111213. export var clipPlaneVertexDeclaration2: {
  111214. name: string;
  111215. shader: string;
  111216. };
  111217. }
  111218. declare module BABYLON {
  111219. /** @hidden */
  111220. export var gpuRenderParticlesVertexShader: {
  111221. name: string;
  111222. shader: string;
  111223. };
  111224. }
  111225. declare module BABYLON {
  111226. /**
  111227. * This represents a GPU particle system in Babylon
  111228. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  111229. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  111230. */
  111231. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  111232. /**
  111233. * The layer mask we are rendering the particles through.
  111234. */
  111235. layerMask: number;
  111236. private _capacity;
  111237. private _activeCount;
  111238. private _currentActiveCount;
  111239. private _accumulatedCount;
  111240. private _renderEffect;
  111241. private _updateEffect;
  111242. private _buffer0;
  111243. private _buffer1;
  111244. private _spriteBuffer;
  111245. private _updateVAO;
  111246. private _renderVAO;
  111247. private _targetIndex;
  111248. private _sourceBuffer;
  111249. private _targetBuffer;
  111250. private _engine;
  111251. private _currentRenderId;
  111252. private _started;
  111253. private _stopped;
  111254. private _timeDelta;
  111255. private _randomTexture;
  111256. private _randomTexture2;
  111257. private _attributesStrideSize;
  111258. private _updateEffectOptions;
  111259. private _randomTextureSize;
  111260. private _actualFrame;
  111261. private readonly _rawTextureWidth;
  111262. /**
  111263. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  111264. */
  111265. static readonly IsSupported: boolean;
  111266. /**
  111267. * An event triggered when the system is disposed.
  111268. */
  111269. onDisposeObservable: Observable<GPUParticleSystem>;
  111270. /**
  111271. * Gets the maximum number of particles active at the same time.
  111272. * @returns The max number of active particles.
  111273. */
  111274. getCapacity(): number;
  111275. /**
  111276. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  111277. * to override the particles.
  111278. */
  111279. forceDepthWrite: boolean;
  111280. /**
  111281. * Gets or set the number of active particles
  111282. */
  111283. activeParticleCount: number;
  111284. private _preWarmDone;
  111285. /**
  111286. * Is this system ready to be used/rendered
  111287. * @return true if the system is ready
  111288. */
  111289. isReady(): boolean;
  111290. /**
  111291. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111292. * @returns True if it has been started, otherwise false.
  111293. */
  111294. isStarted(): boolean;
  111295. /**
  111296. * Starts the particle system and begins to emit
  111297. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111298. */
  111299. start(delay?: number): void;
  111300. /**
  111301. * Stops the particle system.
  111302. */
  111303. stop(): void;
  111304. /**
  111305. * Remove all active particles
  111306. */
  111307. reset(): void;
  111308. /**
  111309. * Returns the string "GPUParticleSystem"
  111310. * @returns a string containing the class name
  111311. */
  111312. getClassName(): string;
  111313. private _colorGradientsTexture;
  111314. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  111315. /**
  111316. * Adds a new color gradient
  111317. * @param gradient defines the gradient to use (between 0 and 1)
  111318. * @param color1 defines the color to affect to the specified gradient
  111319. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  111320. * @returns the current particle system
  111321. */
  111322. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  111323. /**
  111324. * Remove a specific color gradient
  111325. * @param gradient defines the gradient to remove
  111326. * @returns the current particle system
  111327. */
  111328. removeColorGradient(gradient: number): GPUParticleSystem;
  111329. private _angularSpeedGradientsTexture;
  111330. private _sizeGradientsTexture;
  111331. private _velocityGradientsTexture;
  111332. private _limitVelocityGradientsTexture;
  111333. private _dragGradientsTexture;
  111334. private _addFactorGradient;
  111335. /**
  111336. * Adds a new size gradient
  111337. * @param gradient defines the gradient to use (between 0 and 1)
  111338. * @param factor defines the size factor to affect to the specified gradient
  111339. * @returns the current particle system
  111340. */
  111341. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  111342. /**
  111343. * Remove a specific size gradient
  111344. * @param gradient defines the gradient to remove
  111345. * @returns the current particle system
  111346. */
  111347. removeSizeGradient(gradient: number): GPUParticleSystem;
  111348. /**
  111349. * Adds a new angular speed gradient
  111350. * @param gradient defines the gradient to use (between 0 and 1)
  111351. * @param factor defines the angular speed to affect to the specified gradient
  111352. * @returns the current particle system
  111353. */
  111354. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  111355. /**
  111356. * Remove a specific angular speed gradient
  111357. * @param gradient defines the gradient to remove
  111358. * @returns the current particle system
  111359. */
  111360. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  111361. /**
  111362. * Adds a new velocity gradient
  111363. * @param gradient defines the gradient to use (between 0 and 1)
  111364. * @param factor defines the velocity to affect to the specified gradient
  111365. * @returns the current particle system
  111366. */
  111367. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111368. /**
  111369. * Remove a specific velocity gradient
  111370. * @param gradient defines the gradient to remove
  111371. * @returns the current particle system
  111372. */
  111373. removeVelocityGradient(gradient: number): GPUParticleSystem;
  111374. /**
  111375. * Adds a new limit velocity gradient
  111376. * @param gradient defines the gradient to use (between 0 and 1)
  111377. * @param factor defines the limit velocity value to affect to the specified gradient
  111378. * @returns the current particle system
  111379. */
  111380. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111381. /**
  111382. * Remove a specific limit velocity gradient
  111383. * @param gradient defines the gradient to remove
  111384. * @returns the current particle system
  111385. */
  111386. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  111387. /**
  111388. * Adds a new drag gradient
  111389. * @param gradient defines the gradient to use (between 0 and 1)
  111390. * @param factor defines the drag value to affect to the specified gradient
  111391. * @returns the current particle system
  111392. */
  111393. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111394. /**
  111395. * Remove a specific drag gradient
  111396. * @param gradient defines the gradient to remove
  111397. * @returns the current particle system
  111398. */
  111399. removeDragGradient(gradient: number): GPUParticleSystem;
  111400. /**
  111401. * Not supported by GPUParticleSystem
  111402. * @param gradient defines the gradient to use (between 0 and 1)
  111403. * @param factor defines the emit rate value to affect to the specified gradient
  111404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111405. * @returns the current particle system
  111406. */
  111407. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111408. /**
  111409. * Not supported by GPUParticleSystem
  111410. * @param gradient defines the gradient to remove
  111411. * @returns the current particle system
  111412. */
  111413. removeEmitRateGradient(gradient: number): IParticleSystem;
  111414. /**
  111415. * Not supported by GPUParticleSystem
  111416. * @param gradient defines the gradient to use (between 0 and 1)
  111417. * @param factor defines the start size value to affect to the specified gradient
  111418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111419. * @returns the current particle system
  111420. */
  111421. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111422. /**
  111423. * Not supported by GPUParticleSystem
  111424. * @param gradient defines the gradient to remove
  111425. * @returns the current particle system
  111426. */
  111427. removeStartSizeGradient(gradient: number): IParticleSystem;
  111428. /**
  111429. * Not supported by GPUParticleSystem
  111430. * @param gradient defines the gradient to use (between 0 and 1)
  111431. * @param min defines the color remap minimal range
  111432. * @param max defines the color remap maximal range
  111433. * @returns the current particle system
  111434. */
  111435. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111436. /**
  111437. * Not supported by GPUParticleSystem
  111438. * @param gradient defines the gradient to remove
  111439. * @returns the current particle system
  111440. */
  111441. removeColorRemapGradient(): IParticleSystem;
  111442. /**
  111443. * Not supported by GPUParticleSystem
  111444. * @param gradient defines the gradient to use (between 0 and 1)
  111445. * @param min defines the alpha remap minimal range
  111446. * @param max defines the alpha remap maximal range
  111447. * @returns the current particle system
  111448. */
  111449. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111450. /**
  111451. * Not supported by GPUParticleSystem
  111452. * @param gradient defines the gradient to remove
  111453. * @returns the current particle system
  111454. */
  111455. removeAlphaRemapGradient(): IParticleSystem;
  111456. /**
  111457. * Not supported by GPUParticleSystem
  111458. * @param gradient defines the gradient to use (between 0 and 1)
  111459. * @param color defines the color to affect to the specified gradient
  111460. * @returns the current particle system
  111461. */
  111462. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111463. /**
  111464. * Not supported by GPUParticleSystem
  111465. * @param gradient defines the gradient to remove
  111466. * @returns the current particle system
  111467. */
  111468. removeRampGradient(): IParticleSystem;
  111469. /**
  111470. * Not supported by GPUParticleSystem
  111471. * @returns the list of ramp gradients
  111472. */
  111473. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111474. /**
  111475. * Not supported by GPUParticleSystem
  111476. * Gets or sets a boolean indicating that ramp gradients must be used
  111477. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111478. */
  111479. useRampGradients: boolean;
  111480. /**
  111481. * Not supported by GPUParticleSystem
  111482. * @param gradient defines the gradient to use (between 0 and 1)
  111483. * @param factor defines the life time factor to affect to the specified gradient
  111484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111485. * @returns the current particle system
  111486. */
  111487. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111488. /**
  111489. * Not supported by GPUParticleSystem
  111490. * @param gradient defines the gradient to remove
  111491. * @returns the current particle system
  111492. */
  111493. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111494. /**
  111495. * Instantiates a GPU particle system.
  111496. * 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.
  111497. * @param name The name of the particle system
  111498. * @param options The options used to create the system
  111499. * @param scene The scene the particle system belongs to
  111500. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111501. */
  111502. constructor(name: string, options: Partial<{
  111503. capacity: number;
  111504. randomTextureSize: number;
  111505. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111506. protected _reset(): void;
  111507. private _createUpdateVAO;
  111508. private _createRenderVAO;
  111509. private _initialize;
  111510. /** @hidden */
  111511. _recreateUpdateEffect(): void;
  111512. /** @hidden */
  111513. _recreateRenderEffect(): void;
  111514. /**
  111515. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111516. * @param preWarm defines if we are in the pre-warmimg phase
  111517. */
  111518. animate(preWarm?: boolean): void;
  111519. private _createFactorGradientTexture;
  111520. private _createSizeGradientTexture;
  111521. private _createAngularSpeedGradientTexture;
  111522. private _createVelocityGradientTexture;
  111523. private _createLimitVelocityGradientTexture;
  111524. private _createDragGradientTexture;
  111525. private _createColorGradientTexture;
  111526. /**
  111527. * Renders the particle system in its current state
  111528. * @param preWarm defines if the system should only update the particles but not render them
  111529. * @returns the current number of particles
  111530. */
  111531. render(preWarm?: boolean): number;
  111532. /**
  111533. * Rebuilds the particle system
  111534. */
  111535. rebuild(): void;
  111536. private _releaseBuffers;
  111537. private _releaseVAOs;
  111538. /**
  111539. * Disposes the particle system and free the associated resources
  111540. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111541. */
  111542. dispose(disposeTexture?: boolean): void;
  111543. /**
  111544. * Clones the particle system.
  111545. * @param name The name of the cloned object
  111546. * @param newEmitter The new emitter to use
  111547. * @returns the cloned particle system
  111548. */
  111549. clone(name: string, newEmitter: any): GPUParticleSystem;
  111550. /**
  111551. * Serializes the particle system to a JSON object.
  111552. * @returns the JSON object
  111553. */
  111554. serialize(): any;
  111555. /**
  111556. * Parses a JSON object to create a GPU particle system.
  111557. * @param parsedParticleSystem The JSON object to parse
  111558. * @param scene The scene to create the particle system in
  111559. * @param rootUrl The root url to use to load external dependencies like texture
  111560. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111561. * @returns the parsed GPU particle system
  111562. */
  111563. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111564. }
  111565. }
  111566. declare module BABYLON {
  111567. /**
  111568. * Represents a set of particle systems working together to create a specific effect
  111569. */
  111570. export class ParticleSystemSet implements IDisposable {
  111571. private _emitterCreationOptions;
  111572. private _emitterNode;
  111573. /**
  111574. * Gets the particle system list
  111575. */
  111576. systems: IParticleSystem[];
  111577. /**
  111578. * Gets the emitter node used with this set
  111579. */
  111580. readonly emitterNode: Nullable<TransformNode>;
  111581. /**
  111582. * Creates a new emitter mesh as a sphere
  111583. * @param options defines the options used to create the sphere
  111584. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111585. * @param scene defines the hosting scene
  111586. */
  111587. setEmitterAsSphere(options: {
  111588. diameter: number;
  111589. segments: number;
  111590. color: Color3;
  111591. }, renderingGroupId: number, scene: Scene): void;
  111592. /**
  111593. * Starts all particle systems of the set
  111594. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111595. */
  111596. start(emitter?: AbstractMesh): void;
  111597. /**
  111598. * Release all associated resources
  111599. */
  111600. dispose(): void;
  111601. /**
  111602. * Serialize the set into a JSON compatible object
  111603. * @returns a JSON compatible representation of the set
  111604. */
  111605. serialize(): any;
  111606. /**
  111607. * Parse a new ParticleSystemSet from a serialized source
  111608. * @param data defines a JSON compatible representation of the set
  111609. * @param scene defines the hosting scene
  111610. * @param gpu defines if we want GPU particles or CPU particles
  111611. * @returns a new ParticleSystemSet
  111612. */
  111613. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111614. }
  111615. }
  111616. declare module BABYLON {
  111617. /**
  111618. * This class is made for on one-liner static method to help creating particle system set.
  111619. */
  111620. export class ParticleHelper {
  111621. /**
  111622. * Gets or sets base Assets URL
  111623. */
  111624. static BaseAssetsUrl: string;
  111625. /**
  111626. * Create a default particle system that you can tweak
  111627. * @param emitter defines the emitter to use
  111628. * @param capacity defines the system capacity (default is 500 particles)
  111629. * @param scene defines the hosting scene
  111630. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111631. * @returns the new Particle system
  111632. */
  111633. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111634. /**
  111635. * This is the main static method (one-liner) of this helper to create different particle systems
  111636. * @param type This string represents the type to the particle system to create
  111637. * @param scene The scene where the particle system should live
  111638. * @param gpu If the system will use gpu
  111639. * @returns the ParticleSystemSet created
  111640. */
  111641. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111642. /**
  111643. * Static function used to export a particle system to a ParticleSystemSet variable.
  111644. * Please note that the emitter shape is not exported
  111645. * @param systems defines the particle systems to export
  111646. * @returns the created particle system set
  111647. */
  111648. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111649. }
  111650. }
  111651. declare module BABYLON {
  111652. interface Engine {
  111653. /**
  111654. * Create an effect to use with particle systems.
  111655. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111656. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111657. * @param uniformsNames defines a list of attribute names
  111658. * @param samplers defines an array of string used to represent textures
  111659. * @param defines defines the string containing the defines to use to compile the shaders
  111660. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111661. * @param onCompiled defines a function to call when the effect creation is successful
  111662. * @param onError defines a function to call when the effect creation has failed
  111663. * @returns the new Effect
  111664. */
  111665. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111666. }
  111667. interface Mesh {
  111668. /**
  111669. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111670. * @returns an array of IParticleSystem
  111671. */
  111672. getEmittedParticleSystems(): IParticleSystem[];
  111673. /**
  111674. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111675. * @returns an array of IParticleSystem
  111676. */
  111677. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111678. }
  111679. /**
  111680. * @hidden
  111681. */
  111682. export var _IDoNeedToBeInTheBuild: number;
  111683. }
  111684. declare module BABYLON {
  111685. interface Scene {
  111686. /** @hidden (Backing field) */
  111687. _physicsEngine: Nullable<IPhysicsEngine>;
  111688. /**
  111689. * Gets the current physics engine
  111690. * @returns a IPhysicsEngine or null if none attached
  111691. */
  111692. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111693. /**
  111694. * Enables physics to the current scene
  111695. * @param gravity defines the scene's gravity for the physics engine
  111696. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111697. * @return a boolean indicating if the physics engine was initialized
  111698. */
  111699. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111700. /**
  111701. * Disables and disposes the physics engine associated with the scene
  111702. */
  111703. disablePhysicsEngine(): void;
  111704. /**
  111705. * Gets a boolean indicating if there is an active physics engine
  111706. * @returns a boolean indicating if there is an active physics engine
  111707. */
  111708. isPhysicsEnabled(): boolean;
  111709. /**
  111710. * Deletes a physics compound impostor
  111711. * @param compound defines the compound to delete
  111712. */
  111713. deleteCompoundImpostor(compound: any): void;
  111714. /**
  111715. * An event triggered when physic simulation is about to be run
  111716. */
  111717. onBeforePhysicsObservable: Observable<Scene>;
  111718. /**
  111719. * An event triggered when physic simulation has been done
  111720. */
  111721. onAfterPhysicsObservable: Observable<Scene>;
  111722. }
  111723. interface AbstractMesh {
  111724. /** @hidden */
  111725. _physicsImpostor: Nullable<PhysicsImpostor>;
  111726. /**
  111727. * Gets or sets impostor used for physic simulation
  111728. * @see http://doc.babylonjs.com/features/physics_engine
  111729. */
  111730. physicsImpostor: Nullable<PhysicsImpostor>;
  111731. /**
  111732. * Gets the current physics impostor
  111733. * @see http://doc.babylonjs.com/features/physics_engine
  111734. * @returns a physics impostor or null
  111735. */
  111736. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111737. /** Apply a physic impulse to the mesh
  111738. * @param force defines the force to apply
  111739. * @param contactPoint defines where to apply the force
  111740. * @returns the current mesh
  111741. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111742. */
  111743. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111744. /**
  111745. * Creates a physic joint between two meshes
  111746. * @param otherMesh defines the other mesh to use
  111747. * @param pivot1 defines the pivot to use on this mesh
  111748. * @param pivot2 defines the pivot to use on the other mesh
  111749. * @param options defines additional options (can be plugin dependent)
  111750. * @returns the current mesh
  111751. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111752. */
  111753. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111754. /** @hidden */
  111755. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111756. }
  111757. /**
  111758. * Defines the physics engine scene component responsible to manage a physics engine
  111759. */
  111760. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111761. /**
  111762. * The component name helpful to identify the component in the list of scene components.
  111763. */
  111764. readonly name: string;
  111765. /**
  111766. * The scene the component belongs to.
  111767. */
  111768. scene: Scene;
  111769. /**
  111770. * Creates a new instance of the component for the given scene
  111771. * @param scene Defines the scene to register the component in
  111772. */
  111773. constructor(scene: Scene);
  111774. /**
  111775. * Registers the component in a given scene
  111776. */
  111777. register(): void;
  111778. /**
  111779. * Rebuilds the elements related to this component in case of
  111780. * context lost for instance.
  111781. */
  111782. rebuild(): void;
  111783. /**
  111784. * Disposes the component and the associated ressources
  111785. */
  111786. dispose(): void;
  111787. }
  111788. }
  111789. declare module BABYLON {
  111790. /**
  111791. * A helper for physics simulations
  111792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111793. */
  111794. export class PhysicsHelper {
  111795. private _scene;
  111796. private _physicsEngine;
  111797. /**
  111798. * Initializes the Physics helper
  111799. * @param scene Babylon.js scene
  111800. */
  111801. constructor(scene: Scene);
  111802. /**
  111803. * Applies a radial explosion impulse
  111804. * @param origin the origin of the explosion
  111805. * @param radiusOrEventOptions the radius or the options of radial explosion
  111806. * @param strength the explosion strength
  111807. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111808. * @returns A physics radial explosion event, or null
  111809. */
  111810. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111811. /**
  111812. * Applies a radial explosion force
  111813. * @param origin the origin of the explosion
  111814. * @param radiusOrEventOptions the radius or the options of radial explosion
  111815. * @param strength the explosion strength
  111816. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111817. * @returns A physics radial explosion event, or null
  111818. */
  111819. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111820. /**
  111821. * Creates a gravitational field
  111822. * @param origin the origin of the explosion
  111823. * @param radiusOrEventOptions the radius or the options of radial explosion
  111824. * @param strength the explosion strength
  111825. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111826. * @returns A physics gravitational field event, or null
  111827. */
  111828. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111829. /**
  111830. * Creates a physics updraft event
  111831. * @param origin the origin of the updraft
  111832. * @param radiusOrEventOptions the radius or the options of the updraft
  111833. * @param strength the strength of the updraft
  111834. * @param height the height of the updraft
  111835. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111836. * @returns A physics updraft event, or null
  111837. */
  111838. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111839. /**
  111840. * Creates a physics vortex event
  111841. * @param origin the of the vortex
  111842. * @param radiusOrEventOptions the radius or the options of the vortex
  111843. * @param strength the strength of the vortex
  111844. * @param height the height of the vortex
  111845. * @returns a Physics vortex event, or null
  111846. * A physics vortex event or null
  111847. */
  111848. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111849. }
  111850. /**
  111851. * Represents a physics radial explosion event
  111852. */
  111853. class PhysicsRadialExplosionEvent {
  111854. private _scene;
  111855. private _options;
  111856. private _sphere;
  111857. private _dataFetched;
  111858. /**
  111859. * Initializes a radial explosioin event
  111860. * @param _scene BabylonJS scene
  111861. * @param _options The options for the vortex event
  111862. */
  111863. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111864. /**
  111865. * Returns the data related to the radial explosion event (sphere).
  111866. * @returns The radial explosion event data
  111867. */
  111868. getData(): PhysicsRadialExplosionEventData;
  111869. /**
  111870. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111871. * @param impostor A physics imposter
  111872. * @param origin the origin of the explosion
  111873. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111874. */
  111875. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111876. /**
  111877. * Triggers affecterd impostors callbacks
  111878. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111879. */
  111880. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111881. /**
  111882. * Disposes the sphere.
  111883. * @param force Specifies if the sphere should be disposed by force
  111884. */
  111885. dispose(force?: boolean): void;
  111886. /*** Helpers ***/
  111887. private _prepareSphere;
  111888. private _intersectsWithSphere;
  111889. }
  111890. /**
  111891. * Represents a gravitational field event
  111892. */
  111893. class PhysicsGravitationalFieldEvent {
  111894. private _physicsHelper;
  111895. private _scene;
  111896. private _origin;
  111897. private _options;
  111898. private _tickCallback;
  111899. private _sphere;
  111900. private _dataFetched;
  111901. /**
  111902. * Initializes the physics gravitational field event
  111903. * @param _physicsHelper A physics helper
  111904. * @param _scene BabylonJS scene
  111905. * @param _origin The origin position of the gravitational field event
  111906. * @param _options The options for the vortex event
  111907. */
  111908. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111909. /**
  111910. * Returns the data related to the gravitational field event (sphere).
  111911. * @returns A gravitational field event
  111912. */
  111913. getData(): PhysicsGravitationalFieldEventData;
  111914. /**
  111915. * Enables the gravitational field.
  111916. */
  111917. enable(): void;
  111918. /**
  111919. * Disables the gravitational field.
  111920. */
  111921. disable(): void;
  111922. /**
  111923. * Disposes the sphere.
  111924. * @param force The force to dispose from the gravitational field event
  111925. */
  111926. dispose(force?: boolean): void;
  111927. private _tick;
  111928. }
  111929. /**
  111930. * Represents a physics updraft event
  111931. */
  111932. class PhysicsUpdraftEvent {
  111933. private _scene;
  111934. private _origin;
  111935. private _options;
  111936. private _physicsEngine;
  111937. private _originTop;
  111938. private _originDirection;
  111939. private _tickCallback;
  111940. private _cylinder;
  111941. private _cylinderPosition;
  111942. private _dataFetched;
  111943. /**
  111944. * Initializes the physics updraft event
  111945. * @param _scene BabylonJS scene
  111946. * @param _origin The origin position of the updraft
  111947. * @param _options The options for the updraft event
  111948. */
  111949. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111950. /**
  111951. * Returns the data related to the updraft event (cylinder).
  111952. * @returns A physics updraft event
  111953. */
  111954. getData(): PhysicsUpdraftEventData;
  111955. /**
  111956. * Enables the updraft.
  111957. */
  111958. enable(): void;
  111959. /**
  111960. * Disables the updraft.
  111961. */
  111962. disable(): void;
  111963. /**
  111964. * Disposes the cylinder.
  111965. * @param force Specifies if the updraft should be disposed by force
  111966. */
  111967. dispose(force?: boolean): void;
  111968. private getImpostorHitData;
  111969. private _tick;
  111970. /*** Helpers ***/
  111971. private _prepareCylinder;
  111972. private _intersectsWithCylinder;
  111973. }
  111974. /**
  111975. * Represents a physics vortex event
  111976. */
  111977. class PhysicsVortexEvent {
  111978. private _scene;
  111979. private _origin;
  111980. private _options;
  111981. private _physicsEngine;
  111982. private _originTop;
  111983. private _tickCallback;
  111984. private _cylinder;
  111985. private _cylinderPosition;
  111986. private _dataFetched;
  111987. /**
  111988. * Initializes the physics vortex event
  111989. * @param _scene The BabylonJS scene
  111990. * @param _origin The origin position of the vortex
  111991. * @param _options The options for the vortex event
  111992. */
  111993. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111994. /**
  111995. * Returns the data related to the vortex event (cylinder).
  111996. * @returns The physics vortex event data
  111997. */
  111998. getData(): PhysicsVortexEventData;
  111999. /**
  112000. * Enables the vortex.
  112001. */
  112002. enable(): void;
  112003. /**
  112004. * Disables the cortex.
  112005. */
  112006. disable(): void;
  112007. /**
  112008. * Disposes the sphere.
  112009. * @param force
  112010. */
  112011. dispose(force?: boolean): void;
  112012. private getImpostorHitData;
  112013. private _tick;
  112014. /*** Helpers ***/
  112015. private _prepareCylinder;
  112016. private _intersectsWithCylinder;
  112017. }
  112018. /**
  112019. * Options fot the radial explosion event
  112020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112021. */
  112022. export class PhysicsRadialExplosionEventOptions {
  112023. /**
  112024. * The radius of the sphere for the radial explosion.
  112025. */
  112026. radius: number;
  112027. /**
  112028. * The strenth of the explosion.
  112029. */
  112030. strength: number;
  112031. /**
  112032. * The strenght of the force in correspondence to the distance of the affected object
  112033. */
  112034. falloff: PhysicsRadialImpulseFalloff;
  112035. /**
  112036. * Sphere options for the radial explosion.
  112037. */
  112038. sphere: {
  112039. segments: number;
  112040. diameter: number;
  112041. };
  112042. /**
  112043. * Sphere options for the radial explosion.
  112044. */
  112045. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  112046. }
  112047. /**
  112048. * Options fot the updraft event
  112049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112050. */
  112051. export class PhysicsUpdraftEventOptions {
  112052. /**
  112053. * The radius of the cylinder for the vortex
  112054. */
  112055. radius: number;
  112056. /**
  112057. * The strenth of the updraft.
  112058. */
  112059. strength: number;
  112060. /**
  112061. * The height of the cylinder for the updraft.
  112062. */
  112063. height: number;
  112064. /**
  112065. * The mode for the the updraft.
  112066. */
  112067. updraftMode: PhysicsUpdraftMode;
  112068. }
  112069. /**
  112070. * Options fot the vortex event
  112071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112072. */
  112073. export class PhysicsVortexEventOptions {
  112074. /**
  112075. * The radius of the cylinder for the vortex
  112076. */
  112077. radius: number;
  112078. /**
  112079. * The strenth of the vortex.
  112080. */
  112081. strength: number;
  112082. /**
  112083. * The height of the cylinder for the vortex.
  112084. */
  112085. height: number;
  112086. /**
  112087. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  112088. */
  112089. centripetalForceThreshold: number;
  112090. /**
  112091. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  112092. */
  112093. centripetalForceMultiplier: number;
  112094. /**
  112095. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  112096. */
  112097. centrifugalForceMultiplier: number;
  112098. /**
  112099. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  112100. */
  112101. updraftForceMultiplier: number;
  112102. }
  112103. /**
  112104. * The strenght of the force in correspondence to the distance of the affected object
  112105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112106. */
  112107. export enum PhysicsRadialImpulseFalloff {
  112108. /** Defines that impulse is constant in strength across it's whole radius */
  112109. Constant = 0,
  112110. /** Defines that impulse gets weaker if it's further from the origin */
  112111. Linear = 1
  112112. }
  112113. /**
  112114. * The strength of the force in correspondence to the distance of the affected object
  112115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112116. */
  112117. export enum PhysicsUpdraftMode {
  112118. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112119. Center = 0,
  112120. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112121. Perpendicular = 1
  112122. }
  112123. /**
  112124. * Interface for a physics hit data
  112125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112126. */
  112127. export interface PhysicsHitData {
  112128. /**
  112129. * The force applied at the contact point
  112130. */
  112131. force: Vector3;
  112132. /**
  112133. * The contact point
  112134. */
  112135. contactPoint: Vector3;
  112136. /**
  112137. * The distance from the origin to the contact point
  112138. */
  112139. distanceFromOrigin: number;
  112140. }
  112141. /**
  112142. * Interface for radial explosion event data
  112143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112144. */
  112145. export interface PhysicsRadialExplosionEventData {
  112146. /**
  112147. * A sphere used for the radial explosion event
  112148. */
  112149. sphere: Mesh;
  112150. }
  112151. /**
  112152. * Interface for gravitational field event data
  112153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112154. */
  112155. export interface PhysicsGravitationalFieldEventData {
  112156. /**
  112157. * A sphere mesh used for the gravitational field event
  112158. */
  112159. sphere: Mesh;
  112160. }
  112161. /**
  112162. * Interface for updraft event data
  112163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112164. */
  112165. export interface PhysicsUpdraftEventData {
  112166. /**
  112167. * A cylinder used for the updraft event
  112168. */
  112169. cylinder: Mesh;
  112170. }
  112171. /**
  112172. * Interface for vortex event data
  112173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112174. */
  112175. export interface PhysicsVortexEventData {
  112176. /**
  112177. * A cylinder used for the vortex event
  112178. */
  112179. cylinder: Mesh;
  112180. }
  112181. /**
  112182. * Interface for an affected physics impostor
  112183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112184. */
  112185. export interface PhysicsAffectedImpostorWithData {
  112186. /**
  112187. * The impostor affected by the effect
  112188. */
  112189. impostor: PhysicsImpostor;
  112190. /**
  112191. * The data about the hit/horce from the explosion
  112192. */
  112193. hitData: PhysicsHitData;
  112194. }
  112195. }
  112196. declare module BABYLON {
  112197. /** @hidden */
  112198. export var blackAndWhitePixelShader: {
  112199. name: string;
  112200. shader: string;
  112201. };
  112202. }
  112203. declare module BABYLON {
  112204. /**
  112205. * Post process used to render in black and white
  112206. */
  112207. export class BlackAndWhitePostProcess extends PostProcess {
  112208. /**
  112209. * Linear about to convert he result to black and white (default: 1)
  112210. */
  112211. degree: number;
  112212. /**
  112213. * Creates a black and white post process
  112214. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  112215. * @param name The name of the effect.
  112216. * @param options The required width/height ratio to downsize to before computing the render pass.
  112217. * @param camera The camera to apply the render pass to.
  112218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112219. * @param engine The engine which the post process will be applied. (default: current engine)
  112220. * @param reusable If the post process can be reused on the same frame. (default: false)
  112221. */
  112222. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112223. }
  112224. }
  112225. declare module BABYLON {
  112226. /**
  112227. * This represents a set of one or more post processes in Babylon.
  112228. * A post process can be used to apply a shader to a texture after it is rendered.
  112229. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112230. */
  112231. export class PostProcessRenderEffect {
  112232. private _postProcesses;
  112233. private _getPostProcesses;
  112234. private _singleInstance;
  112235. private _cameras;
  112236. private _indicesForCamera;
  112237. /**
  112238. * Name of the effect
  112239. * @hidden
  112240. */
  112241. _name: string;
  112242. /**
  112243. * Instantiates a post process render effect.
  112244. * A post process can be used to apply a shader to a texture after it is rendered.
  112245. * @param engine The engine the effect is tied to
  112246. * @param name The name of the effect
  112247. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  112248. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  112249. */
  112250. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  112251. /**
  112252. * Checks if all the post processes in the effect are supported.
  112253. */
  112254. readonly isSupported: boolean;
  112255. /**
  112256. * Updates the current state of the effect
  112257. * @hidden
  112258. */
  112259. _update(): void;
  112260. /**
  112261. * Attaches the effect on cameras
  112262. * @param cameras The camera to attach to.
  112263. * @hidden
  112264. */
  112265. _attachCameras(cameras: Camera): void;
  112266. /**
  112267. * Attaches the effect on cameras
  112268. * @param cameras The camera to attach to.
  112269. * @hidden
  112270. */
  112271. _attachCameras(cameras: Camera[]): void;
  112272. /**
  112273. * Detaches the effect on cameras
  112274. * @param cameras The camera to detatch from.
  112275. * @hidden
  112276. */
  112277. _detachCameras(cameras: Camera): void;
  112278. /**
  112279. * Detatches the effect on cameras
  112280. * @param cameras The camera to detatch from.
  112281. * @hidden
  112282. */
  112283. _detachCameras(cameras: Camera[]): void;
  112284. /**
  112285. * Enables the effect on given cameras
  112286. * @param cameras The camera to enable.
  112287. * @hidden
  112288. */
  112289. _enable(cameras: Camera): void;
  112290. /**
  112291. * Enables the effect on given cameras
  112292. * @param cameras The camera to enable.
  112293. * @hidden
  112294. */
  112295. _enable(cameras: Nullable<Camera[]>): void;
  112296. /**
  112297. * Disables the effect on the given cameras
  112298. * @param cameras The camera to disable.
  112299. * @hidden
  112300. */
  112301. _disable(cameras: Camera): void;
  112302. /**
  112303. * Disables the effect on the given cameras
  112304. * @param cameras The camera to disable.
  112305. * @hidden
  112306. */
  112307. _disable(cameras: Nullable<Camera[]>): void;
  112308. /**
  112309. * Gets a list of the post processes contained in the effect.
  112310. * @param camera The camera to get the post processes on.
  112311. * @returns The list of the post processes in the effect.
  112312. */
  112313. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  112314. }
  112315. }
  112316. declare module BABYLON {
  112317. /** @hidden */
  112318. export var extractHighlightsPixelShader: {
  112319. name: string;
  112320. shader: string;
  112321. };
  112322. }
  112323. declare module BABYLON {
  112324. /**
  112325. * 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.
  112326. */
  112327. export class ExtractHighlightsPostProcess extends PostProcess {
  112328. /**
  112329. * The luminance threshold, pixels below this value will be set to black.
  112330. */
  112331. threshold: number;
  112332. /** @hidden */
  112333. _exposure: number;
  112334. /**
  112335. * Post process which has the input texture to be used when performing highlight extraction
  112336. * @hidden
  112337. */
  112338. _inputPostProcess: Nullable<PostProcess>;
  112339. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112340. }
  112341. }
  112342. declare module BABYLON {
  112343. /** @hidden */
  112344. export var bloomMergePixelShader: {
  112345. name: string;
  112346. shader: string;
  112347. };
  112348. }
  112349. declare module BABYLON {
  112350. /**
  112351. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112352. */
  112353. export class BloomMergePostProcess extends PostProcess {
  112354. /** Weight of the bloom to be added to the original input. */
  112355. weight: number;
  112356. /**
  112357. * Creates a new instance of @see BloomMergePostProcess
  112358. * @param name The name of the effect.
  112359. * @param originalFromInput Post process which's input will be used for the merge.
  112360. * @param blurred Blurred highlights post process which's output will be used.
  112361. * @param weight Weight of the bloom to be added to the original input.
  112362. * @param options The required width/height ratio to downsize to before computing the render pass.
  112363. * @param camera The camera to apply the render pass to.
  112364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112365. * @param engine The engine which the post process will be applied. (default: current engine)
  112366. * @param reusable If the post process can be reused on the same frame. (default: false)
  112367. * @param textureType Type of textures used when performing the post process. (default: 0)
  112368. * @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)
  112369. */
  112370. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  112371. /** Weight of the bloom to be added to the original input. */
  112372. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112373. }
  112374. }
  112375. declare module BABYLON {
  112376. /**
  112377. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  112378. */
  112379. export class BloomEffect extends PostProcessRenderEffect {
  112380. private bloomScale;
  112381. /**
  112382. * @hidden Internal
  112383. */
  112384. _effects: Array<PostProcess>;
  112385. /**
  112386. * @hidden Internal
  112387. */
  112388. _downscale: ExtractHighlightsPostProcess;
  112389. private _blurX;
  112390. private _blurY;
  112391. private _merge;
  112392. /**
  112393. * The luminance threshold to find bright areas of the image to bloom.
  112394. */
  112395. threshold: number;
  112396. /**
  112397. * The strength of the bloom.
  112398. */
  112399. weight: number;
  112400. /**
  112401. * Specifies the size of the bloom blur kernel, relative to the final output size
  112402. */
  112403. kernel: number;
  112404. /**
  112405. * Creates a new instance of @see BloomEffect
  112406. * @param scene The scene the effect belongs to.
  112407. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112408. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112409. * @param bloomWeight The the strength of bloom.
  112410. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112411. * @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)
  112412. */
  112413. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112414. /**
  112415. * Disposes each of the internal effects for a given camera.
  112416. * @param camera The camera to dispose the effect on.
  112417. */
  112418. disposeEffects(camera: Camera): void;
  112419. /**
  112420. * @hidden Internal
  112421. */
  112422. _updateEffects(): void;
  112423. /**
  112424. * Internal
  112425. * @returns if all the contained post processes are ready.
  112426. * @hidden
  112427. */
  112428. _isReady(): boolean;
  112429. }
  112430. }
  112431. declare module BABYLON {
  112432. /** @hidden */
  112433. export var chromaticAberrationPixelShader: {
  112434. name: string;
  112435. shader: string;
  112436. };
  112437. }
  112438. declare module BABYLON {
  112439. /**
  112440. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112441. */
  112442. export class ChromaticAberrationPostProcess extends PostProcess {
  112443. /**
  112444. * The amount of seperation of rgb channels (default: 30)
  112445. */
  112446. aberrationAmount: number;
  112447. /**
  112448. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112449. */
  112450. radialIntensity: number;
  112451. /**
  112452. * 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))
  112453. */
  112454. direction: Vector2;
  112455. /**
  112456. * 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))
  112457. */
  112458. centerPosition: Vector2;
  112459. /**
  112460. * Creates a new instance ChromaticAberrationPostProcess
  112461. * @param name The name of the effect.
  112462. * @param screenWidth The width of the screen to apply the effect on.
  112463. * @param screenHeight The height of the screen to apply the effect on.
  112464. * @param options The required width/height ratio to downsize to before computing the render pass.
  112465. * @param camera The camera to apply the render pass to.
  112466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112467. * @param engine The engine which the post process will be applied. (default: current engine)
  112468. * @param reusable If the post process can be reused on the same frame. (default: false)
  112469. * @param textureType Type of textures used when performing the post process. (default: 0)
  112470. * @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)
  112471. */
  112472. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112473. }
  112474. }
  112475. declare module BABYLON {
  112476. /** @hidden */
  112477. export var circleOfConfusionPixelShader: {
  112478. name: string;
  112479. shader: string;
  112480. };
  112481. }
  112482. declare module BABYLON {
  112483. /**
  112484. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112485. */
  112486. export class CircleOfConfusionPostProcess extends PostProcess {
  112487. /**
  112488. * 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.
  112489. */
  112490. lensSize: number;
  112491. /**
  112492. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112493. */
  112494. fStop: number;
  112495. /**
  112496. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112497. */
  112498. focusDistance: number;
  112499. /**
  112500. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112501. */
  112502. focalLength: number;
  112503. private _depthTexture;
  112504. /**
  112505. * Creates a new instance CircleOfConfusionPostProcess
  112506. * @param name The name of the effect.
  112507. * @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.
  112508. * @param options The required width/height ratio to downsize to before computing the render pass.
  112509. * @param camera The camera to apply the render pass to.
  112510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112511. * @param engine The engine which the post process will be applied. (default: current engine)
  112512. * @param reusable If the post process can be reused on the same frame. (default: false)
  112513. * @param textureType Type of textures used when performing the post process. (default: 0)
  112514. * @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)
  112515. */
  112516. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112517. /**
  112518. * 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.
  112519. */
  112520. depthTexture: RenderTargetTexture;
  112521. }
  112522. }
  112523. declare module BABYLON {
  112524. /** @hidden */
  112525. export var colorCorrectionPixelShader: {
  112526. name: string;
  112527. shader: string;
  112528. };
  112529. }
  112530. declare module BABYLON {
  112531. /**
  112532. *
  112533. * This post-process allows the modification of rendered colors by using
  112534. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112535. *
  112536. * The object needs to be provided an url to a texture containing the color
  112537. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112538. * Use an image editing software to tweak the LUT to match your needs.
  112539. *
  112540. * For an example of a color LUT, see here:
  112541. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112542. * For explanations on color grading, see here:
  112543. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112544. *
  112545. */
  112546. export class ColorCorrectionPostProcess extends PostProcess {
  112547. private _colorTableTexture;
  112548. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112549. }
  112550. }
  112551. declare module BABYLON {
  112552. /** @hidden */
  112553. export var convolutionPixelShader: {
  112554. name: string;
  112555. shader: string;
  112556. };
  112557. }
  112558. declare module BABYLON {
  112559. /**
  112560. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112561. * input texture to perform effects such as edge detection or sharpening
  112562. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112563. */
  112564. export class ConvolutionPostProcess extends PostProcess {
  112565. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112566. kernel: number[];
  112567. /**
  112568. * Creates a new instance ConvolutionPostProcess
  112569. * @param name The name of the effect.
  112570. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112571. * @param options The required width/height ratio to downsize to before computing the render pass.
  112572. * @param camera The camera to apply the render pass to.
  112573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112574. * @param engine The engine which the post process will be applied. (default: current engine)
  112575. * @param reusable If the post process can be reused on the same frame. (default: false)
  112576. * @param textureType Type of textures used when performing the post process. (default: 0)
  112577. */
  112578. constructor(name: string,
  112579. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112580. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112581. /**
  112582. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112583. */
  112584. static EdgeDetect0Kernel: number[];
  112585. /**
  112586. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112587. */
  112588. static EdgeDetect1Kernel: number[];
  112589. /**
  112590. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112591. */
  112592. static EdgeDetect2Kernel: number[];
  112593. /**
  112594. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112595. */
  112596. static SharpenKernel: number[];
  112597. /**
  112598. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112599. */
  112600. static EmbossKernel: number[];
  112601. /**
  112602. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112603. */
  112604. static GaussianKernel: number[];
  112605. }
  112606. }
  112607. declare module BABYLON {
  112608. /**
  112609. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112610. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112611. * based on samples that have a large difference in distance than the center pixel.
  112612. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112613. */
  112614. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112615. direction: Vector2;
  112616. /**
  112617. * Creates a new instance CircleOfConfusionPostProcess
  112618. * @param name The name of the effect.
  112619. * @param scene The scene the effect belongs to.
  112620. * @param direction The direction the blur should be applied.
  112621. * @param kernel The size of the kernel used to blur.
  112622. * @param options The required width/height ratio to downsize to before computing the render pass.
  112623. * @param camera The camera to apply the render pass to.
  112624. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112625. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112627. * @param engine The engine which the post process will be applied. (default: current engine)
  112628. * @param reusable If the post process can be reused on the same frame. (default: false)
  112629. * @param textureType Type of textures used when performing the post process. (default: 0)
  112630. * @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)
  112631. */
  112632. 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);
  112633. }
  112634. }
  112635. declare module BABYLON {
  112636. /** @hidden */
  112637. export var depthOfFieldMergePixelShader: {
  112638. name: string;
  112639. shader: string;
  112640. };
  112641. }
  112642. declare module BABYLON {
  112643. /**
  112644. * Options to be set when merging outputs from the default pipeline.
  112645. */
  112646. export class DepthOfFieldMergePostProcessOptions {
  112647. /**
  112648. * The original image to merge on top of
  112649. */
  112650. originalFromInput: PostProcess;
  112651. /**
  112652. * Parameters to perform the merge of the depth of field effect
  112653. */
  112654. depthOfField?: {
  112655. circleOfConfusion: PostProcess;
  112656. blurSteps: Array<PostProcess>;
  112657. };
  112658. /**
  112659. * Parameters to perform the merge of bloom effect
  112660. */
  112661. bloom?: {
  112662. blurred: PostProcess;
  112663. weight: number;
  112664. };
  112665. }
  112666. /**
  112667. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112668. */
  112669. export class DepthOfFieldMergePostProcess extends PostProcess {
  112670. private blurSteps;
  112671. /**
  112672. * Creates a new instance of DepthOfFieldMergePostProcess
  112673. * @param name The name of the effect.
  112674. * @param originalFromInput Post process which's input will be used for the merge.
  112675. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112676. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112677. * @param options The required width/height ratio to downsize to before computing the render pass.
  112678. * @param camera The camera to apply the render pass to.
  112679. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112680. * @param engine The engine which the post process will be applied. (default: current engine)
  112681. * @param reusable If the post process can be reused on the same frame. (default: false)
  112682. * @param textureType Type of textures used when performing the post process. (default: 0)
  112683. * @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)
  112684. */
  112685. 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);
  112686. /**
  112687. * Updates the effect with the current post process compile time values and recompiles the shader.
  112688. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112689. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112690. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112691. * @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
  112692. * @param onCompiled Called when the shader has been compiled.
  112693. * @param onError Called if there is an error when compiling a shader.
  112694. */
  112695. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112696. }
  112697. }
  112698. declare module BABYLON {
  112699. /**
  112700. * Specifies the level of max blur that should be applied when using the depth of field effect
  112701. */
  112702. export enum DepthOfFieldEffectBlurLevel {
  112703. /**
  112704. * Subtle blur
  112705. */
  112706. Low = 0,
  112707. /**
  112708. * Medium blur
  112709. */
  112710. Medium = 1,
  112711. /**
  112712. * Large blur
  112713. */
  112714. High = 2
  112715. }
  112716. /**
  112717. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112718. */
  112719. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112720. private _circleOfConfusion;
  112721. /**
  112722. * @hidden Internal, blurs from high to low
  112723. */
  112724. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112725. private _depthOfFieldBlurY;
  112726. private _dofMerge;
  112727. /**
  112728. * @hidden Internal post processes in depth of field effect
  112729. */
  112730. _effects: Array<PostProcess>;
  112731. /**
  112732. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112733. */
  112734. focalLength: number;
  112735. /**
  112736. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112737. */
  112738. fStop: number;
  112739. /**
  112740. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112741. */
  112742. focusDistance: number;
  112743. /**
  112744. * 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.
  112745. */
  112746. lensSize: number;
  112747. /**
  112748. * Creates a new instance DepthOfFieldEffect
  112749. * @param scene The scene the effect belongs to.
  112750. * @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.
  112751. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112752. * @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)
  112753. */
  112754. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112755. /**
  112756. * Get the current class name of the current effet
  112757. * @returns "DepthOfFieldEffect"
  112758. */
  112759. getClassName(): string;
  112760. /**
  112761. * 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.
  112762. */
  112763. depthTexture: RenderTargetTexture;
  112764. /**
  112765. * Disposes each of the internal effects for a given camera.
  112766. * @param camera The camera to dispose the effect on.
  112767. */
  112768. disposeEffects(camera: Camera): void;
  112769. /**
  112770. * @hidden Internal
  112771. */
  112772. _updateEffects(): void;
  112773. /**
  112774. * Internal
  112775. * @returns if all the contained post processes are ready.
  112776. * @hidden
  112777. */
  112778. _isReady(): boolean;
  112779. }
  112780. }
  112781. declare module BABYLON {
  112782. /** @hidden */
  112783. export var displayPassPixelShader: {
  112784. name: string;
  112785. shader: string;
  112786. };
  112787. }
  112788. declare module BABYLON {
  112789. /**
  112790. * DisplayPassPostProcess which produces an output the same as it's input
  112791. */
  112792. export class DisplayPassPostProcess extends PostProcess {
  112793. /**
  112794. * Creates the DisplayPassPostProcess
  112795. * @param name The name of the effect.
  112796. * @param options The required width/height ratio to downsize to before computing the render pass.
  112797. * @param camera The camera to apply the render pass to.
  112798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112799. * @param engine The engine which the post process will be applied. (default: current engine)
  112800. * @param reusable If the post process can be reused on the same frame. (default: false)
  112801. */
  112802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112803. }
  112804. }
  112805. declare module BABYLON {
  112806. /** @hidden */
  112807. export var filterPixelShader: {
  112808. name: string;
  112809. shader: string;
  112810. };
  112811. }
  112812. declare module BABYLON {
  112813. /**
  112814. * Applies a kernel filter to the image
  112815. */
  112816. export class FilterPostProcess extends PostProcess {
  112817. /** The matrix to be applied to the image */
  112818. kernelMatrix: Matrix;
  112819. /**
  112820. *
  112821. * @param name The name of the effect.
  112822. * @param kernelMatrix The matrix to be applied to the image
  112823. * @param options The required width/height ratio to downsize to before computing the render pass.
  112824. * @param camera The camera to apply the render pass to.
  112825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112826. * @param engine The engine which the post process will be applied. (default: current engine)
  112827. * @param reusable If the post process can be reused on the same frame. (default: false)
  112828. */
  112829. constructor(name: string,
  112830. /** The matrix to be applied to the image */
  112831. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112832. }
  112833. }
  112834. declare module BABYLON {
  112835. /** @hidden */
  112836. export var fxaaPixelShader: {
  112837. name: string;
  112838. shader: string;
  112839. };
  112840. }
  112841. declare module BABYLON {
  112842. /** @hidden */
  112843. export var fxaaVertexShader: {
  112844. name: string;
  112845. shader: string;
  112846. };
  112847. }
  112848. declare module BABYLON {
  112849. /**
  112850. * Fxaa post process
  112851. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112852. */
  112853. export class FxaaPostProcess extends PostProcess {
  112854. /** @hidden */
  112855. texelWidth: number;
  112856. /** @hidden */
  112857. texelHeight: number;
  112858. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112859. private _getDefines;
  112860. }
  112861. }
  112862. declare module BABYLON {
  112863. /** @hidden */
  112864. export var grainPixelShader: {
  112865. name: string;
  112866. shader: string;
  112867. };
  112868. }
  112869. declare module BABYLON {
  112870. /**
  112871. * The GrainPostProcess adds noise to the image at mid luminance levels
  112872. */
  112873. export class GrainPostProcess extends PostProcess {
  112874. /**
  112875. * The intensity of the grain added (default: 30)
  112876. */
  112877. intensity: number;
  112878. /**
  112879. * If the grain should be randomized on every frame
  112880. */
  112881. animated: boolean;
  112882. /**
  112883. * Creates a new instance of @see GrainPostProcess
  112884. * @param name The name of the effect.
  112885. * @param options The required width/height ratio to downsize to before computing the render pass.
  112886. * @param camera The camera to apply the render pass to.
  112887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112888. * @param engine The engine which the post process will be applied. (default: current engine)
  112889. * @param reusable If the post process can be reused on the same frame. (default: false)
  112890. * @param textureType Type of textures used when performing the post process. (default: 0)
  112891. * @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)
  112892. */
  112893. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112894. }
  112895. }
  112896. declare module BABYLON {
  112897. /** @hidden */
  112898. export var highlightsPixelShader: {
  112899. name: string;
  112900. shader: string;
  112901. };
  112902. }
  112903. declare module BABYLON {
  112904. /**
  112905. * Extracts highlights from the image
  112906. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112907. */
  112908. export class HighlightsPostProcess extends PostProcess {
  112909. /**
  112910. * Extracts highlights from the image
  112911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112912. * @param name The name of the effect.
  112913. * @param options The required width/height ratio to downsize to before computing the render pass.
  112914. * @param camera The camera to apply the render pass to.
  112915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112916. * @param engine The engine which the post process will be applied. (default: current engine)
  112917. * @param reusable If the post process can be reused on the same frame. (default: false)
  112918. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112919. */
  112920. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112921. }
  112922. }
  112923. declare module BABYLON {
  112924. /** @hidden */
  112925. export var mrtFragmentDeclaration: {
  112926. name: string;
  112927. shader: string;
  112928. };
  112929. }
  112930. declare module BABYLON {
  112931. /** @hidden */
  112932. export var geometryPixelShader: {
  112933. name: string;
  112934. shader: string;
  112935. };
  112936. }
  112937. declare module BABYLON {
  112938. /** @hidden */
  112939. export var geometryVertexShader: {
  112940. name: string;
  112941. shader: string;
  112942. };
  112943. }
  112944. declare module BABYLON {
  112945. /**
  112946. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112947. */
  112948. export class GeometryBufferRenderer {
  112949. /**
  112950. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112951. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112952. */
  112953. static readonly POSITION_TEXTURE_TYPE: number;
  112954. /**
  112955. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112956. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112957. */
  112958. static readonly VELOCITY_TEXTURE_TYPE: number;
  112959. /**
  112960. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112961. * in order to compute objects velocities when enableVelocity is set to "true"
  112962. * @hidden
  112963. */
  112964. _previousTransformationMatrices: {
  112965. [index: number]: Matrix;
  112966. };
  112967. private _scene;
  112968. private _multiRenderTarget;
  112969. private _ratio;
  112970. private _enablePosition;
  112971. private _enableVelocity;
  112972. private _positionIndex;
  112973. private _velocityIndex;
  112974. protected _effect: Effect;
  112975. protected _cachedDefines: string;
  112976. /**
  112977. * Set the render list (meshes to be rendered) used in the G buffer.
  112978. */
  112979. renderList: Mesh[];
  112980. /**
  112981. * Gets wether or not G buffer are supported by the running hardware.
  112982. * This requires draw buffer supports
  112983. */
  112984. readonly isSupported: boolean;
  112985. /**
  112986. * Returns the index of the given texture type in the G-Buffer textures array
  112987. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112988. * @returns the index of the given texture type in the G-Buffer textures array
  112989. */
  112990. getTextureIndex(textureType: number): number;
  112991. /**
  112992. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112993. */
  112994. /**
  112995. * Sets whether or not objects positions are enabled for the G buffer.
  112996. */
  112997. enablePosition: boolean;
  112998. /**
  112999. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  113000. */
  113001. /**
  113002. * Sets wether or not objects velocities are enabled for the G buffer.
  113003. */
  113004. enableVelocity: boolean;
  113005. /**
  113006. * Gets the scene associated with the buffer.
  113007. */
  113008. readonly scene: Scene;
  113009. /**
  113010. * Gets the ratio used by the buffer during its creation.
  113011. * How big is the buffer related to the main canvas.
  113012. */
  113013. readonly ratio: number;
  113014. /** @hidden */
  113015. static _SceneComponentInitialization: (scene: Scene) => void;
  113016. /**
  113017. * Creates a new G Buffer for the scene
  113018. * @param scene The scene the buffer belongs to
  113019. * @param ratio How big is the buffer related to the main canvas.
  113020. */
  113021. constructor(scene: Scene, ratio?: number);
  113022. /**
  113023. * Checks wether everything is ready to render a submesh to the G buffer.
  113024. * @param subMesh the submesh to check readiness for
  113025. * @param useInstances is the mesh drawn using instance or not
  113026. * @returns true if ready otherwise false
  113027. */
  113028. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113029. /**
  113030. * Gets the current underlying G Buffer.
  113031. * @returns the buffer
  113032. */
  113033. getGBuffer(): MultiRenderTarget;
  113034. /**
  113035. * Gets the number of samples used to render the buffer (anti aliasing).
  113036. */
  113037. /**
  113038. * Sets the number of samples used to render the buffer (anti aliasing).
  113039. */
  113040. samples: number;
  113041. /**
  113042. * Disposes the renderer and frees up associated resources.
  113043. */
  113044. dispose(): void;
  113045. protected _createRenderTargets(): void;
  113046. }
  113047. }
  113048. declare module BABYLON {
  113049. interface Scene {
  113050. /** @hidden (Backing field) */
  113051. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113052. /**
  113053. * Gets or Sets the current geometry buffer associated to the scene.
  113054. */
  113055. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113056. /**
  113057. * Enables a GeometryBufferRender and associates it with the scene
  113058. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  113059. * @returns the GeometryBufferRenderer
  113060. */
  113061. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  113062. /**
  113063. * Disables the GeometryBufferRender associated with the scene
  113064. */
  113065. disableGeometryBufferRenderer(): void;
  113066. }
  113067. /**
  113068. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  113069. * in several rendering techniques.
  113070. */
  113071. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  113072. /**
  113073. * The component name helpful to identify the component in the list of scene components.
  113074. */
  113075. readonly name: string;
  113076. /**
  113077. * The scene the component belongs to.
  113078. */
  113079. scene: Scene;
  113080. /**
  113081. * Creates a new instance of the component for the given scene
  113082. * @param scene Defines the scene to register the component in
  113083. */
  113084. constructor(scene: Scene);
  113085. /**
  113086. * Registers the component in a given scene
  113087. */
  113088. register(): void;
  113089. /**
  113090. * Rebuilds the elements related to this component in case of
  113091. * context lost for instance.
  113092. */
  113093. rebuild(): void;
  113094. /**
  113095. * Disposes the component and the associated ressources
  113096. */
  113097. dispose(): void;
  113098. private _gatherRenderTargets;
  113099. }
  113100. }
  113101. declare module BABYLON {
  113102. /** @hidden */
  113103. export var motionBlurPixelShader: {
  113104. name: string;
  113105. shader: string;
  113106. };
  113107. }
  113108. declare module BABYLON {
  113109. /**
  113110. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  113111. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  113112. * As an example, all you have to do is to create the post-process:
  113113. * var mb = new BABYLON.MotionBlurPostProcess(
  113114. * 'mb', // The name of the effect.
  113115. * scene, // The scene containing the objects to blur according to their velocity.
  113116. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  113117. * camera // The camera to apply the render pass to.
  113118. * );
  113119. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  113120. */
  113121. export class MotionBlurPostProcess extends PostProcess {
  113122. /**
  113123. * Defines how much the image is blurred by the movement. Default value is equal to 1
  113124. */
  113125. motionStrength: number;
  113126. /**
  113127. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  113128. */
  113129. /**
  113130. * Sets the number of iterations to be used for motion blur quality
  113131. */
  113132. motionBlurSamples: number;
  113133. private _motionBlurSamples;
  113134. private _geometryBufferRenderer;
  113135. /**
  113136. * Creates a new instance MotionBlurPostProcess
  113137. * @param name The name of the effect.
  113138. * @param scene The scene containing the objects to blur according to their velocity.
  113139. * @param options The required width/height ratio to downsize to before computing the render pass.
  113140. * @param camera The camera to apply the render pass to.
  113141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113142. * @param engine The engine which the post process will be applied. (default: current engine)
  113143. * @param reusable If the post process can be reused on the same frame. (default: false)
  113144. * @param textureType Type of textures used when performing the post process. (default: 0)
  113145. * @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)
  113146. */
  113147. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113148. /**
  113149. * Disposes the post process.
  113150. * @param camera The camera to dispose the post process on.
  113151. */
  113152. dispose(camera?: Camera): void;
  113153. }
  113154. }
  113155. declare module BABYLON {
  113156. /** @hidden */
  113157. export var refractionPixelShader: {
  113158. name: string;
  113159. shader: string;
  113160. };
  113161. }
  113162. declare module BABYLON {
  113163. /**
  113164. * Post process which applies a refractin texture
  113165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113166. */
  113167. export class RefractionPostProcess extends PostProcess {
  113168. /** the base color of the refraction (used to taint the rendering) */
  113169. color: Color3;
  113170. /** simulated refraction depth */
  113171. depth: number;
  113172. /** the coefficient of the base color (0 to remove base color tainting) */
  113173. colorLevel: number;
  113174. private _refTexture;
  113175. private _ownRefractionTexture;
  113176. /**
  113177. * Gets or sets the refraction texture
  113178. * Please note that you are responsible for disposing the texture if you set it manually
  113179. */
  113180. refractionTexture: Texture;
  113181. /**
  113182. * Initializes the RefractionPostProcess
  113183. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113184. * @param name The name of the effect.
  113185. * @param refractionTextureUrl Url of the refraction texture to use
  113186. * @param color the base color of the refraction (used to taint the rendering)
  113187. * @param depth simulated refraction depth
  113188. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  113189. * @param camera The camera to apply the render pass to.
  113190. * @param options The required width/height ratio to downsize to before computing the render pass.
  113191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113192. * @param engine The engine which the post process will be applied. (default: current engine)
  113193. * @param reusable If the post process can be reused on the same frame. (default: false)
  113194. */
  113195. constructor(name: string, refractionTextureUrl: string,
  113196. /** the base color of the refraction (used to taint the rendering) */
  113197. color: Color3,
  113198. /** simulated refraction depth */
  113199. depth: number,
  113200. /** the coefficient of the base color (0 to remove base color tainting) */
  113201. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113202. /**
  113203. * Disposes of the post process
  113204. * @param camera Camera to dispose post process on
  113205. */
  113206. dispose(camera: Camera): void;
  113207. }
  113208. }
  113209. declare module BABYLON {
  113210. /** @hidden */
  113211. export var sharpenPixelShader: {
  113212. name: string;
  113213. shader: string;
  113214. };
  113215. }
  113216. declare module BABYLON {
  113217. /**
  113218. * The SharpenPostProcess applies a sharpen kernel to every pixel
  113219. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  113220. */
  113221. export class SharpenPostProcess extends PostProcess {
  113222. /**
  113223. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  113224. */
  113225. colorAmount: number;
  113226. /**
  113227. * How much sharpness should be applied (default: 0.3)
  113228. */
  113229. edgeAmount: number;
  113230. /**
  113231. * Creates a new instance ConvolutionPostProcess
  113232. * @param name The name of the effect.
  113233. * @param options The required width/height ratio to downsize to before computing the render pass.
  113234. * @param camera The camera to apply the render pass to.
  113235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113236. * @param engine The engine which the post process will be applied. (default: current engine)
  113237. * @param reusable If the post process can be reused on the same frame. (default: false)
  113238. * @param textureType Type of textures used when performing the post process. (default: 0)
  113239. * @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)
  113240. */
  113241. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113242. }
  113243. }
  113244. declare module BABYLON {
  113245. /**
  113246. * PostProcessRenderPipeline
  113247. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113248. */
  113249. export class PostProcessRenderPipeline {
  113250. private engine;
  113251. private _renderEffects;
  113252. private _renderEffectsForIsolatedPass;
  113253. /**
  113254. * List of inspectable custom properties (used by the Inspector)
  113255. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113256. */
  113257. inspectableCustomProperties: IInspectable[];
  113258. /**
  113259. * @hidden
  113260. */
  113261. protected _cameras: Camera[];
  113262. /** @hidden */
  113263. _name: string;
  113264. /**
  113265. * Gets pipeline name
  113266. */
  113267. readonly name: string;
  113268. /**
  113269. * Initializes a PostProcessRenderPipeline
  113270. * @param engine engine to add the pipeline to
  113271. * @param name name of the pipeline
  113272. */
  113273. constructor(engine: Engine, name: string);
  113274. /**
  113275. * Gets the class name
  113276. * @returns "PostProcessRenderPipeline"
  113277. */
  113278. getClassName(): string;
  113279. /**
  113280. * If all the render effects in the pipeline are supported
  113281. */
  113282. readonly isSupported: boolean;
  113283. /**
  113284. * Adds an effect to the pipeline
  113285. * @param renderEffect the effect to add
  113286. */
  113287. addEffect(renderEffect: PostProcessRenderEffect): void;
  113288. /** @hidden */
  113289. _rebuild(): void;
  113290. /** @hidden */
  113291. _enableEffect(renderEffectName: string, cameras: Camera): void;
  113292. /** @hidden */
  113293. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  113294. /** @hidden */
  113295. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113296. /** @hidden */
  113297. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113298. /** @hidden */
  113299. _attachCameras(cameras: Camera, unique: boolean): void;
  113300. /** @hidden */
  113301. _attachCameras(cameras: Camera[], unique: boolean): void;
  113302. /** @hidden */
  113303. _detachCameras(cameras: Camera): void;
  113304. /** @hidden */
  113305. _detachCameras(cameras: Nullable<Camera[]>): void;
  113306. /** @hidden */
  113307. _update(): void;
  113308. /** @hidden */
  113309. _reset(): void;
  113310. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  113311. /**
  113312. * Disposes of the pipeline
  113313. */
  113314. dispose(): void;
  113315. }
  113316. }
  113317. declare module BABYLON {
  113318. /**
  113319. * PostProcessRenderPipelineManager class
  113320. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113321. */
  113322. export class PostProcessRenderPipelineManager {
  113323. private _renderPipelines;
  113324. /**
  113325. * Initializes a PostProcessRenderPipelineManager
  113326. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113327. */
  113328. constructor();
  113329. /**
  113330. * Gets the list of supported render pipelines
  113331. */
  113332. readonly supportedPipelines: PostProcessRenderPipeline[];
  113333. /**
  113334. * Adds a pipeline to the manager
  113335. * @param renderPipeline The pipeline to add
  113336. */
  113337. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  113338. /**
  113339. * Attaches a camera to the pipeline
  113340. * @param renderPipelineName The name of the pipeline to attach to
  113341. * @param cameras the camera to attach
  113342. * @param unique if the camera can be attached multiple times to the pipeline
  113343. */
  113344. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  113345. /**
  113346. * Detaches a camera from the pipeline
  113347. * @param renderPipelineName The name of the pipeline to detach from
  113348. * @param cameras the camera to detach
  113349. */
  113350. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  113351. /**
  113352. * Enables an effect by name on a pipeline
  113353. * @param renderPipelineName the name of the pipeline to enable the effect in
  113354. * @param renderEffectName the name of the effect to enable
  113355. * @param cameras the cameras that the effect should be enabled on
  113356. */
  113357. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113358. /**
  113359. * Disables an effect by name on a pipeline
  113360. * @param renderPipelineName the name of the pipeline to disable the effect in
  113361. * @param renderEffectName the name of the effect to disable
  113362. * @param cameras the cameras that the effect should be disabled on
  113363. */
  113364. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113365. /**
  113366. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  113367. */
  113368. update(): void;
  113369. /** @hidden */
  113370. _rebuild(): void;
  113371. /**
  113372. * Disposes of the manager and pipelines
  113373. */
  113374. dispose(): void;
  113375. }
  113376. }
  113377. declare module BABYLON {
  113378. interface Scene {
  113379. /** @hidden (Backing field) */
  113380. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113381. /**
  113382. * Gets the postprocess render pipeline manager
  113383. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113384. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113385. */
  113386. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113387. }
  113388. /**
  113389. * Defines the Render Pipeline scene component responsible to rendering pipelines
  113390. */
  113391. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  113392. /**
  113393. * The component name helpfull to identify the component in the list of scene components.
  113394. */
  113395. readonly name: string;
  113396. /**
  113397. * The scene the component belongs to.
  113398. */
  113399. scene: Scene;
  113400. /**
  113401. * Creates a new instance of the component for the given scene
  113402. * @param scene Defines the scene to register the component in
  113403. */
  113404. constructor(scene: Scene);
  113405. /**
  113406. * Registers the component in a given scene
  113407. */
  113408. register(): void;
  113409. /**
  113410. * Rebuilds the elements related to this component in case of
  113411. * context lost for instance.
  113412. */
  113413. rebuild(): void;
  113414. /**
  113415. * Disposes the component and the associated ressources
  113416. */
  113417. dispose(): void;
  113418. private _gatherRenderTargets;
  113419. }
  113420. }
  113421. declare module BABYLON {
  113422. /**
  113423. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113424. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113425. */
  113426. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113427. private _scene;
  113428. private _camerasToBeAttached;
  113429. /**
  113430. * ID of the sharpen post process,
  113431. */
  113432. private readonly SharpenPostProcessId;
  113433. /**
  113434. * @ignore
  113435. * ID of the image processing post process;
  113436. */
  113437. readonly ImageProcessingPostProcessId: string;
  113438. /**
  113439. * @ignore
  113440. * ID of the Fast Approximate Anti-Aliasing post process;
  113441. */
  113442. readonly FxaaPostProcessId: string;
  113443. /**
  113444. * ID of the chromatic aberration post process,
  113445. */
  113446. private readonly ChromaticAberrationPostProcessId;
  113447. /**
  113448. * ID of the grain post process
  113449. */
  113450. private readonly GrainPostProcessId;
  113451. /**
  113452. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113453. */
  113454. sharpen: SharpenPostProcess;
  113455. private _sharpenEffect;
  113456. private bloom;
  113457. /**
  113458. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113459. */
  113460. depthOfField: DepthOfFieldEffect;
  113461. /**
  113462. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113463. */
  113464. fxaa: FxaaPostProcess;
  113465. /**
  113466. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113467. */
  113468. imageProcessing: ImageProcessingPostProcess;
  113469. /**
  113470. * Chromatic aberration post process which will shift rgb colors in the image
  113471. */
  113472. chromaticAberration: ChromaticAberrationPostProcess;
  113473. private _chromaticAberrationEffect;
  113474. /**
  113475. * Grain post process which add noise to the image
  113476. */
  113477. grain: GrainPostProcess;
  113478. private _grainEffect;
  113479. /**
  113480. * Glow post process which adds a glow to emissive areas of the image
  113481. */
  113482. private _glowLayer;
  113483. /**
  113484. * Animations which can be used to tweak settings over a period of time
  113485. */
  113486. animations: Animation[];
  113487. private _imageProcessingConfigurationObserver;
  113488. private _sharpenEnabled;
  113489. private _bloomEnabled;
  113490. private _depthOfFieldEnabled;
  113491. private _depthOfFieldBlurLevel;
  113492. private _fxaaEnabled;
  113493. private _imageProcessingEnabled;
  113494. private _defaultPipelineTextureType;
  113495. private _bloomScale;
  113496. private _chromaticAberrationEnabled;
  113497. private _grainEnabled;
  113498. private _buildAllowed;
  113499. /**
  113500. * Gets active scene
  113501. */
  113502. readonly scene: Scene;
  113503. /**
  113504. * Enable or disable the sharpen process from the pipeline
  113505. */
  113506. sharpenEnabled: boolean;
  113507. private _resizeObserver;
  113508. private _hardwareScaleLevel;
  113509. private _bloomKernel;
  113510. /**
  113511. * Specifies the size of the bloom blur kernel, relative to the final output size
  113512. */
  113513. bloomKernel: number;
  113514. /**
  113515. * Specifies the weight of the bloom in the final rendering
  113516. */
  113517. private _bloomWeight;
  113518. /**
  113519. * Specifies the luma threshold for the area that will be blurred by the bloom
  113520. */
  113521. private _bloomThreshold;
  113522. private _hdr;
  113523. /**
  113524. * The strength of the bloom.
  113525. */
  113526. bloomWeight: number;
  113527. /**
  113528. * The strength of the bloom.
  113529. */
  113530. bloomThreshold: number;
  113531. /**
  113532. * The scale of the bloom, lower value will provide better performance.
  113533. */
  113534. bloomScale: number;
  113535. /**
  113536. * Enable or disable the bloom from the pipeline
  113537. */
  113538. bloomEnabled: boolean;
  113539. private _rebuildBloom;
  113540. /**
  113541. * If the depth of field is enabled.
  113542. */
  113543. depthOfFieldEnabled: boolean;
  113544. /**
  113545. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113546. */
  113547. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113548. /**
  113549. * If the anti aliasing is enabled.
  113550. */
  113551. fxaaEnabled: boolean;
  113552. private _samples;
  113553. /**
  113554. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113555. */
  113556. samples: number;
  113557. /**
  113558. * If image processing is enabled.
  113559. */
  113560. imageProcessingEnabled: boolean;
  113561. /**
  113562. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113563. */
  113564. glowLayerEnabled: boolean;
  113565. /**
  113566. * Enable or disable the chromaticAberration process from the pipeline
  113567. */
  113568. chromaticAberrationEnabled: boolean;
  113569. /**
  113570. * Enable or disable the grain process from the pipeline
  113571. */
  113572. grainEnabled: boolean;
  113573. /**
  113574. * @constructor
  113575. * @param name - The rendering pipeline name (default: "")
  113576. * @param hdr - If high dynamic range textures should be used (default: true)
  113577. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113578. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113579. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113580. */
  113581. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113582. /**
  113583. * Get the class name
  113584. * @returns "DefaultRenderingPipeline"
  113585. */
  113586. getClassName(): string;
  113587. /**
  113588. * Force the compilation of the entire pipeline.
  113589. */
  113590. prepare(): void;
  113591. private _hasCleared;
  113592. private _prevPostProcess;
  113593. private _prevPrevPostProcess;
  113594. private _setAutoClearAndTextureSharing;
  113595. private _depthOfFieldSceneObserver;
  113596. private _buildPipeline;
  113597. private _disposePostProcesses;
  113598. /**
  113599. * Adds a camera to the pipeline
  113600. * @param camera the camera to be added
  113601. */
  113602. addCamera(camera: Camera): void;
  113603. /**
  113604. * Removes a camera from the pipeline
  113605. * @param camera the camera to remove
  113606. */
  113607. removeCamera(camera: Camera): void;
  113608. /**
  113609. * Dispose of the pipeline and stop all post processes
  113610. */
  113611. dispose(): void;
  113612. /**
  113613. * Serialize the rendering pipeline (Used when exporting)
  113614. * @returns the serialized object
  113615. */
  113616. serialize(): any;
  113617. /**
  113618. * Parse the serialized pipeline
  113619. * @param source Source pipeline.
  113620. * @param scene The scene to load the pipeline to.
  113621. * @param rootUrl The URL of the serialized pipeline.
  113622. * @returns An instantiated pipeline from the serialized object.
  113623. */
  113624. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113625. }
  113626. }
  113627. declare module BABYLON {
  113628. /** @hidden */
  113629. export var lensHighlightsPixelShader: {
  113630. name: string;
  113631. shader: string;
  113632. };
  113633. }
  113634. declare module BABYLON {
  113635. /** @hidden */
  113636. export var depthOfFieldPixelShader: {
  113637. name: string;
  113638. shader: string;
  113639. };
  113640. }
  113641. declare module BABYLON {
  113642. /**
  113643. * BABYLON.JS Chromatic Aberration GLSL Shader
  113644. * Author: Olivier Guyot
  113645. * Separates very slightly R, G and B colors on the edges of the screen
  113646. * Inspired by Francois Tarlier & Martins Upitis
  113647. */
  113648. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113649. /**
  113650. * @ignore
  113651. * The chromatic aberration PostProcess id in the pipeline
  113652. */
  113653. LensChromaticAberrationEffect: string;
  113654. /**
  113655. * @ignore
  113656. * The highlights enhancing PostProcess id in the pipeline
  113657. */
  113658. HighlightsEnhancingEffect: string;
  113659. /**
  113660. * @ignore
  113661. * The depth-of-field PostProcess id in the pipeline
  113662. */
  113663. LensDepthOfFieldEffect: string;
  113664. private _scene;
  113665. private _depthTexture;
  113666. private _grainTexture;
  113667. private _chromaticAberrationPostProcess;
  113668. private _highlightsPostProcess;
  113669. private _depthOfFieldPostProcess;
  113670. private _edgeBlur;
  113671. private _grainAmount;
  113672. private _chromaticAberration;
  113673. private _distortion;
  113674. private _highlightsGain;
  113675. private _highlightsThreshold;
  113676. private _dofDistance;
  113677. private _dofAperture;
  113678. private _dofDarken;
  113679. private _dofPentagon;
  113680. private _blurNoise;
  113681. /**
  113682. * @constructor
  113683. *
  113684. * Effect parameters are as follow:
  113685. * {
  113686. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113687. * edge_blur: number; // from 0 to x (1 for realism)
  113688. * distortion: number; // from 0 to x (1 for realism)
  113689. * grain_amount: number; // from 0 to 1
  113690. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113691. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113692. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113693. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113694. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113695. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113696. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113697. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113698. * }
  113699. * Note: if an effect parameter is unset, effect is disabled
  113700. *
  113701. * @param name The rendering pipeline name
  113702. * @param parameters - An object containing all parameters (see above)
  113703. * @param scene The scene linked to this pipeline
  113704. * @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)
  113705. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113706. */
  113707. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113708. /**
  113709. * Get the class name
  113710. * @returns "LensRenderingPipeline"
  113711. */
  113712. getClassName(): string;
  113713. /**
  113714. * Gets associated scene
  113715. */
  113716. readonly scene: Scene;
  113717. /**
  113718. * Gets or sets the edge blur
  113719. */
  113720. edgeBlur: number;
  113721. /**
  113722. * Gets or sets the grain amount
  113723. */
  113724. grainAmount: number;
  113725. /**
  113726. * Gets or sets the chromatic aberration amount
  113727. */
  113728. chromaticAberration: number;
  113729. /**
  113730. * Gets or sets the depth of field aperture
  113731. */
  113732. dofAperture: number;
  113733. /**
  113734. * Gets or sets the edge distortion
  113735. */
  113736. edgeDistortion: number;
  113737. /**
  113738. * Gets or sets the depth of field distortion
  113739. */
  113740. dofDistortion: number;
  113741. /**
  113742. * Gets or sets the darken out of focus amount
  113743. */
  113744. darkenOutOfFocus: number;
  113745. /**
  113746. * Gets or sets a boolean indicating if blur noise is enabled
  113747. */
  113748. blurNoise: boolean;
  113749. /**
  113750. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113751. */
  113752. pentagonBokeh: boolean;
  113753. /**
  113754. * Gets or sets the highlight grain amount
  113755. */
  113756. highlightsGain: number;
  113757. /**
  113758. * Gets or sets the highlight threshold
  113759. */
  113760. highlightsThreshold: number;
  113761. /**
  113762. * Sets the amount of blur at the edges
  113763. * @param amount blur amount
  113764. */
  113765. setEdgeBlur(amount: number): void;
  113766. /**
  113767. * Sets edge blur to 0
  113768. */
  113769. disableEdgeBlur(): void;
  113770. /**
  113771. * Sets the amout of grain
  113772. * @param amount Amount of grain
  113773. */
  113774. setGrainAmount(amount: number): void;
  113775. /**
  113776. * Set grain amount to 0
  113777. */
  113778. disableGrain(): void;
  113779. /**
  113780. * Sets the chromatic aberration amount
  113781. * @param amount amount of chromatic aberration
  113782. */
  113783. setChromaticAberration(amount: number): void;
  113784. /**
  113785. * Sets chromatic aberration amount to 0
  113786. */
  113787. disableChromaticAberration(): void;
  113788. /**
  113789. * Sets the EdgeDistortion amount
  113790. * @param amount amount of EdgeDistortion
  113791. */
  113792. setEdgeDistortion(amount: number): void;
  113793. /**
  113794. * Sets edge distortion to 0
  113795. */
  113796. disableEdgeDistortion(): void;
  113797. /**
  113798. * Sets the FocusDistance amount
  113799. * @param amount amount of FocusDistance
  113800. */
  113801. setFocusDistance(amount: number): void;
  113802. /**
  113803. * Disables depth of field
  113804. */
  113805. disableDepthOfField(): void;
  113806. /**
  113807. * Sets the Aperture amount
  113808. * @param amount amount of Aperture
  113809. */
  113810. setAperture(amount: number): void;
  113811. /**
  113812. * Sets the DarkenOutOfFocus amount
  113813. * @param amount amount of DarkenOutOfFocus
  113814. */
  113815. setDarkenOutOfFocus(amount: number): void;
  113816. private _pentagonBokehIsEnabled;
  113817. /**
  113818. * Creates a pentagon bokeh effect
  113819. */
  113820. enablePentagonBokeh(): void;
  113821. /**
  113822. * Disables the pentagon bokeh effect
  113823. */
  113824. disablePentagonBokeh(): void;
  113825. /**
  113826. * Enables noise blur
  113827. */
  113828. enableNoiseBlur(): void;
  113829. /**
  113830. * Disables noise blur
  113831. */
  113832. disableNoiseBlur(): void;
  113833. /**
  113834. * Sets the HighlightsGain amount
  113835. * @param amount amount of HighlightsGain
  113836. */
  113837. setHighlightsGain(amount: number): void;
  113838. /**
  113839. * Sets the HighlightsThreshold amount
  113840. * @param amount amount of HighlightsThreshold
  113841. */
  113842. setHighlightsThreshold(amount: number): void;
  113843. /**
  113844. * Disables highlights
  113845. */
  113846. disableHighlights(): void;
  113847. /**
  113848. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113849. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113850. */
  113851. dispose(disableDepthRender?: boolean): void;
  113852. private _createChromaticAberrationPostProcess;
  113853. private _createHighlightsPostProcess;
  113854. private _createDepthOfFieldPostProcess;
  113855. private _createGrainTexture;
  113856. }
  113857. }
  113858. declare module BABYLON {
  113859. /** @hidden */
  113860. export var ssao2PixelShader: {
  113861. name: string;
  113862. shader: string;
  113863. };
  113864. }
  113865. declare module BABYLON {
  113866. /** @hidden */
  113867. export var ssaoCombinePixelShader: {
  113868. name: string;
  113869. shader: string;
  113870. };
  113871. }
  113872. declare module BABYLON {
  113873. /**
  113874. * Render pipeline to produce ssao effect
  113875. */
  113876. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113877. /**
  113878. * @ignore
  113879. * The PassPostProcess id in the pipeline that contains the original scene color
  113880. */
  113881. SSAOOriginalSceneColorEffect: string;
  113882. /**
  113883. * @ignore
  113884. * The SSAO PostProcess id in the pipeline
  113885. */
  113886. SSAORenderEffect: string;
  113887. /**
  113888. * @ignore
  113889. * The horizontal blur PostProcess id in the pipeline
  113890. */
  113891. SSAOBlurHRenderEffect: string;
  113892. /**
  113893. * @ignore
  113894. * The vertical blur PostProcess id in the pipeline
  113895. */
  113896. SSAOBlurVRenderEffect: string;
  113897. /**
  113898. * @ignore
  113899. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113900. */
  113901. SSAOCombineRenderEffect: string;
  113902. /**
  113903. * The output strength of the SSAO post-process. Default value is 1.0.
  113904. */
  113905. totalStrength: number;
  113906. /**
  113907. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113908. */
  113909. maxZ: number;
  113910. /**
  113911. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113912. */
  113913. minZAspect: number;
  113914. private _samples;
  113915. /**
  113916. * Number of samples used for the SSAO calculations. Default value is 8
  113917. */
  113918. samples: number;
  113919. private _textureSamples;
  113920. /**
  113921. * Number of samples to use for antialiasing
  113922. */
  113923. textureSamples: number;
  113924. /**
  113925. * Ratio object used for SSAO ratio and blur ratio
  113926. */
  113927. private _ratio;
  113928. /**
  113929. * Dynamically generated sphere sampler.
  113930. */
  113931. private _sampleSphere;
  113932. /**
  113933. * Blur filter offsets
  113934. */
  113935. private _samplerOffsets;
  113936. private _expensiveBlur;
  113937. /**
  113938. * If bilateral blur should be used
  113939. */
  113940. expensiveBlur: boolean;
  113941. /**
  113942. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113943. */
  113944. radius: number;
  113945. /**
  113946. * The base color of the SSAO post-process
  113947. * The final result is "base + ssao" between [0, 1]
  113948. */
  113949. base: number;
  113950. /**
  113951. * Support test.
  113952. */
  113953. static readonly IsSupported: boolean;
  113954. private _scene;
  113955. private _depthTexture;
  113956. private _normalTexture;
  113957. private _randomTexture;
  113958. private _originalColorPostProcess;
  113959. private _ssaoPostProcess;
  113960. private _blurHPostProcess;
  113961. private _blurVPostProcess;
  113962. private _ssaoCombinePostProcess;
  113963. private _firstUpdate;
  113964. /**
  113965. * Gets active scene
  113966. */
  113967. readonly scene: Scene;
  113968. /**
  113969. * @constructor
  113970. * @param name The rendering pipeline name
  113971. * @param scene The scene linked to this pipeline
  113972. * @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 }
  113973. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113974. */
  113975. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113976. /**
  113977. * Get the class name
  113978. * @returns "SSAO2RenderingPipeline"
  113979. */
  113980. getClassName(): string;
  113981. /**
  113982. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113983. */
  113984. dispose(disableGeometryBufferRenderer?: boolean): void;
  113985. private _createBlurPostProcess;
  113986. /** @hidden */
  113987. _rebuild(): void;
  113988. private _bits;
  113989. private _radicalInverse_VdC;
  113990. private _hammersley;
  113991. private _hemisphereSample_uniform;
  113992. private _generateHemisphere;
  113993. private _createSSAOPostProcess;
  113994. private _createSSAOCombinePostProcess;
  113995. private _createRandomTexture;
  113996. /**
  113997. * Serialize the rendering pipeline (Used when exporting)
  113998. * @returns the serialized object
  113999. */
  114000. serialize(): any;
  114001. /**
  114002. * Parse the serialized pipeline
  114003. * @param source Source pipeline.
  114004. * @param scene The scene to load the pipeline to.
  114005. * @param rootUrl The URL of the serialized pipeline.
  114006. * @returns An instantiated pipeline from the serialized object.
  114007. */
  114008. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  114009. }
  114010. }
  114011. declare module BABYLON {
  114012. /** @hidden */
  114013. export var ssaoPixelShader: {
  114014. name: string;
  114015. shader: string;
  114016. };
  114017. }
  114018. declare module BABYLON {
  114019. /**
  114020. * Render pipeline to produce ssao effect
  114021. */
  114022. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  114023. /**
  114024. * @ignore
  114025. * The PassPostProcess id in the pipeline that contains the original scene color
  114026. */
  114027. SSAOOriginalSceneColorEffect: string;
  114028. /**
  114029. * @ignore
  114030. * The SSAO PostProcess id in the pipeline
  114031. */
  114032. SSAORenderEffect: string;
  114033. /**
  114034. * @ignore
  114035. * The horizontal blur PostProcess id in the pipeline
  114036. */
  114037. SSAOBlurHRenderEffect: string;
  114038. /**
  114039. * @ignore
  114040. * The vertical blur PostProcess id in the pipeline
  114041. */
  114042. SSAOBlurVRenderEffect: string;
  114043. /**
  114044. * @ignore
  114045. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114046. */
  114047. SSAOCombineRenderEffect: string;
  114048. /**
  114049. * The output strength of the SSAO post-process. Default value is 1.0.
  114050. */
  114051. totalStrength: number;
  114052. /**
  114053. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114054. */
  114055. radius: number;
  114056. /**
  114057. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114058. * Must not be equal to fallOff and superior to fallOff.
  114059. * Default value is 0.0075
  114060. */
  114061. area: number;
  114062. /**
  114063. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114064. * Must not be equal to area and inferior to area.
  114065. * Default value is 0.000001
  114066. */
  114067. fallOff: number;
  114068. /**
  114069. * The base color of the SSAO post-process
  114070. * The final result is "base + ssao" between [0, 1]
  114071. */
  114072. base: number;
  114073. private _scene;
  114074. private _depthTexture;
  114075. private _randomTexture;
  114076. private _originalColorPostProcess;
  114077. private _ssaoPostProcess;
  114078. private _blurHPostProcess;
  114079. private _blurVPostProcess;
  114080. private _ssaoCombinePostProcess;
  114081. private _firstUpdate;
  114082. /**
  114083. * Gets active scene
  114084. */
  114085. readonly scene: Scene;
  114086. /**
  114087. * @constructor
  114088. * @param name - The rendering pipeline name
  114089. * @param scene - The scene linked to this pipeline
  114090. * @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 }
  114091. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114092. */
  114093. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114094. /**
  114095. * Get the class name
  114096. * @returns "SSAORenderingPipeline"
  114097. */
  114098. getClassName(): string;
  114099. /**
  114100. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114101. */
  114102. dispose(disableDepthRender?: boolean): void;
  114103. private _createBlurPostProcess;
  114104. /** @hidden */
  114105. _rebuild(): void;
  114106. private _createSSAOPostProcess;
  114107. private _createSSAOCombinePostProcess;
  114108. private _createRandomTexture;
  114109. }
  114110. }
  114111. declare module BABYLON {
  114112. /** @hidden */
  114113. export var standardPixelShader: {
  114114. name: string;
  114115. shader: string;
  114116. };
  114117. }
  114118. declare module BABYLON {
  114119. /**
  114120. * Standard rendering pipeline
  114121. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114122. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114123. */
  114124. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  114125. /**
  114126. * Public members
  114127. */
  114128. /**
  114129. * Post-process which contains the original scene color before the pipeline applies all the effects
  114130. */
  114131. originalPostProcess: Nullable<PostProcess>;
  114132. /**
  114133. * Post-process used to down scale an image x4
  114134. */
  114135. downSampleX4PostProcess: Nullable<PostProcess>;
  114136. /**
  114137. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114138. */
  114139. brightPassPostProcess: Nullable<PostProcess>;
  114140. /**
  114141. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114142. */
  114143. blurHPostProcesses: PostProcess[];
  114144. /**
  114145. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114146. */
  114147. blurVPostProcesses: PostProcess[];
  114148. /**
  114149. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114150. */
  114151. textureAdderPostProcess: Nullable<PostProcess>;
  114152. /**
  114153. * Post-process used to create volumetric lighting effect
  114154. */
  114155. volumetricLightPostProcess: Nullable<PostProcess>;
  114156. /**
  114157. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114158. */
  114159. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  114160. /**
  114161. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114162. */
  114163. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  114164. /**
  114165. * Post-process used to merge the volumetric light effect and the real scene color
  114166. */
  114167. volumetricLightMergePostProces: Nullable<PostProcess>;
  114168. /**
  114169. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114170. */
  114171. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  114172. /**
  114173. * Base post-process used to calculate the average luminance of the final image for HDR
  114174. */
  114175. luminancePostProcess: Nullable<PostProcess>;
  114176. /**
  114177. * Post-processes used to create down sample post-processes in order to get
  114178. * the average luminance of the final image for HDR
  114179. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114180. */
  114181. luminanceDownSamplePostProcesses: PostProcess[];
  114182. /**
  114183. * Post-process used to create a HDR effect (light adaptation)
  114184. */
  114185. hdrPostProcess: Nullable<PostProcess>;
  114186. /**
  114187. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114188. */
  114189. textureAdderFinalPostProcess: Nullable<PostProcess>;
  114190. /**
  114191. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114192. */
  114193. lensFlareFinalPostProcess: Nullable<PostProcess>;
  114194. /**
  114195. * Post-process used to merge the final HDR post-process and the real scene color
  114196. */
  114197. hdrFinalPostProcess: Nullable<PostProcess>;
  114198. /**
  114199. * Post-process used to create a lens flare effect
  114200. */
  114201. lensFlarePostProcess: Nullable<PostProcess>;
  114202. /**
  114203. * Post-process that merges the result of the lens flare post-process and the real scene color
  114204. */
  114205. lensFlareComposePostProcess: Nullable<PostProcess>;
  114206. /**
  114207. * Post-process used to create a motion blur effect
  114208. */
  114209. motionBlurPostProcess: Nullable<PostProcess>;
  114210. /**
  114211. * Post-process used to create a depth of field effect
  114212. */
  114213. depthOfFieldPostProcess: Nullable<PostProcess>;
  114214. /**
  114215. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114216. */
  114217. fxaaPostProcess: Nullable<FxaaPostProcess>;
  114218. /**
  114219. * Represents the brightness threshold in order to configure the illuminated surfaces
  114220. */
  114221. brightThreshold: number;
  114222. /**
  114223. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114224. */
  114225. blurWidth: number;
  114226. /**
  114227. * Sets if the blur for highlighted surfaces must be only horizontal
  114228. */
  114229. horizontalBlur: boolean;
  114230. /**
  114231. * Gets the overall exposure used by the pipeline
  114232. */
  114233. /**
  114234. * Sets the overall exposure used by the pipeline
  114235. */
  114236. exposure: number;
  114237. /**
  114238. * Texture used typically to simulate "dirty" on camera lens
  114239. */
  114240. lensTexture: Nullable<Texture>;
  114241. /**
  114242. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114243. */
  114244. volumetricLightCoefficient: number;
  114245. /**
  114246. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114247. */
  114248. volumetricLightPower: number;
  114249. /**
  114250. * Used the set the blur intensity to smooth the volumetric lights
  114251. */
  114252. volumetricLightBlurScale: number;
  114253. /**
  114254. * Light (spot or directional) used to generate the volumetric lights rays
  114255. * The source light must have a shadow generate so the pipeline can get its
  114256. * depth map
  114257. */
  114258. sourceLight: Nullable<SpotLight | DirectionalLight>;
  114259. /**
  114260. * For eye adaptation, represents the minimum luminance the eye can see
  114261. */
  114262. hdrMinimumLuminance: number;
  114263. /**
  114264. * For eye adaptation, represents the decrease luminance speed
  114265. */
  114266. hdrDecreaseRate: number;
  114267. /**
  114268. * For eye adaptation, represents the increase luminance speed
  114269. */
  114270. hdrIncreaseRate: number;
  114271. /**
  114272. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114273. */
  114274. /**
  114275. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114276. */
  114277. hdrAutoExposure: boolean;
  114278. /**
  114279. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114280. */
  114281. lensColorTexture: Nullable<Texture>;
  114282. /**
  114283. * The overall strengh for the lens flare effect
  114284. */
  114285. lensFlareStrength: number;
  114286. /**
  114287. * Dispersion coefficient for lens flare ghosts
  114288. */
  114289. lensFlareGhostDispersal: number;
  114290. /**
  114291. * Main lens flare halo width
  114292. */
  114293. lensFlareHaloWidth: number;
  114294. /**
  114295. * Based on the lens distortion effect, defines how much the lens flare result
  114296. * is distorted
  114297. */
  114298. lensFlareDistortionStrength: number;
  114299. /**
  114300. * Lens star texture must be used to simulate rays on the flares and is available
  114301. * in the documentation
  114302. */
  114303. lensStarTexture: Nullable<Texture>;
  114304. /**
  114305. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114306. * flare effect by taking account of the dirt texture
  114307. */
  114308. lensFlareDirtTexture: Nullable<Texture>;
  114309. /**
  114310. * Represents the focal length for the depth of field effect
  114311. */
  114312. depthOfFieldDistance: number;
  114313. /**
  114314. * Represents the blur intensity for the blurred part of the depth of field effect
  114315. */
  114316. depthOfFieldBlurWidth: number;
  114317. /**
  114318. * For motion blur, defines how much the image is blurred by the movement
  114319. */
  114320. motionStrength: number;
  114321. /**
  114322. * List of animations for the pipeline (IAnimatable implementation)
  114323. */
  114324. animations: Animation[];
  114325. /**
  114326. * Private members
  114327. */
  114328. private _scene;
  114329. private _currentDepthOfFieldSource;
  114330. private _basePostProcess;
  114331. private _fixedExposure;
  114332. private _currentExposure;
  114333. private _hdrAutoExposure;
  114334. private _hdrCurrentLuminance;
  114335. private _floatTextureType;
  114336. private _ratio;
  114337. private _bloomEnabled;
  114338. private _depthOfFieldEnabled;
  114339. private _vlsEnabled;
  114340. private _lensFlareEnabled;
  114341. private _hdrEnabled;
  114342. private _motionBlurEnabled;
  114343. private _fxaaEnabled;
  114344. private _motionBlurSamples;
  114345. private _volumetricLightStepsCount;
  114346. private _samples;
  114347. /**
  114348. * @ignore
  114349. * Specifies if the bloom pipeline is enabled
  114350. */
  114351. BloomEnabled: boolean;
  114352. /**
  114353. * @ignore
  114354. * Specifies if the depth of field pipeline is enabed
  114355. */
  114356. DepthOfFieldEnabled: boolean;
  114357. /**
  114358. * @ignore
  114359. * Specifies if the lens flare pipeline is enabed
  114360. */
  114361. LensFlareEnabled: boolean;
  114362. /**
  114363. * @ignore
  114364. * Specifies if the HDR pipeline is enabled
  114365. */
  114366. HDREnabled: boolean;
  114367. /**
  114368. * @ignore
  114369. * Specifies if the volumetric lights scattering effect is enabled
  114370. */
  114371. VLSEnabled: boolean;
  114372. /**
  114373. * @ignore
  114374. * Specifies if the motion blur effect is enabled
  114375. */
  114376. MotionBlurEnabled: boolean;
  114377. /**
  114378. * Specifies if anti-aliasing is enabled
  114379. */
  114380. fxaaEnabled: boolean;
  114381. /**
  114382. * Specifies the number of steps used to calculate the volumetric lights
  114383. * Typically in interval [50, 200]
  114384. */
  114385. volumetricLightStepsCount: number;
  114386. /**
  114387. * Specifies the number of samples used for the motion blur effect
  114388. * Typically in interval [16, 64]
  114389. */
  114390. motionBlurSamples: number;
  114391. /**
  114392. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114393. */
  114394. samples: number;
  114395. /**
  114396. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114397. * @constructor
  114398. * @param name The rendering pipeline name
  114399. * @param scene The scene linked to this pipeline
  114400. * @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)
  114401. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114402. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114403. */
  114404. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114405. private _buildPipeline;
  114406. private _createDownSampleX4PostProcess;
  114407. private _createBrightPassPostProcess;
  114408. private _createBlurPostProcesses;
  114409. private _createTextureAdderPostProcess;
  114410. private _createVolumetricLightPostProcess;
  114411. private _createLuminancePostProcesses;
  114412. private _createHdrPostProcess;
  114413. private _createLensFlarePostProcess;
  114414. private _createDepthOfFieldPostProcess;
  114415. private _createMotionBlurPostProcess;
  114416. private _getDepthTexture;
  114417. private _disposePostProcesses;
  114418. /**
  114419. * Dispose of the pipeline and stop all post processes
  114420. */
  114421. dispose(): void;
  114422. /**
  114423. * Serialize the rendering pipeline (Used when exporting)
  114424. * @returns the serialized object
  114425. */
  114426. serialize(): any;
  114427. /**
  114428. * Parse the serialized pipeline
  114429. * @param source Source pipeline.
  114430. * @param scene The scene to load the pipeline to.
  114431. * @param rootUrl The URL of the serialized pipeline.
  114432. * @returns An instantiated pipeline from the serialized object.
  114433. */
  114434. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114435. /**
  114436. * Luminance steps
  114437. */
  114438. static LuminanceSteps: number;
  114439. }
  114440. }
  114441. declare module BABYLON {
  114442. /** @hidden */
  114443. export var tonemapPixelShader: {
  114444. name: string;
  114445. shader: string;
  114446. };
  114447. }
  114448. declare module BABYLON {
  114449. /** Defines operator used for tonemapping */
  114450. export enum TonemappingOperator {
  114451. /** Hable */
  114452. Hable = 0,
  114453. /** Reinhard */
  114454. Reinhard = 1,
  114455. /** HejiDawson */
  114456. HejiDawson = 2,
  114457. /** Photographic */
  114458. Photographic = 3
  114459. }
  114460. /**
  114461. * Defines a post process to apply tone mapping
  114462. */
  114463. export class TonemapPostProcess extends PostProcess {
  114464. private _operator;
  114465. /** Defines the required exposure adjustement */
  114466. exposureAdjustment: number;
  114467. /**
  114468. * Creates a new TonemapPostProcess
  114469. * @param name defines the name of the postprocess
  114470. * @param _operator defines the operator to use
  114471. * @param exposureAdjustment defines the required exposure adjustement
  114472. * @param camera defines the camera to use (can be null)
  114473. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114474. * @param engine defines the hosting engine (can be ignore if camera is set)
  114475. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114476. */
  114477. constructor(name: string, _operator: TonemappingOperator,
  114478. /** Defines the required exposure adjustement */
  114479. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114480. }
  114481. }
  114482. declare module BABYLON {
  114483. /** @hidden */
  114484. export var depthVertexShader: {
  114485. name: string;
  114486. shader: string;
  114487. };
  114488. }
  114489. declare module BABYLON {
  114490. /** @hidden */
  114491. export var volumetricLightScatteringPixelShader: {
  114492. name: string;
  114493. shader: string;
  114494. };
  114495. }
  114496. declare module BABYLON {
  114497. /** @hidden */
  114498. export var volumetricLightScatteringPassPixelShader: {
  114499. name: string;
  114500. shader: string;
  114501. };
  114502. }
  114503. declare module BABYLON {
  114504. /**
  114505. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114506. */
  114507. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114508. private _volumetricLightScatteringPass;
  114509. private _volumetricLightScatteringRTT;
  114510. private _viewPort;
  114511. private _screenCoordinates;
  114512. private _cachedDefines;
  114513. /**
  114514. * If not undefined, the mesh position is computed from the attached node position
  114515. */
  114516. attachedNode: {
  114517. position: Vector3;
  114518. };
  114519. /**
  114520. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114521. */
  114522. customMeshPosition: Vector3;
  114523. /**
  114524. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114525. */
  114526. useCustomMeshPosition: boolean;
  114527. /**
  114528. * If the post-process should inverse the light scattering direction
  114529. */
  114530. invert: boolean;
  114531. /**
  114532. * The internal mesh used by the post-process
  114533. */
  114534. mesh: Mesh;
  114535. /**
  114536. * @hidden
  114537. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114538. */
  114539. useDiffuseColor: boolean;
  114540. /**
  114541. * Array containing the excluded meshes not rendered in the internal pass
  114542. */
  114543. excludedMeshes: AbstractMesh[];
  114544. /**
  114545. * Controls the overall intensity of the post-process
  114546. */
  114547. exposure: number;
  114548. /**
  114549. * Dissipates each sample's contribution in range [0, 1]
  114550. */
  114551. decay: number;
  114552. /**
  114553. * Controls the overall intensity of each sample
  114554. */
  114555. weight: number;
  114556. /**
  114557. * Controls the density of each sample
  114558. */
  114559. density: number;
  114560. /**
  114561. * @constructor
  114562. * @param name The post-process name
  114563. * @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)
  114564. * @param camera The camera that the post-process will be attached to
  114565. * @param mesh The mesh used to create the light scattering
  114566. * @param samples The post-process quality, default 100
  114567. * @param samplingModeThe post-process filtering mode
  114568. * @param engine The babylon engine
  114569. * @param reusable If the post-process is reusable
  114570. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114571. */
  114572. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114573. /**
  114574. * Returns the string "VolumetricLightScatteringPostProcess"
  114575. * @returns "VolumetricLightScatteringPostProcess"
  114576. */
  114577. getClassName(): string;
  114578. private _isReady;
  114579. /**
  114580. * Sets the new light position for light scattering effect
  114581. * @param position The new custom light position
  114582. */
  114583. setCustomMeshPosition(position: Vector3): void;
  114584. /**
  114585. * Returns the light position for light scattering effect
  114586. * @return Vector3 The custom light position
  114587. */
  114588. getCustomMeshPosition(): Vector3;
  114589. /**
  114590. * Disposes the internal assets and detaches the post-process from the camera
  114591. */
  114592. dispose(camera: Camera): void;
  114593. /**
  114594. * Returns the render target texture used by the post-process
  114595. * @return the render target texture used by the post-process
  114596. */
  114597. getPass(): RenderTargetTexture;
  114598. private _meshExcluded;
  114599. private _createPass;
  114600. private _updateMeshScreenCoordinates;
  114601. /**
  114602. * Creates a default mesh for the Volumeric Light Scattering post-process
  114603. * @param name The mesh name
  114604. * @param scene The scene where to create the mesh
  114605. * @return the default mesh
  114606. */
  114607. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114608. }
  114609. }
  114610. declare module BABYLON {
  114611. interface Scene {
  114612. /** @hidden (Backing field) */
  114613. _boundingBoxRenderer: BoundingBoxRenderer;
  114614. /** @hidden (Backing field) */
  114615. _forceShowBoundingBoxes: boolean;
  114616. /**
  114617. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114618. */
  114619. forceShowBoundingBoxes: boolean;
  114620. /**
  114621. * Gets the bounding box renderer associated with the scene
  114622. * @returns a BoundingBoxRenderer
  114623. */
  114624. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114625. }
  114626. interface AbstractMesh {
  114627. /** @hidden (Backing field) */
  114628. _showBoundingBox: boolean;
  114629. /**
  114630. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114631. */
  114632. showBoundingBox: boolean;
  114633. }
  114634. /**
  114635. * Component responsible of rendering the bounding box of the meshes in a scene.
  114636. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114637. */
  114638. export class BoundingBoxRenderer implements ISceneComponent {
  114639. /**
  114640. * The component name helpfull to identify the component in the list of scene components.
  114641. */
  114642. readonly name: string;
  114643. /**
  114644. * The scene the component belongs to.
  114645. */
  114646. scene: Scene;
  114647. /**
  114648. * Color of the bounding box lines placed in front of an object
  114649. */
  114650. frontColor: Color3;
  114651. /**
  114652. * Color of the bounding box lines placed behind an object
  114653. */
  114654. backColor: Color3;
  114655. /**
  114656. * Defines if the renderer should show the back lines or not
  114657. */
  114658. showBackLines: boolean;
  114659. /**
  114660. * @hidden
  114661. */
  114662. renderList: SmartArray<BoundingBox>;
  114663. private _colorShader;
  114664. private _vertexBuffers;
  114665. private _indexBuffer;
  114666. /**
  114667. * Instantiates a new bounding box renderer in a scene.
  114668. * @param scene the scene the renderer renders in
  114669. */
  114670. constructor(scene: Scene);
  114671. /**
  114672. * Registers the component in a given scene
  114673. */
  114674. register(): void;
  114675. private _evaluateSubMesh;
  114676. private _activeMesh;
  114677. private _prepareRessources;
  114678. private _createIndexBuffer;
  114679. /**
  114680. * Rebuilds the elements related to this component in case of
  114681. * context lost for instance.
  114682. */
  114683. rebuild(): void;
  114684. /**
  114685. * @hidden
  114686. */
  114687. reset(): void;
  114688. /**
  114689. * Render the bounding boxes of a specific rendering group
  114690. * @param renderingGroupId defines the rendering group to render
  114691. */
  114692. render(renderingGroupId: number): void;
  114693. /**
  114694. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114695. * @param mesh Define the mesh to render the occlusion bounding box for
  114696. */
  114697. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114698. /**
  114699. * Dispose and release the resources attached to this renderer.
  114700. */
  114701. dispose(): void;
  114702. }
  114703. }
  114704. declare module BABYLON {
  114705. /** @hidden */
  114706. export var depthPixelShader: {
  114707. name: string;
  114708. shader: string;
  114709. };
  114710. }
  114711. declare module BABYLON {
  114712. /**
  114713. * This represents a depth renderer in Babylon.
  114714. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114715. */
  114716. export class DepthRenderer {
  114717. private _scene;
  114718. private _depthMap;
  114719. private _effect;
  114720. private _cachedDefines;
  114721. private _camera;
  114722. /**
  114723. * Specifiess that the depth renderer will only be used within
  114724. * the camera it is created for.
  114725. * This can help forcing its rendering during the camera processing.
  114726. */
  114727. useOnlyInActiveCamera: boolean;
  114728. /** @hidden */
  114729. static _SceneComponentInitialization: (scene: Scene) => void;
  114730. /**
  114731. * Instantiates a depth renderer
  114732. * @param scene The scene the renderer belongs to
  114733. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114734. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114735. */
  114736. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114737. /**
  114738. * Creates the depth rendering effect and checks if the effect is ready.
  114739. * @param subMesh The submesh to be used to render the depth map of
  114740. * @param useInstances If multiple world instances should be used
  114741. * @returns if the depth renderer is ready to render the depth map
  114742. */
  114743. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114744. /**
  114745. * Gets the texture which the depth map will be written to.
  114746. * @returns The depth map texture
  114747. */
  114748. getDepthMap(): RenderTargetTexture;
  114749. /**
  114750. * Disposes of the depth renderer.
  114751. */
  114752. dispose(): void;
  114753. }
  114754. }
  114755. declare module BABYLON {
  114756. interface Scene {
  114757. /** @hidden (Backing field) */
  114758. _depthRenderer: {
  114759. [id: string]: DepthRenderer;
  114760. };
  114761. /**
  114762. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114763. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114764. * @returns the created depth renderer
  114765. */
  114766. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114767. /**
  114768. * Disables a depth renderer for a given camera
  114769. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114770. */
  114771. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114772. }
  114773. /**
  114774. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114775. * in several rendering techniques.
  114776. */
  114777. export class DepthRendererSceneComponent implements ISceneComponent {
  114778. /**
  114779. * The component name helpfull to identify the component in the list of scene components.
  114780. */
  114781. readonly name: string;
  114782. /**
  114783. * The scene the component belongs to.
  114784. */
  114785. scene: Scene;
  114786. /**
  114787. * Creates a new instance of the component for the given scene
  114788. * @param scene Defines the scene to register the component in
  114789. */
  114790. constructor(scene: Scene);
  114791. /**
  114792. * Registers the component in a given scene
  114793. */
  114794. register(): void;
  114795. /**
  114796. * Rebuilds the elements related to this component in case of
  114797. * context lost for instance.
  114798. */
  114799. rebuild(): void;
  114800. /**
  114801. * Disposes the component and the associated ressources
  114802. */
  114803. dispose(): void;
  114804. private _gatherRenderTargets;
  114805. private _gatherActiveCameraRenderTargets;
  114806. }
  114807. }
  114808. declare module BABYLON {
  114809. /** @hidden */
  114810. export var outlinePixelShader: {
  114811. name: string;
  114812. shader: string;
  114813. };
  114814. }
  114815. declare module BABYLON {
  114816. /** @hidden */
  114817. export var outlineVertexShader: {
  114818. name: string;
  114819. shader: string;
  114820. };
  114821. }
  114822. declare module BABYLON {
  114823. interface Scene {
  114824. /** @hidden */
  114825. _outlineRenderer: OutlineRenderer;
  114826. /**
  114827. * Gets the outline renderer associated with the scene
  114828. * @returns a OutlineRenderer
  114829. */
  114830. getOutlineRenderer(): OutlineRenderer;
  114831. }
  114832. interface AbstractMesh {
  114833. /** @hidden (Backing field) */
  114834. _renderOutline: boolean;
  114835. /**
  114836. * Gets or sets a boolean indicating if the outline must be rendered as well
  114837. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114838. */
  114839. renderOutline: boolean;
  114840. /** @hidden (Backing field) */
  114841. _renderOverlay: boolean;
  114842. /**
  114843. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114844. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114845. */
  114846. renderOverlay: boolean;
  114847. }
  114848. /**
  114849. * This class is responsible to draw bothe outline/overlay of meshes.
  114850. * It should not be used directly but through the available method on mesh.
  114851. */
  114852. export class OutlineRenderer implements ISceneComponent {
  114853. /**
  114854. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114855. */
  114856. private static _StencilReference;
  114857. /**
  114858. * The name of the component. Each component must have a unique name.
  114859. */
  114860. name: string;
  114861. /**
  114862. * The scene the component belongs to.
  114863. */
  114864. scene: Scene;
  114865. /**
  114866. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114867. */
  114868. zOffset: number;
  114869. private _engine;
  114870. private _effect;
  114871. private _cachedDefines;
  114872. private _savedDepthWrite;
  114873. /**
  114874. * Instantiates a new outline renderer. (There could be only one per scene).
  114875. * @param scene Defines the scene it belongs to
  114876. */
  114877. constructor(scene: Scene);
  114878. /**
  114879. * Register the component to one instance of a scene.
  114880. */
  114881. register(): void;
  114882. /**
  114883. * Rebuilds the elements related to this component in case of
  114884. * context lost for instance.
  114885. */
  114886. rebuild(): void;
  114887. /**
  114888. * Disposes the component and the associated ressources.
  114889. */
  114890. dispose(): void;
  114891. /**
  114892. * Renders the outline in the canvas.
  114893. * @param subMesh Defines the sumesh to render
  114894. * @param batch Defines the batch of meshes in case of instances
  114895. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114896. */
  114897. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114898. /**
  114899. * Returns whether or not the outline renderer is ready for a given submesh.
  114900. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114901. * @param subMesh Defines the submesh to check readyness for
  114902. * @param useInstances Defines wheter wee are trying to render instances or not
  114903. * @returns true if ready otherwise false
  114904. */
  114905. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114906. private _beforeRenderingMesh;
  114907. private _afterRenderingMesh;
  114908. }
  114909. }
  114910. declare module BABYLON {
  114911. /**
  114912. * Defines the list of states available for a task inside a AssetsManager
  114913. */
  114914. export enum AssetTaskState {
  114915. /**
  114916. * Initialization
  114917. */
  114918. INIT = 0,
  114919. /**
  114920. * Running
  114921. */
  114922. RUNNING = 1,
  114923. /**
  114924. * Done
  114925. */
  114926. DONE = 2,
  114927. /**
  114928. * Error
  114929. */
  114930. ERROR = 3
  114931. }
  114932. /**
  114933. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  114934. */
  114935. export abstract class AbstractAssetTask {
  114936. /**
  114937. * Task name
  114938. */ name: string;
  114939. /**
  114940. * Callback called when the task is successful
  114941. */
  114942. onSuccess: (task: any) => void;
  114943. /**
  114944. * Callback called when the task is not successful
  114945. */
  114946. onError: (task: any, message?: string, exception?: any) => void;
  114947. /**
  114948. * Creates a new AssetsManager
  114949. * @param name defines the name of the task
  114950. */
  114951. constructor(
  114952. /**
  114953. * Task name
  114954. */ name: string);
  114955. private _isCompleted;
  114956. private _taskState;
  114957. private _errorObject;
  114958. /**
  114959. * Get if the task is completed
  114960. */
  114961. readonly isCompleted: boolean;
  114962. /**
  114963. * Gets the current state of the task
  114964. */
  114965. readonly taskState: AssetTaskState;
  114966. /**
  114967. * Gets the current error object (if task is in error)
  114968. */
  114969. readonly errorObject: {
  114970. message?: string;
  114971. exception?: any;
  114972. };
  114973. /**
  114974. * Internal only
  114975. * @hidden
  114976. */
  114977. _setErrorObject(message?: string, exception?: any): void;
  114978. /**
  114979. * Execute the current task
  114980. * @param scene defines the scene where you want your assets to be loaded
  114981. * @param onSuccess is a callback called when the task is successfully executed
  114982. * @param onError is a callback called if an error occurs
  114983. */
  114984. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114985. /**
  114986. * Execute the current task
  114987. * @param scene defines the scene where you want your assets to be loaded
  114988. * @param onSuccess is a callback called when the task is successfully executed
  114989. * @param onError is a callback called if an error occurs
  114990. */
  114991. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114992. /**
  114993. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114994. * This can be used with failed tasks that have the reason for failure fixed.
  114995. */
  114996. reset(): void;
  114997. private onErrorCallback;
  114998. private onDoneCallback;
  114999. }
  115000. /**
  115001. * Define the interface used by progress events raised during assets loading
  115002. */
  115003. export interface IAssetsProgressEvent {
  115004. /**
  115005. * Defines the number of remaining tasks to process
  115006. */
  115007. remainingCount: number;
  115008. /**
  115009. * Defines the total number of tasks
  115010. */
  115011. totalCount: number;
  115012. /**
  115013. * Defines the task that was just processed
  115014. */
  115015. task: AbstractAssetTask;
  115016. }
  115017. /**
  115018. * Class used to share progress information about assets loading
  115019. */
  115020. export class AssetsProgressEvent implements IAssetsProgressEvent {
  115021. /**
  115022. * Defines the number of remaining tasks to process
  115023. */
  115024. remainingCount: number;
  115025. /**
  115026. * Defines the total number of tasks
  115027. */
  115028. totalCount: number;
  115029. /**
  115030. * Defines the task that was just processed
  115031. */
  115032. task: AbstractAssetTask;
  115033. /**
  115034. * Creates a AssetsProgressEvent
  115035. * @param remainingCount defines the number of remaining tasks to process
  115036. * @param totalCount defines the total number of tasks
  115037. * @param task defines the task that was just processed
  115038. */
  115039. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  115040. }
  115041. /**
  115042. * Define a task used by AssetsManager to load meshes
  115043. */
  115044. export class MeshAssetTask extends AbstractAssetTask {
  115045. /**
  115046. * Defines the name of the task
  115047. */
  115048. name: string;
  115049. /**
  115050. * Defines the list of mesh's names you want to load
  115051. */
  115052. meshesNames: any;
  115053. /**
  115054. * Defines the root url to use as a base to load your meshes and associated resources
  115055. */
  115056. rootUrl: string;
  115057. /**
  115058. * Defines the filename of the scene to load from
  115059. */
  115060. sceneFilename: string;
  115061. /**
  115062. * Gets the list of loaded meshes
  115063. */
  115064. loadedMeshes: Array<AbstractMesh>;
  115065. /**
  115066. * Gets the list of loaded particle systems
  115067. */
  115068. loadedParticleSystems: Array<IParticleSystem>;
  115069. /**
  115070. * Gets the list of loaded skeletons
  115071. */
  115072. loadedSkeletons: Array<Skeleton>;
  115073. /**
  115074. * Gets the list of loaded animation groups
  115075. */
  115076. loadedAnimationGroups: Array<AnimationGroup>;
  115077. /**
  115078. * Callback called when the task is successful
  115079. */
  115080. onSuccess: (task: MeshAssetTask) => void;
  115081. /**
  115082. * Callback called when the task is successful
  115083. */
  115084. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  115085. /**
  115086. * Creates a new MeshAssetTask
  115087. * @param name defines the name of the task
  115088. * @param meshesNames defines the list of mesh's names you want to load
  115089. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  115090. * @param sceneFilename defines the filename of the scene to load from
  115091. */
  115092. constructor(
  115093. /**
  115094. * Defines the name of the task
  115095. */
  115096. name: string,
  115097. /**
  115098. * Defines the list of mesh's names you want to load
  115099. */
  115100. meshesNames: any,
  115101. /**
  115102. * Defines the root url to use as a base to load your meshes and associated resources
  115103. */
  115104. rootUrl: string,
  115105. /**
  115106. * Defines the filename of the scene to load from
  115107. */
  115108. sceneFilename: string);
  115109. /**
  115110. * Execute the current task
  115111. * @param scene defines the scene where you want your assets to be loaded
  115112. * @param onSuccess is a callback called when the task is successfully executed
  115113. * @param onError is a callback called if an error occurs
  115114. */
  115115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115116. }
  115117. /**
  115118. * Define a task used by AssetsManager to load text content
  115119. */
  115120. export class TextFileAssetTask extends AbstractAssetTask {
  115121. /**
  115122. * Defines the name of the task
  115123. */
  115124. name: string;
  115125. /**
  115126. * Defines the location of the file to load
  115127. */
  115128. url: string;
  115129. /**
  115130. * Gets the loaded text string
  115131. */
  115132. text: string;
  115133. /**
  115134. * Callback called when the task is successful
  115135. */
  115136. onSuccess: (task: TextFileAssetTask) => void;
  115137. /**
  115138. * Callback called when the task is successful
  115139. */
  115140. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  115141. /**
  115142. * Creates a new TextFileAssetTask object
  115143. * @param name defines the name of the task
  115144. * @param url defines the location of the file to load
  115145. */
  115146. constructor(
  115147. /**
  115148. * Defines the name of the task
  115149. */
  115150. name: string,
  115151. /**
  115152. * Defines the location of the file to load
  115153. */
  115154. url: string);
  115155. /**
  115156. * Execute the current task
  115157. * @param scene defines the scene where you want your assets to be loaded
  115158. * @param onSuccess is a callback called when the task is successfully executed
  115159. * @param onError is a callback called if an error occurs
  115160. */
  115161. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115162. }
  115163. /**
  115164. * Define a task used by AssetsManager to load binary data
  115165. */
  115166. export class BinaryFileAssetTask extends AbstractAssetTask {
  115167. /**
  115168. * Defines the name of the task
  115169. */
  115170. name: string;
  115171. /**
  115172. * Defines the location of the file to load
  115173. */
  115174. url: string;
  115175. /**
  115176. * Gets the lodaded data (as an array buffer)
  115177. */
  115178. data: ArrayBuffer;
  115179. /**
  115180. * Callback called when the task is successful
  115181. */
  115182. onSuccess: (task: BinaryFileAssetTask) => void;
  115183. /**
  115184. * Callback called when the task is successful
  115185. */
  115186. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  115187. /**
  115188. * Creates a new BinaryFileAssetTask object
  115189. * @param name defines the name of the new task
  115190. * @param url defines the location of the file to load
  115191. */
  115192. constructor(
  115193. /**
  115194. * Defines the name of the task
  115195. */
  115196. name: string,
  115197. /**
  115198. * Defines the location of the file to load
  115199. */
  115200. url: string);
  115201. /**
  115202. * Execute the current task
  115203. * @param scene defines the scene where you want your assets to be loaded
  115204. * @param onSuccess is a callback called when the task is successfully executed
  115205. * @param onError is a callback called if an error occurs
  115206. */
  115207. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115208. }
  115209. /**
  115210. * Define a task used by AssetsManager to load images
  115211. */
  115212. export class ImageAssetTask extends AbstractAssetTask {
  115213. /**
  115214. * Defines the name of the task
  115215. */
  115216. name: string;
  115217. /**
  115218. * Defines the location of the image to load
  115219. */
  115220. url: string;
  115221. /**
  115222. * Gets the loaded images
  115223. */
  115224. image: HTMLImageElement;
  115225. /**
  115226. * Callback called when the task is successful
  115227. */
  115228. onSuccess: (task: ImageAssetTask) => void;
  115229. /**
  115230. * Callback called when the task is successful
  115231. */
  115232. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  115233. /**
  115234. * Creates a new ImageAssetTask
  115235. * @param name defines the name of the task
  115236. * @param url defines the location of the image to load
  115237. */
  115238. constructor(
  115239. /**
  115240. * Defines the name of the task
  115241. */
  115242. name: string,
  115243. /**
  115244. * Defines the location of the image to load
  115245. */
  115246. url: string);
  115247. /**
  115248. * Execute the current task
  115249. * @param scene defines the scene where you want your assets to be loaded
  115250. * @param onSuccess is a callback called when the task is successfully executed
  115251. * @param onError is a callback called if an error occurs
  115252. */
  115253. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115254. }
  115255. /**
  115256. * Defines the interface used by texture loading tasks
  115257. */
  115258. export interface ITextureAssetTask<TEX extends BaseTexture> {
  115259. /**
  115260. * Gets the loaded texture
  115261. */
  115262. texture: TEX;
  115263. }
  115264. /**
  115265. * Define a task used by AssetsManager to load 2D textures
  115266. */
  115267. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  115268. /**
  115269. * Defines the name of the task
  115270. */
  115271. name: string;
  115272. /**
  115273. * Defines the location of the file to load
  115274. */
  115275. url: string;
  115276. /**
  115277. * Defines if mipmap should not be generated (default is false)
  115278. */
  115279. noMipmap?: boolean | undefined;
  115280. /**
  115281. * Defines if texture must be inverted on Y axis (default is false)
  115282. */
  115283. invertY?: boolean | undefined;
  115284. /**
  115285. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115286. */
  115287. samplingMode: number;
  115288. /**
  115289. * Gets the loaded texture
  115290. */
  115291. texture: Texture;
  115292. /**
  115293. * Callback called when the task is successful
  115294. */
  115295. onSuccess: (task: TextureAssetTask) => void;
  115296. /**
  115297. * Callback called when the task is successful
  115298. */
  115299. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  115300. /**
  115301. * Creates a new TextureAssetTask object
  115302. * @param name defines the name of the task
  115303. * @param url defines the location of the file to load
  115304. * @param noMipmap defines if mipmap should not be generated (default is false)
  115305. * @param invertY defines if texture must be inverted on Y axis (default is false)
  115306. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115307. */
  115308. constructor(
  115309. /**
  115310. * Defines the name of the task
  115311. */
  115312. name: string,
  115313. /**
  115314. * Defines the location of the file to load
  115315. */
  115316. url: string,
  115317. /**
  115318. * Defines if mipmap should not be generated (default is false)
  115319. */
  115320. noMipmap?: boolean | undefined,
  115321. /**
  115322. * Defines if texture must be inverted on Y axis (default is false)
  115323. */
  115324. invertY?: boolean | undefined,
  115325. /**
  115326. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115327. */
  115328. samplingMode?: number);
  115329. /**
  115330. * Execute the current task
  115331. * @param scene defines the scene where you want your assets to be loaded
  115332. * @param onSuccess is a callback called when the task is successfully executed
  115333. * @param onError is a callback called if an error occurs
  115334. */
  115335. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115336. }
  115337. /**
  115338. * Define a task used by AssetsManager to load cube textures
  115339. */
  115340. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  115341. /**
  115342. * Defines the name of the task
  115343. */
  115344. name: string;
  115345. /**
  115346. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115347. */
  115348. url: string;
  115349. /**
  115350. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115351. */
  115352. extensions?: string[] | undefined;
  115353. /**
  115354. * Defines if mipmaps should not be generated (default is false)
  115355. */
  115356. noMipmap?: boolean | undefined;
  115357. /**
  115358. * Defines the explicit list of files (undefined by default)
  115359. */
  115360. files?: string[] | undefined;
  115361. /**
  115362. * Gets the loaded texture
  115363. */
  115364. texture: CubeTexture;
  115365. /**
  115366. * Callback called when the task is successful
  115367. */
  115368. onSuccess: (task: CubeTextureAssetTask) => void;
  115369. /**
  115370. * Callback called when the task is successful
  115371. */
  115372. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  115373. /**
  115374. * Creates a new CubeTextureAssetTask
  115375. * @param name defines the name of the task
  115376. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115377. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115378. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115379. * @param files defines the explicit list of files (undefined by default)
  115380. */
  115381. constructor(
  115382. /**
  115383. * Defines the name of the task
  115384. */
  115385. name: string,
  115386. /**
  115387. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115388. */
  115389. url: string,
  115390. /**
  115391. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115392. */
  115393. extensions?: string[] | undefined,
  115394. /**
  115395. * Defines if mipmaps should not be generated (default is false)
  115396. */
  115397. noMipmap?: boolean | undefined,
  115398. /**
  115399. * Defines the explicit list of files (undefined by default)
  115400. */
  115401. files?: string[] | undefined);
  115402. /**
  115403. * Execute the current task
  115404. * @param scene defines the scene where you want your assets to be loaded
  115405. * @param onSuccess is a callback called when the task is successfully executed
  115406. * @param onError is a callback called if an error occurs
  115407. */
  115408. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115409. }
  115410. /**
  115411. * Define a task used by AssetsManager to load HDR cube textures
  115412. */
  115413. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115414. /**
  115415. * Defines the name of the task
  115416. */
  115417. name: string;
  115418. /**
  115419. * Defines the location of the file to load
  115420. */
  115421. url: string;
  115422. /**
  115423. * Defines the desired size (the more it increases the longer the generation will be)
  115424. */
  115425. size: number;
  115426. /**
  115427. * Defines if mipmaps should not be generated (default is false)
  115428. */
  115429. noMipmap: boolean;
  115430. /**
  115431. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115432. */
  115433. generateHarmonics: boolean;
  115434. /**
  115435. * 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)
  115436. */
  115437. gammaSpace: boolean;
  115438. /**
  115439. * Internal Use Only
  115440. */
  115441. reserved: boolean;
  115442. /**
  115443. * Gets the loaded texture
  115444. */
  115445. texture: HDRCubeTexture;
  115446. /**
  115447. * Callback called when the task is successful
  115448. */
  115449. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115450. /**
  115451. * Callback called when the task is successful
  115452. */
  115453. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115454. /**
  115455. * Creates a new HDRCubeTextureAssetTask object
  115456. * @param name defines the name of the task
  115457. * @param url defines the location of the file to load
  115458. * @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.
  115459. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115460. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115461. * @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)
  115462. * @param reserved Internal use only
  115463. */
  115464. constructor(
  115465. /**
  115466. * Defines the name of the task
  115467. */
  115468. name: string,
  115469. /**
  115470. * Defines the location of the file to load
  115471. */
  115472. url: string,
  115473. /**
  115474. * Defines the desired size (the more it increases the longer the generation will be)
  115475. */
  115476. size: number,
  115477. /**
  115478. * Defines if mipmaps should not be generated (default is false)
  115479. */
  115480. noMipmap?: boolean,
  115481. /**
  115482. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115483. */
  115484. generateHarmonics?: boolean,
  115485. /**
  115486. * 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)
  115487. */
  115488. gammaSpace?: boolean,
  115489. /**
  115490. * Internal Use Only
  115491. */
  115492. reserved?: boolean);
  115493. /**
  115494. * Execute the current task
  115495. * @param scene defines the scene where you want your assets to be loaded
  115496. * @param onSuccess is a callback called when the task is successfully executed
  115497. * @param onError is a callback called if an error occurs
  115498. */
  115499. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115500. }
  115501. /**
  115502. * Define a task used by AssetsManager to load Equirectangular cube textures
  115503. */
  115504. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115505. /**
  115506. * Defines the name of the task
  115507. */
  115508. name: string;
  115509. /**
  115510. * Defines the location of the file to load
  115511. */
  115512. url: string;
  115513. /**
  115514. * Defines the desired size (the more it increases the longer the generation will be)
  115515. */
  115516. size: number;
  115517. /**
  115518. * Defines if mipmaps should not be generated (default is false)
  115519. */
  115520. noMipmap: boolean;
  115521. /**
  115522. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115523. * but the standard material would require them in Gamma space) (default is true)
  115524. */
  115525. gammaSpace: boolean;
  115526. /**
  115527. * Gets the loaded texture
  115528. */
  115529. texture: EquiRectangularCubeTexture;
  115530. /**
  115531. * Callback called when the task is successful
  115532. */
  115533. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115534. /**
  115535. * Callback called when the task is successful
  115536. */
  115537. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115538. /**
  115539. * Creates a new EquiRectangularCubeTextureAssetTask object
  115540. * @param name defines the name of the task
  115541. * @param url defines the location of the file to load
  115542. * @param size defines the desired size (the more it increases the longer the generation will be)
  115543. * If the size is omitted this implies you are using a preprocessed cubemap.
  115544. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115545. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115546. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115547. * (default is true)
  115548. */
  115549. constructor(
  115550. /**
  115551. * Defines the name of the task
  115552. */
  115553. name: string,
  115554. /**
  115555. * Defines the location of the file to load
  115556. */
  115557. url: string,
  115558. /**
  115559. * Defines the desired size (the more it increases the longer the generation will be)
  115560. */
  115561. size: number,
  115562. /**
  115563. * Defines if mipmaps should not be generated (default is false)
  115564. */
  115565. noMipmap?: boolean,
  115566. /**
  115567. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115568. * but the standard material would require them in Gamma space) (default is true)
  115569. */
  115570. gammaSpace?: boolean);
  115571. /**
  115572. * Execute the current task
  115573. * @param scene defines the scene where you want your assets to be loaded
  115574. * @param onSuccess is a callback called when the task is successfully executed
  115575. * @param onError is a callback called if an error occurs
  115576. */
  115577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115578. }
  115579. /**
  115580. * This class can be used to easily import assets into a scene
  115581. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115582. */
  115583. export class AssetsManager {
  115584. private _scene;
  115585. private _isLoading;
  115586. protected _tasks: AbstractAssetTask[];
  115587. protected _waitingTasksCount: number;
  115588. protected _totalTasksCount: number;
  115589. /**
  115590. * Callback called when all tasks are processed
  115591. */
  115592. onFinish: (tasks: AbstractAssetTask[]) => void;
  115593. /**
  115594. * Callback called when a task is successful
  115595. */
  115596. onTaskSuccess: (task: AbstractAssetTask) => void;
  115597. /**
  115598. * Callback called when a task had an error
  115599. */
  115600. onTaskError: (task: AbstractAssetTask) => void;
  115601. /**
  115602. * Callback called when a task is done (whatever the result is)
  115603. */
  115604. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115605. /**
  115606. * Observable called when all tasks are processed
  115607. */
  115608. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115609. /**
  115610. * Observable called when a task had an error
  115611. */
  115612. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115613. /**
  115614. * Observable called when all tasks were executed
  115615. */
  115616. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115617. /**
  115618. * Observable called when a task is done (whatever the result is)
  115619. */
  115620. onProgressObservable: Observable<IAssetsProgressEvent>;
  115621. /**
  115622. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115623. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115624. */
  115625. useDefaultLoadingScreen: boolean;
  115626. /**
  115627. * Creates a new AssetsManager
  115628. * @param scene defines the scene to work on
  115629. */
  115630. constructor(scene: Scene);
  115631. /**
  115632. * Add a MeshAssetTask to the list of active tasks
  115633. * @param taskName defines the name of the new task
  115634. * @param meshesNames defines the name of meshes to load
  115635. * @param rootUrl defines the root url to use to locate files
  115636. * @param sceneFilename defines the filename of the scene file
  115637. * @returns a new MeshAssetTask object
  115638. */
  115639. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115640. /**
  115641. * Add a TextFileAssetTask to the list of active tasks
  115642. * @param taskName defines the name of the new task
  115643. * @param url defines the url of the file to load
  115644. * @returns a new TextFileAssetTask object
  115645. */
  115646. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115647. /**
  115648. * Add a BinaryFileAssetTask to the list of active tasks
  115649. * @param taskName defines the name of the new task
  115650. * @param url defines the url of the file to load
  115651. * @returns a new BinaryFileAssetTask object
  115652. */
  115653. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115654. /**
  115655. * Add a ImageAssetTask to the list of active tasks
  115656. * @param taskName defines the name of the new task
  115657. * @param url defines the url of the file to load
  115658. * @returns a new ImageAssetTask object
  115659. */
  115660. addImageTask(taskName: string, url: string): ImageAssetTask;
  115661. /**
  115662. * Add a TextureAssetTask to the list of active tasks
  115663. * @param taskName defines the name of the new task
  115664. * @param url defines the url of the file to load
  115665. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115666. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115667. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115668. * @returns a new TextureAssetTask object
  115669. */
  115670. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115671. /**
  115672. * Add a CubeTextureAssetTask to the list of active tasks
  115673. * @param taskName defines the name of the new task
  115674. * @param url defines the url of the file to load
  115675. * @param extensions defines the extension to use to load the cube map (can be null)
  115676. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115677. * @param files defines the list of files to load (can be null)
  115678. * @returns a new CubeTextureAssetTask object
  115679. */
  115680. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115681. /**
  115682. *
  115683. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115684. * @param taskName defines the name of the new task
  115685. * @param url defines the url of the file to load
  115686. * @param size defines the size you want for the cubemap (can be null)
  115687. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115688. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115689. * @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)
  115690. * @param reserved Internal use only
  115691. * @returns a new HDRCubeTextureAssetTask object
  115692. */
  115693. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115694. /**
  115695. *
  115696. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115697. * @param taskName defines the name of the new task
  115698. * @param url defines the url of the file to load
  115699. * @param size defines the size you want for the cubemap (can be null)
  115700. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115701. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115702. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115703. * @returns a new EquiRectangularCubeTextureAssetTask object
  115704. */
  115705. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115706. /**
  115707. * Remove a task from the assets manager.
  115708. * @param task the task to remove
  115709. */
  115710. removeTask(task: AbstractAssetTask): void;
  115711. private _decreaseWaitingTasksCount;
  115712. private _runTask;
  115713. /**
  115714. * Reset the AssetsManager and remove all tasks
  115715. * @return the current instance of the AssetsManager
  115716. */
  115717. reset(): AssetsManager;
  115718. /**
  115719. * Start the loading process
  115720. * @return the current instance of the AssetsManager
  115721. */
  115722. load(): AssetsManager;
  115723. /**
  115724. * Start the loading process as an async operation
  115725. * @return a promise returning the list of failed tasks
  115726. */
  115727. loadAsync(): Promise<void>;
  115728. }
  115729. }
  115730. declare module BABYLON {
  115731. /**
  115732. * Wrapper class for promise with external resolve and reject.
  115733. */
  115734. export class Deferred<T> {
  115735. /**
  115736. * The promise associated with this deferred object.
  115737. */
  115738. readonly promise: Promise<T>;
  115739. private _resolve;
  115740. private _reject;
  115741. /**
  115742. * The resolve method of the promise associated with this deferred object.
  115743. */
  115744. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115745. /**
  115746. * The reject method of the promise associated with this deferred object.
  115747. */
  115748. readonly reject: (reason?: any) => void;
  115749. /**
  115750. * Constructor for this deferred object.
  115751. */
  115752. constructor();
  115753. }
  115754. }
  115755. declare module BABYLON {
  115756. /**
  115757. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115758. */
  115759. export class MeshExploder {
  115760. private _centerMesh;
  115761. private _meshes;
  115762. private _meshesOrigins;
  115763. private _toCenterVectors;
  115764. private _scaledDirection;
  115765. private _newPosition;
  115766. private _centerPosition;
  115767. /**
  115768. * Explodes meshes from a center mesh.
  115769. * @param meshes The meshes to explode.
  115770. * @param centerMesh The mesh to be center of explosion.
  115771. */
  115772. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115773. private _setCenterMesh;
  115774. /**
  115775. * Get class name
  115776. * @returns "MeshExploder"
  115777. */
  115778. getClassName(): string;
  115779. /**
  115780. * "Exploded meshes"
  115781. * @returns Array of meshes with the centerMesh at index 0.
  115782. */
  115783. getMeshes(): Array<Mesh>;
  115784. /**
  115785. * Explodes meshes giving a specific direction
  115786. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115787. */
  115788. explode(direction?: number): void;
  115789. }
  115790. }
  115791. declare module BABYLON {
  115792. /**
  115793. * Class used to help managing file picking and drag'n'drop
  115794. */
  115795. export class FilesInput {
  115796. /**
  115797. * List of files ready to be loaded
  115798. */
  115799. static readonly FilesToLoad: {
  115800. [key: string]: File;
  115801. };
  115802. /**
  115803. * Callback called when a file is processed
  115804. */
  115805. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115806. private _engine;
  115807. private _currentScene;
  115808. private _sceneLoadedCallback;
  115809. private _progressCallback;
  115810. private _additionalRenderLoopLogicCallback;
  115811. private _textureLoadingCallback;
  115812. private _startingProcessingFilesCallback;
  115813. private _onReloadCallback;
  115814. private _errorCallback;
  115815. private _elementToMonitor;
  115816. private _sceneFileToLoad;
  115817. private _filesToLoad;
  115818. /**
  115819. * Creates a new FilesInput
  115820. * @param engine defines the rendering engine
  115821. * @param scene defines the hosting scene
  115822. * @param sceneLoadedCallback callback called when scene is loaded
  115823. * @param progressCallback callback called to track progress
  115824. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115825. * @param textureLoadingCallback callback called when a texture is loading
  115826. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115827. * @param onReloadCallback callback called when a reload is requested
  115828. * @param errorCallback callback call if an error occurs
  115829. */
  115830. 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);
  115831. private _dragEnterHandler;
  115832. private _dragOverHandler;
  115833. private _dropHandler;
  115834. /**
  115835. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115836. * @param elementToMonitor defines the DOM element to track
  115837. */
  115838. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115839. /**
  115840. * Release all associated resources
  115841. */
  115842. dispose(): void;
  115843. private renderFunction;
  115844. private drag;
  115845. private drop;
  115846. private _traverseFolder;
  115847. private _processFiles;
  115848. /**
  115849. * Load files from a drop event
  115850. * @param event defines the drop event to use as source
  115851. */
  115852. loadFiles(event: any): void;
  115853. private _processReload;
  115854. /**
  115855. * Reload the current scene from the loaded files
  115856. */
  115857. reload(): void;
  115858. }
  115859. }
  115860. declare module BABYLON {
  115861. /**
  115862. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115863. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115864. */
  115865. export class SceneOptimization {
  115866. /**
  115867. * Defines the priority of this optimization (0 by default which means first in the list)
  115868. */
  115869. priority: number;
  115870. /**
  115871. * Gets a string describing the action executed by the current optimization
  115872. * @returns description string
  115873. */
  115874. getDescription(): string;
  115875. /**
  115876. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115877. * @param scene defines the current scene where to apply this optimization
  115878. * @param optimizer defines the current optimizer
  115879. * @returns true if everything that can be done was applied
  115880. */
  115881. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115882. /**
  115883. * Creates the SceneOptimization object
  115884. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115885. * @param desc defines the description associated with the optimization
  115886. */
  115887. constructor(
  115888. /**
  115889. * Defines the priority of this optimization (0 by default which means first in the list)
  115890. */
  115891. priority?: number);
  115892. }
  115893. /**
  115894. * Defines an optimization used to reduce the size of render target textures
  115895. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115896. */
  115897. export class TextureOptimization extends SceneOptimization {
  115898. /**
  115899. * Defines the priority of this optimization (0 by default which means first in the list)
  115900. */
  115901. priority: number;
  115902. /**
  115903. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  115904. */
  115905. maximumSize: number;
  115906. /**
  115907. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115908. */
  115909. step: number;
  115910. /**
  115911. * Gets a string describing the action executed by the current optimization
  115912. * @returns description string
  115913. */
  115914. getDescription(): string;
  115915. /**
  115916. * Creates the TextureOptimization object
  115917. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115918. * @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
  115919. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115920. */
  115921. constructor(
  115922. /**
  115923. * Defines the priority of this optimization (0 by default which means first in the list)
  115924. */
  115925. priority?: number,
  115926. /**
  115927. * 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
  115928. */
  115929. maximumSize?: number,
  115930. /**
  115931. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115932. */
  115933. step?: number);
  115934. /**
  115935. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115936. * @param scene defines the current scene where to apply this optimization
  115937. * @param optimizer defines the current optimizer
  115938. * @returns true if everything that can be done was applied
  115939. */
  115940. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115941. }
  115942. /**
  115943. * Defines an optimization used to increase or decrease the rendering resolution
  115944. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115945. */
  115946. export class HardwareScalingOptimization extends SceneOptimization {
  115947. /**
  115948. * Defines the priority of this optimization (0 by default which means first in the list)
  115949. */
  115950. priority: number;
  115951. /**
  115952. * Defines the maximum scale to use (2 by default)
  115953. */
  115954. maximumScale: number;
  115955. /**
  115956. * Defines the step to use between two passes (0.5 by default)
  115957. */
  115958. step: number;
  115959. private _currentScale;
  115960. private _directionOffset;
  115961. /**
  115962. * Gets a string describing the action executed by the current optimization
  115963. * @return description string
  115964. */
  115965. getDescription(): string;
  115966. /**
  115967. * Creates the HardwareScalingOptimization object
  115968. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115969. * @param maximumScale defines the maximum scale to use (2 by default)
  115970. * @param step defines the step to use between two passes (0.5 by default)
  115971. */
  115972. constructor(
  115973. /**
  115974. * Defines the priority of this optimization (0 by default which means first in the list)
  115975. */
  115976. priority?: number,
  115977. /**
  115978. * Defines the maximum scale to use (2 by default)
  115979. */
  115980. maximumScale?: number,
  115981. /**
  115982. * Defines the step to use between two passes (0.5 by default)
  115983. */
  115984. step?: number);
  115985. /**
  115986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115987. * @param scene defines the current scene where to apply this optimization
  115988. * @param optimizer defines the current optimizer
  115989. * @returns true if everything that can be done was applied
  115990. */
  115991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115992. }
  115993. /**
  115994. * Defines an optimization used to remove shadows
  115995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115996. */
  115997. export class ShadowsOptimization extends SceneOptimization {
  115998. /**
  115999. * Gets a string describing the action executed by the current optimization
  116000. * @return description string
  116001. */
  116002. getDescription(): string;
  116003. /**
  116004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116005. * @param scene defines the current scene where to apply this optimization
  116006. * @param optimizer defines the current optimizer
  116007. * @returns true if everything that can be done was applied
  116008. */
  116009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116010. }
  116011. /**
  116012. * Defines an optimization used to turn post-processes off
  116013. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116014. */
  116015. export class PostProcessesOptimization extends SceneOptimization {
  116016. /**
  116017. * Gets a string describing the action executed by the current optimization
  116018. * @return description string
  116019. */
  116020. getDescription(): string;
  116021. /**
  116022. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116023. * @param scene defines the current scene where to apply this optimization
  116024. * @param optimizer defines the current optimizer
  116025. * @returns true if everything that can be done was applied
  116026. */
  116027. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116028. }
  116029. /**
  116030. * Defines an optimization used to turn lens flares off
  116031. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116032. */
  116033. export class LensFlaresOptimization extends SceneOptimization {
  116034. /**
  116035. * Gets a string describing the action executed by the current optimization
  116036. * @return description string
  116037. */
  116038. getDescription(): string;
  116039. /**
  116040. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116041. * @param scene defines the current scene where to apply this optimization
  116042. * @param optimizer defines the current optimizer
  116043. * @returns true if everything that can be done was applied
  116044. */
  116045. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116046. }
  116047. /**
  116048. * Defines an optimization based on user defined callback.
  116049. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116050. */
  116051. export class CustomOptimization extends SceneOptimization {
  116052. /**
  116053. * Callback called to apply the custom optimization.
  116054. */
  116055. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  116056. /**
  116057. * Callback called to get custom description
  116058. */
  116059. onGetDescription: () => string;
  116060. /**
  116061. * Gets a string describing the action executed by the current optimization
  116062. * @returns description string
  116063. */
  116064. getDescription(): string;
  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 turn particles off
  116075. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116076. */
  116077. export class ParticlesOptimization 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 render targets off
  116093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116094. */
  116095. export class RenderTargetsOptimization 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 merge meshes with compatible materials
  116111. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116112. */
  116113. export class MergeMeshesOptimization extends SceneOptimization {
  116114. private static _UpdateSelectionTree;
  116115. /**
  116116. * Gets or sets a boolean which defines if optimization octree has to be updated
  116117. */
  116118. /**
  116119. * Gets or sets a boolean which defines if optimization octree has to be updated
  116120. */
  116121. static UpdateSelectionTree: boolean;
  116122. /**
  116123. * Gets a string describing the action executed by the current optimization
  116124. * @return description string
  116125. */
  116126. getDescription(): string;
  116127. private _canBeMerged;
  116128. /**
  116129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116130. * @param scene defines the current scene where to apply this optimization
  116131. * @param optimizer defines the current optimizer
  116132. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  116133. * @returns true if everything that can be done was applied
  116134. */
  116135. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  116136. }
  116137. /**
  116138. * Defines a list of options used by SceneOptimizer
  116139. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116140. */
  116141. export class SceneOptimizerOptions {
  116142. /**
  116143. * Defines the target frame rate to reach (60 by default)
  116144. */
  116145. targetFrameRate: number;
  116146. /**
  116147. * Defines the interval between two checkes (2000ms by default)
  116148. */
  116149. trackerDuration: number;
  116150. /**
  116151. * Gets the list of optimizations to apply
  116152. */
  116153. optimizations: SceneOptimization[];
  116154. /**
  116155. * Creates a new list of options used by SceneOptimizer
  116156. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  116157. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  116158. */
  116159. constructor(
  116160. /**
  116161. * Defines the target frame rate to reach (60 by default)
  116162. */
  116163. targetFrameRate?: number,
  116164. /**
  116165. * Defines the interval between two checkes (2000ms by default)
  116166. */
  116167. trackerDuration?: number);
  116168. /**
  116169. * Add a new optimization
  116170. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  116171. * @returns the current SceneOptimizerOptions
  116172. */
  116173. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  116174. /**
  116175. * Add a new custom optimization
  116176. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  116177. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  116178. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116179. * @returns the current SceneOptimizerOptions
  116180. */
  116181. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  116182. /**
  116183. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  116184. * @param targetFrameRate defines the target frame rate (60 by default)
  116185. * @returns a SceneOptimizerOptions object
  116186. */
  116187. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116188. /**
  116189. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  116190. * @param targetFrameRate defines the target frame rate (60 by default)
  116191. * @returns a SceneOptimizerOptions object
  116192. */
  116193. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116194. /**
  116195. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  116196. * @param targetFrameRate defines the target frame rate (60 by default)
  116197. * @returns a SceneOptimizerOptions object
  116198. */
  116199. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116200. }
  116201. /**
  116202. * Class used to run optimizations in order to reach a target frame rate
  116203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116204. */
  116205. export class SceneOptimizer implements IDisposable {
  116206. private _isRunning;
  116207. private _options;
  116208. private _scene;
  116209. private _currentPriorityLevel;
  116210. private _targetFrameRate;
  116211. private _trackerDuration;
  116212. private _currentFrameRate;
  116213. private _sceneDisposeObserver;
  116214. private _improvementMode;
  116215. /**
  116216. * Defines an observable called when the optimizer reaches the target frame rate
  116217. */
  116218. onSuccessObservable: Observable<SceneOptimizer>;
  116219. /**
  116220. * Defines an observable called when the optimizer enables an optimization
  116221. */
  116222. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  116223. /**
  116224. * Defines an observable called when the optimizer is not able to reach the target frame rate
  116225. */
  116226. onFailureObservable: Observable<SceneOptimizer>;
  116227. /**
  116228. * Gets a boolean indicating if the optimizer is in improvement mode
  116229. */
  116230. readonly isInImprovementMode: boolean;
  116231. /**
  116232. * Gets the current priority level (0 at start)
  116233. */
  116234. readonly currentPriorityLevel: number;
  116235. /**
  116236. * Gets the current frame rate checked by the SceneOptimizer
  116237. */
  116238. readonly currentFrameRate: number;
  116239. /**
  116240. * Gets or sets the current target frame rate (60 by default)
  116241. */
  116242. /**
  116243. * Gets or sets the current target frame rate (60 by default)
  116244. */
  116245. targetFrameRate: number;
  116246. /**
  116247. * Gets or sets the current interval between two checks (every 2000ms by default)
  116248. */
  116249. /**
  116250. * Gets or sets the current interval between two checks (every 2000ms by default)
  116251. */
  116252. trackerDuration: number;
  116253. /**
  116254. * Gets the list of active optimizations
  116255. */
  116256. readonly optimizations: SceneOptimization[];
  116257. /**
  116258. * Creates a new SceneOptimizer
  116259. * @param scene defines the scene to work on
  116260. * @param options defines the options to use with the SceneOptimizer
  116261. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  116262. * @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)
  116263. */
  116264. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  116265. /**
  116266. * Stops the current optimizer
  116267. */
  116268. stop(): void;
  116269. /**
  116270. * Reset the optimizer to initial step (current priority level = 0)
  116271. */
  116272. reset(): void;
  116273. /**
  116274. * Start the optimizer. By default it will try to reach a specific framerate
  116275. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  116276. */
  116277. start(): void;
  116278. private _checkCurrentState;
  116279. /**
  116280. * Release all resources
  116281. */
  116282. dispose(): void;
  116283. /**
  116284. * Helper function to create a SceneOptimizer with one single line of code
  116285. * @param scene defines the scene to work on
  116286. * @param options defines the options to use with the SceneOptimizer
  116287. * @param onSuccess defines a callback to call on success
  116288. * @param onFailure defines a callback to call on failure
  116289. * @returns the new SceneOptimizer object
  116290. */
  116291. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  116292. }
  116293. }
  116294. declare module BABYLON {
  116295. /**
  116296. * Class used to serialize a scene into a string
  116297. */
  116298. export class SceneSerializer {
  116299. /**
  116300. * Clear cache used by a previous serialization
  116301. */
  116302. static ClearCache(): void;
  116303. /**
  116304. * Serialize a scene into a JSON compatible object
  116305. * @param scene defines the scene to serialize
  116306. * @returns a JSON compatible object
  116307. */
  116308. static Serialize(scene: Scene): any;
  116309. /**
  116310. * Serialize a mesh into a JSON compatible object
  116311. * @param toSerialize defines the mesh to serialize
  116312. * @param withParents defines if parents must be serialized as well
  116313. * @param withChildren defines if children must be serialized as well
  116314. * @returns a JSON compatible object
  116315. */
  116316. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  116317. }
  116318. }
  116319. declare module BABYLON {
  116320. /**
  116321. * Class used to host texture specific utilities
  116322. */
  116323. export class TextureTools {
  116324. /**
  116325. * Uses the GPU to create a copy texture rescaled at a given size
  116326. * @param texture Texture to copy from
  116327. * @param width defines the desired width
  116328. * @param height defines the desired height
  116329. * @param useBilinearMode defines if bilinear mode has to be used
  116330. * @return the generated texture
  116331. */
  116332. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  116333. }
  116334. }
  116335. declare module BABYLON {
  116336. /**
  116337. * This represents the different options avilable for the video capture.
  116338. */
  116339. export interface VideoRecorderOptions {
  116340. /** Defines the mime type of the video */
  116341. mimeType: string;
  116342. /** Defines the video the video should be recorded at */
  116343. fps: number;
  116344. /** Defines the chunk size for the recording data */
  116345. recordChunckSize: number;
  116346. /** The audio tracks to attach to the record */
  116347. audioTracks?: MediaStreamTrack[];
  116348. }
  116349. /**
  116350. * This can helps recording videos from BabylonJS.
  116351. * This is based on the available WebRTC functionalities of the browser.
  116352. *
  116353. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116354. */
  116355. export class VideoRecorder {
  116356. private static readonly _defaultOptions;
  116357. /**
  116358. * Returns wehther or not the VideoRecorder is available in your browser.
  116359. * @param engine Defines the Babylon Engine to check the support for
  116360. * @returns true if supported otherwise false
  116361. */
  116362. static IsSupported(engine: Engine): boolean;
  116363. private readonly _options;
  116364. private _canvas;
  116365. private _mediaRecorder;
  116366. private _recordedChunks;
  116367. private _fileName;
  116368. private _resolve;
  116369. private _reject;
  116370. /**
  116371. * True wether a recording is already in progress.
  116372. */
  116373. readonly isRecording: boolean;
  116374. /**
  116375. * Create a new VideoCapture object which can help converting what you see in Babylon to
  116376. * a video file.
  116377. * @param engine Defines the BabylonJS Engine you wish to record
  116378. * @param options Defines options that can be used to customized the capture
  116379. */
  116380. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  116381. /**
  116382. * Stops the current recording before the default capture timeout passed in the startRecording
  116383. * functions.
  116384. */
  116385. stopRecording(): void;
  116386. /**
  116387. * Starts recording the canvas for a max duration specified in parameters.
  116388. * @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.
  116389. * @param maxDuration Defines the maximum recording time in seconds.
  116390. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116391. * @return a promise callback at the end of the recording with the video data in Blob.
  116392. */
  116393. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116394. /**
  116395. * Releases internal resources used during the recording.
  116396. */
  116397. dispose(): void;
  116398. private _handleDataAvailable;
  116399. private _handleError;
  116400. private _handleStop;
  116401. }
  116402. }
  116403. declare module BABYLON {
  116404. /**
  116405. * Class containing a set of static utilities functions for screenshots
  116406. */
  116407. export class ScreenshotTools {
  116408. /**
  116409. * Captures a screenshot of the current rendering
  116410. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116411. * @param engine defines the rendering engine
  116412. * @param camera defines the source camera
  116413. * @param size This parameter can be set to a single number or to an object with the
  116414. * following (optional) properties: precision, width, height. If a single number is passed,
  116415. * it will be used for both width and height. If an object is passed, the screenshot size
  116416. * will be derived from the parameters. The precision property is a multiplier allowing
  116417. * rendering at a higher or lower resolution
  116418. * @param successCallback defines the callback receives a single parameter which contains the
  116419. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116420. * src parameter of an <img> to display it
  116421. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116422. * Check your browser for supported MIME types
  116423. */
  116424. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116425. /**
  116426. * Generates an image screenshot from the specified camera.
  116427. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116428. * @param engine The engine to use for rendering
  116429. * @param camera The camera to use for rendering
  116430. * @param size This parameter can be set to a single number or to an object with the
  116431. * following (optional) properties: precision, width, height. If a single number is passed,
  116432. * it will be used for both width and height. If an object is passed, the screenshot size
  116433. * will be derived from the parameters. The precision property is a multiplier allowing
  116434. * rendering at a higher or lower resolution
  116435. * @param successCallback The callback receives a single parameter which contains the
  116436. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116437. * src parameter of an <img> to display it
  116438. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116439. * Check your browser for supported MIME types
  116440. * @param samples Texture samples (default: 1)
  116441. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116442. * @param fileName A name for for the downloaded file.
  116443. */
  116444. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116445. }
  116446. }
  116447. declare module BABYLON {
  116448. /**
  116449. * A cursor which tracks a point on a path
  116450. */
  116451. export class PathCursor {
  116452. private path;
  116453. /**
  116454. * Stores path cursor callbacks for when an onchange event is triggered
  116455. */
  116456. private _onchange;
  116457. /**
  116458. * The value of the path cursor
  116459. */
  116460. value: number;
  116461. /**
  116462. * The animation array of the path cursor
  116463. */
  116464. animations: Animation[];
  116465. /**
  116466. * Initializes the path cursor
  116467. * @param path The path to track
  116468. */
  116469. constructor(path: Path2);
  116470. /**
  116471. * Gets the cursor point on the path
  116472. * @returns A point on the path cursor at the cursor location
  116473. */
  116474. getPoint(): Vector3;
  116475. /**
  116476. * Moves the cursor ahead by the step amount
  116477. * @param step The amount to move the cursor forward
  116478. * @returns This path cursor
  116479. */
  116480. moveAhead(step?: number): PathCursor;
  116481. /**
  116482. * Moves the cursor behind by the step amount
  116483. * @param step The amount to move the cursor back
  116484. * @returns This path cursor
  116485. */
  116486. moveBack(step?: number): PathCursor;
  116487. /**
  116488. * Moves the cursor by the step amount
  116489. * If the step amount is greater than one, an exception is thrown
  116490. * @param step The amount to move the cursor
  116491. * @returns This path cursor
  116492. */
  116493. move(step: number): PathCursor;
  116494. /**
  116495. * Ensures that the value is limited between zero and one
  116496. * @returns This path cursor
  116497. */
  116498. private ensureLimits;
  116499. /**
  116500. * Runs onchange callbacks on change (used by the animation engine)
  116501. * @returns This path cursor
  116502. */
  116503. private raiseOnChange;
  116504. /**
  116505. * Executes a function on change
  116506. * @param f A path cursor onchange callback
  116507. * @returns This path cursor
  116508. */
  116509. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116510. }
  116511. }
  116512. declare module BABYLON {
  116513. /** @hidden */
  116514. export var blurPixelShader: {
  116515. name: string;
  116516. shader: string;
  116517. };
  116518. }
  116519. declare module BABYLON {
  116520. /** @hidden */
  116521. export var bones300Declaration: {
  116522. name: string;
  116523. shader: string;
  116524. };
  116525. }
  116526. declare module BABYLON {
  116527. /** @hidden */
  116528. export var instances300Declaration: {
  116529. name: string;
  116530. shader: string;
  116531. };
  116532. }
  116533. declare module BABYLON {
  116534. /** @hidden */
  116535. export var pointCloudVertexDeclaration: {
  116536. name: string;
  116537. shader: string;
  116538. };
  116539. }
  116540. // Mixins
  116541. interface Window {
  116542. mozIndexedDB: IDBFactory;
  116543. webkitIndexedDB: IDBFactory;
  116544. msIndexedDB: IDBFactory;
  116545. webkitURL: typeof URL;
  116546. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116547. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116548. WebGLRenderingContext: WebGLRenderingContext;
  116549. MSGesture: MSGesture;
  116550. CANNON: any;
  116551. AudioContext: AudioContext;
  116552. webkitAudioContext: AudioContext;
  116553. PointerEvent: any;
  116554. Math: Math;
  116555. Uint8Array: Uint8ArrayConstructor;
  116556. Float32Array: Float32ArrayConstructor;
  116557. mozURL: typeof URL;
  116558. msURL: typeof URL;
  116559. VRFrameData: any; // WebVR, from specs 1.1
  116560. DracoDecoderModule: any;
  116561. setImmediate(handler: (...args: any[]) => void): number;
  116562. }
  116563. interface HTMLCanvasElement {
  116564. requestPointerLock(): void;
  116565. msRequestPointerLock?(): void;
  116566. mozRequestPointerLock?(): void;
  116567. webkitRequestPointerLock?(): void;
  116568. /** Track wether a record is in progress */
  116569. isRecording: boolean;
  116570. /** Capture Stream method defined by some browsers */
  116571. captureStream(fps?: number): MediaStream;
  116572. }
  116573. interface CanvasRenderingContext2D {
  116574. msImageSmoothingEnabled: boolean;
  116575. }
  116576. interface MouseEvent {
  116577. mozMovementX: number;
  116578. mozMovementY: number;
  116579. webkitMovementX: number;
  116580. webkitMovementY: number;
  116581. msMovementX: number;
  116582. msMovementY: number;
  116583. }
  116584. interface Navigator {
  116585. mozGetVRDevices: (any: any) => any;
  116586. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116587. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116588. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116589. webkitGetGamepads(): Gamepad[];
  116590. msGetGamepads(): Gamepad[];
  116591. webkitGamepads(): Gamepad[];
  116592. }
  116593. interface HTMLVideoElement {
  116594. mozSrcObject: any;
  116595. }
  116596. interface Math {
  116597. fround(x: number): number;
  116598. imul(a: number, b: number): number;
  116599. }
  116600. interface WebGLRenderingContext {
  116601. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116602. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116603. vertexAttribDivisor(index: number, divisor: number): void;
  116604. createVertexArray(): any;
  116605. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116606. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116607. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116608. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116609. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116610. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116611. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116612. // Queries
  116613. createQuery(): WebGLQuery;
  116614. deleteQuery(query: WebGLQuery): void;
  116615. beginQuery(target: number, query: WebGLQuery): void;
  116616. endQuery(target: number): void;
  116617. getQueryParameter(query: WebGLQuery, pname: number): any;
  116618. getQuery(target: number, pname: number): any;
  116619. MAX_SAMPLES: number;
  116620. RGBA8: number;
  116621. READ_FRAMEBUFFER: number;
  116622. DRAW_FRAMEBUFFER: number;
  116623. UNIFORM_BUFFER: number;
  116624. HALF_FLOAT_OES: number;
  116625. RGBA16F: number;
  116626. RGBA32F: number;
  116627. R32F: number;
  116628. RG32F: number;
  116629. RGB32F: number;
  116630. R16F: number;
  116631. RG16F: number;
  116632. RGB16F: number;
  116633. RED: number;
  116634. RG: number;
  116635. R8: number;
  116636. RG8: number;
  116637. UNSIGNED_INT_24_8: number;
  116638. DEPTH24_STENCIL8: number;
  116639. /* Multiple Render Targets */
  116640. drawBuffers(buffers: number[]): void;
  116641. readBuffer(src: number): void;
  116642. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116643. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116644. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116645. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116646. // Occlusion Query
  116647. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116648. ANY_SAMPLES_PASSED: number;
  116649. QUERY_RESULT_AVAILABLE: number;
  116650. QUERY_RESULT: number;
  116651. }
  116652. interface WebGLProgram {
  116653. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116654. }
  116655. interface EXT_disjoint_timer_query {
  116656. QUERY_COUNTER_BITS_EXT: number;
  116657. TIME_ELAPSED_EXT: number;
  116658. TIMESTAMP_EXT: number;
  116659. GPU_DISJOINT_EXT: number;
  116660. QUERY_RESULT_EXT: number;
  116661. QUERY_RESULT_AVAILABLE_EXT: number;
  116662. queryCounterEXT(query: WebGLQuery, target: number): void;
  116663. createQueryEXT(): WebGLQuery;
  116664. beginQueryEXT(target: number, query: WebGLQuery): void;
  116665. endQueryEXT(target: number): void;
  116666. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116667. deleteQueryEXT(query: WebGLQuery): void;
  116668. }
  116669. interface WebGLUniformLocation {
  116670. _currentState: any;
  116671. }
  116672. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116673. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116674. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116675. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116676. interface WebGLRenderingContext {
  116677. readonly RASTERIZER_DISCARD: number;
  116678. readonly DEPTH_COMPONENT24: number;
  116679. readonly TEXTURE_3D: number;
  116680. readonly TEXTURE_2D_ARRAY: number;
  116681. readonly TEXTURE_COMPARE_FUNC: number;
  116682. readonly TEXTURE_COMPARE_MODE: number;
  116683. readonly COMPARE_REF_TO_TEXTURE: number;
  116684. readonly TEXTURE_WRAP_R: number;
  116685. readonly HALF_FLOAT: number;
  116686. readonly RGB8: number;
  116687. readonly RED_INTEGER: number;
  116688. readonly RG_INTEGER: number;
  116689. readonly RGB_INTEGER: number;
  116690. readonly RGBA_INTEGER: number;
  116691. readonly R8_SNORM: number;
  116692. readonly RG8_SNORM: number;
  116693. readonly RGB8_SNORM: number;
  116694. readonly RGBA8_SNORM: number;
  116695. readonly R8I: number;
  116696. readonly RG8I: number;
  116697. readonly RGB8I: number;
  116698. readonly RGBA8I: number;
  116699. readonly R8UI: number;
  116700. readonly RG8UI: number;
  116701. readonly RGB8UI: number;
  116702. readonly RGBA8UI: number;
  116703. readonly R16I: number;
  116704. readonly RG16I: number;
  116705. readonly RGB16I: number;
  116706. readonly RGBA16I: number;
  116707. readonly R16UI: number;
  116708. readonly RG16UI: number;
  116709. readonly RGB16UI: number;
  116710. readonly RGBA16UI: number;
  116711. readonly R32I: number;
  116712. readonly RG32I: number;
  116713. readonly RGB32I: number;
  116714. readonly RGBA32I: number;
  116715. readonly R32UI: number;
  116716. readonly RG32UI: number;
  116717. readonly RGB32UI: number;
  116718. readonly RGBA32UI: number;
  116719. readonly RGB10_A2UI: number;
  116720. readonly R11F_G11F_B10F: number;
  116721. readonly RGB9_E5: number;
  116722. readonly RGB10_A2: number;
  116723. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116724. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116725. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116726. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116727. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116728. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116729. 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;
  116730. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116731. readonly TRANSFORM_FEEDBACK: number;
  116732. readonly INTERLEAVED_ATTRIBS: number;
  116733. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116734. createTransformFeedback(): WebGLTransformFeedback;
  116735. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116736. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116737. beginTransformFeedback(primitiveMode: number): void;
  116738. endTransformFeedback(): void;
  116739. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116740. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116741. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116742. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116743. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116744. }
  116745. interface ImageBitmap {
  116746. readonly width: number;
  116747. readonly height: number;
  116748. close(): void;
  116749. }
  116750. interface WebGLQuery extends WebGLObject {
  116751. }
  116752. declare var WebGLQuery: {
  116753. prototype: WebGLQuery;
  116754. new(): WebGLQuery;
  116755. };
  116756. interface WebGLSampler extends WebGLObject {
  116757. }
  116758. declare var WebGLSampler: {
  116759. prototype: WebGLSampler;
  116760. new(): WebGLSampler;
  116761. };
  116762. interface WebGLSync extends WebGLObject {
  116763. }
  116764. declare var WebGLSync: {
  116765. prototype: WebGLSync;
  116766. new(): WebGLSync;
  116767. };
  116768. interface WebGLTransformFeedback extends WebGLObject {
  116769. }
  116770. declare var WebGLTransformFeedback: {
  116771. prototype: WebGLTransformFeedback;
  116772. new(): WebGLTransformFeedback;
  116773. };
  116774. interface WebGLVertexArrayObject extends WebGLObject {
  116775. }
  116776. declare var WebGLVertexArrayObject: {
  116777. prototype: WebGLVertexArrayObject;
  116778. new(): WebGLVertexArrayObject;
  116779. };
  116780. // Type definitions for WebVR API
  116781. // Project: https://w3c.github.io/webvr/
  116782. // Definitions by: six a <https://github.com/lostfictions>
  116783. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116784. interface VRDisplay extends EventTarget {
  116785. /**
  116786. * Dictionary of capabilities describing the VRDisplay.
  116787. */
  116788. readonly capabilities: VRDisplayCapabilities;
  116789. /**
  116790. * z-depth defining the far plane of the eye view frustum
  116791. * enables mapping of values in the render target depth
  116792. * attachment to scene coordinates. Initially set to 10000.0.
  116793. */
  116794. depthFar: number;
  116795. /**
  116796. * z-depth defining the near plane of the eye view frustum
  116797. * enables mapping of values in the render target depth
  116798. * attachment to scene coordinates. Initially set to 0.01.
  116799. */
  116800. depthNear: number;
  116801. /**
  116802. * An identifier for this distinct VRDisplay. Used as an
  116803. * association point in the Gamepad API.
  116804. */
  116805. readonly displayId: number;
  116806. /**
  116807. * A display name, a user-readable name identifying it.
  116808. */
  116809. readonly displayName: string;
  116810. readonly isConnected: boolean;
  116811. readonly isPresenting: boolean;
  116812. /**
  116813. * If this VRDisplay supports room-scale experiences, the optional
  116814. * stage attribute contains details on the room-scale parameters.
  116815. */
  116816. readonly stageParameters: VRStageParameters | null;
  116817. /**
  116818. * Passing the value returned by `requestAnimationFrame` to
  116819. * `cancelAnimationFrame` will unregister the callback.
  116820. * @param handle Define the hanle of the request to cancel
  116821. */
  116822. cancelAnimationFrame(handle: number): void;
  116823. /**
  116824. * Stops presenting to the VRDisplay.
  116825. * @returns a promise to know when it stopped
  116826. */
  116827. exitPresent(): Promise<void>;
  116828. /**
  116829. * Return the current VREyeParameters for the given eye.
  116830. * @param whichEye Define the eye we want the parameter for
  116831. * @returns the eye parameters
  116832. */
  116833. getEyeParameters(whichEye: string): VREyeParameters;
  116834. /**
  116835. * Populates the passed VRFrameData with the information required to render
  116836. * the current frame.
  116837. * @param frameData Define the data structure to populate
  116838. * @returns true if ok otherwise false
  116839. */
  116840. getFrameData(frameData: VRFrameData): boolean;
  116841. /**
  116842. * Get the layers currently being presented.
  116843. * @returns the list of VR layers
  116844. */
  116845. getLayers(): VRLayer[];
  116846. /**
  116847. * Return a VRPose containing the future predicted pose of the VRDisplay
  116848. * when the current frame will be presented. The value returned will not
  116849. * change until JavaScript has returned control to the browser.
  116850. *
  116851. * The VRPose will contain the position, orientation, velocity,
  116852. * and acceleration of each of these properties.
  116853. * @returns the pose object
  116854. */
  116855. getPose(): VRPose;
  116856. /**
  116857. * Return the current instantaneous pose of the VRDisplay, with no
  116858. * prediction applied.
  116859. * @returns the current instantaneous pose
  116860. */
  116861. getImmediatePose(): VRPose;
  116862. /**
  116863. * The callback passed to `requestAnimationFrame` will be called
  116864. * any time a new frame should be rendered. When the VRDisplay is
  116865. * presenting the callback will be called at the native refresh
  116866. * rate of the HMD. When not presenting this function acts
  116867. * identically to how window.requestAnimationFrame acts. Content should
  116868. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116869. * asynchronously from other displays and at differing refresh rates.
  116870. * @param callback Define the eaction to run next frame
  116871. * @returns the request handle it
  116872. */
  116873. requestAnimationFrame(callback: FrameRequestCallback): number;
  116874. /**
  116875. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116876. * Repeat calls while already presenting will update the VRLayers being displayed.
  116877. * @param layers Define the list of layer to present
  116878. * @returns a promise to know when the request has been fulfilled
  116879. */
  116880. requestPresent(layers: VRLayer[]): Promise<void>;
  116881. /**
  116882. * Reset the pose for this display, treating its current position and
  116883. * orientation as the "origin/zero" values. VRPose.position,
  116884. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116885. * updated when calling resetPose(). This should be called in only
  116886. * sitting-space experiences.
  116887. */
  116888. resetPose(): void;
  116889. /**
  116890. * The VRLayer provided to the VRDisplay will be captured and presented
  116891. * in the HMD. Calling this function has the same effect on the source
  116892. * canvas as any other operation that uses its source image, and canvases
  116893. * created without preserveDrawingBuffer set to true will be cleared.
  116894. * @param pose Define the pose to submit
  116895. */
  116896. submitFrame(pose?: VRPose): void;
  116897. }
  116898. declare var VRDisplay: {
  116899. prototype: VRDisplay;
  116900. new(): VRDisplay;
  116901. };
  116902. interface VRLayer {
  116903. leftBounds?: number[] | Float32Array | null;
  116904. rightBounds?: number[] | Float32Array | null;
  116905. source?: HTMLCanvasElement | null;
  116906. }
  116907. interface VRDisplayCapabilities {
  116908. readonly canPresent: boolean;
  116909. readonly hasExternalDisplay: boolean;
  116910. readonly hasOrientation: boolean;
  116911. readonly hasPosition: boolean;
  116912. readonly maxLayers: number;
  116913. }
  116914. interface VREyeParameters {
  116915. /** @deprecated */
  116916. readonly fieldOfView: VRFieldOfView;
  116917. readonly offset: Float32Array;
  116918. readonly renderHeight: number;
  116919. readonly renderWidth: number;
  116920. }
  116921. interface VRFieldOfView {
  116922. readonly downDegrees: number;
  116923. readonly leftDegrees: number;
  116924. readonly rightDegrees: number;
  116925. readonly upDegrees: number;
  116926. }
  116927. interface VRFrameData {
  116928. readonly leftProjectionMatrix: Float32Array;
  116929. readonly leftViewMatrix: Float32Array;
  116930. readonly pose: VRPose;
  116931. readonly rightProjectionMatrix: Float32Array;
  116932. readonly rightViewMatrix: Float32Array;
  116933. readonly timestamp: number;
  116934. }
  116935. interface VRPose {
  116936. readonly angularAcceleration: Float32Array | null;
  116937. readonly angularVelocity: Float32Array | null;
  116938. readonly linearAcceleration: Float32Array | null;
  116939. readonly linearVelocity: Float32Array | null;
  116940. readonly orientation: Float32Array | null;
  116941. readonly position: Float32Array | null;
  116942. readonly timestamp: number;
  116943. }
  116944. interface VRStageParameters {
  116945. sittingToStandingTransform?: Float32Array;
  116946. sizeX?: number;
  116947. sizeY?: number;
  116948. }
  116949. interface Navigator {
  116950. getVRDisplays(): Promise<VRDisplay[]>;
  116951. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116952. }
  116953. interface Window {
  116954. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116955. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116956. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116957. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116958. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116959. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116960. }
  116961. interface Gamepad {
  116962. readonly displayId: number;
  116963. }
  116964. interface XRDevice {
  116965. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116966. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116967. }
  116968. interface XRSession {
  116969. getInputSources(): Array<any>;
  116970. baseLayer: XRWebGLLayer;
  116971. requestFrameOfReference(type: string): Promise<void>;
  116972. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116973. end(): Promise<void>;
  116974. requestAnimationFrame: Function;
  116975. addEventListener: Function;
  116976. }
  116977. interface XRSessionCreationOptions {
  116978. outputContext?: WebGLRenderingContext | null;
  116979. immersive?: boolean;
  116980. environmentIntegration?: boolean;
  116981. }
  116982. interface XRLayer {
  116983. getViewport: Function;
  116984. framebufferWidth: number;
  116985. framebufferHeight: number;
  116986. }
  116987. interface XRView {
  116988. projectionMatrix: Float32Array;
  116989. }
  116990. interface XRFrame {
  116991. getDevicePose: Function;
  116992. getInputPose: Function;
  116993. views: Array<XRView>;
  116994. baseLayer: XRLayer;
  116995. }
  116996. interface XRFrameOfReference {
  116997. }
  116998. interface XRWebGLLayer extends XRLayer {
  116999. framebuffer: WebGLFramebuffer;
  117000. }
  117001. declare var XRWebGLLayer: {
  117002. prototype: XRWebGLLayer;
  117003. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  117004. };